/everything-claude-code:iterative-retrievalfrom everything-claude-code
逐步细化上下文检索以解决子 agent 上下文问题的模式,通过4阶段循环(分发、评估、优化、循环)迭代获取相关文件。
Ships in everything-claude-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
解决多 agent 工作流中的“上下文问题”,即子 agent 在开始工作之前不知道它们需要什么上下文。
子 agent 生成时上下文有限。它们不知道:
标准方法会失败:
一个逐步细化上下文的 4 阶段循环:
┌─────────────────────────────────────────────┐
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ DISPATCH │─────▶│ EVALUATE │ │
│ └──────────┘ └──────────┘ │
│ ▲ │ │
│ │ ▼ │
│ ┌──────────┐ ┌──────────┐ │
│ │ LOOP │◀─────│ REFINE │ │
│ └──────────┘ └──────────┘ │
│ │
│ Max 3 cycles, then proceed │
│ │
└─────────────────────────────────────────────┘
初始广泛查询以收集候选文件:
// 从高层意图开始
const initialQuery = {
patterns: ['src/**/*.ts', 'lib/**/*.ts'],
keywords: ['authentication', 'user', 'session'],
excludes: ['*.test.ts', '*.spec.ts']
};
// 分发给检索 agent
const candidates = await retrieveFiles(initialQuery);
评估检索内容的即相关性:
function evaluateRelevance(files, task) {
return files.map(file => ({
path: file.path,
relevance: scoreRelevance(file.content, task),
reason: explainRelevance(file.content, task),
missingContext: identifyGaps(file.content, task)
}));
}
评分标准:
根据评估更新搜索条件:
function refineQuery(evaluation, previousQuery) {
return {
// 添加在高相关性文件中发现的新模式
patterns: [...previousQuery.patterns, ...extractPatterns(evaluation)],
// 添加在代码库中发现的术语
keywords: [...previousQuery.keywords, ...extractKeywords(evaluation)],
// 排除确认不相关的路径
excludes: [...previousQuery.excludes, ...evaluation
.filter(e => e.relevance < 0.2)
.map(e => e.path)
],
// 针对特定缺口
focusAreas: evaluation
.flatMap(e => e.missingContext)
.filter(unique)
};
}
使用优化后的条件重复(最多 3 个周期):
async function iterativeRetrieve(task, maxCycles = 3) {
let query = createInitialQuery(task);
let bestContext = [];
for (let cycle = 0; cycle < maxCycles; cycle++) {
const candidates = await retrieveFiles(query);
const evaluation = evaluateRelevance(candidates, task);
// 检查是否有足够的上下文
const highRelevance = evaluation.filter(e => e.relevance >= 0.7);
if (highRelevance.length >= 3 && !hasCriticalGaps(evaluation)) {
return highRelevance;
}
// 优化并继续
query = refineQuery(evaluation, query);
bestContext = mergeContext(bestContext, highRelevance);
}
return bestContext;
}
Task: "修复认证令牌过期 bug"
Cycle 1:
DISPATCH: 在 src/** 中搜索 "token", "auth", "expiry"
EVALUATE: 找到 auth.ts (0.9), tokens.ts (0.8), user.ts (0.3)
REFINE: 添加 "refresh", "jwt" 关键字; 排除 user.ts
Cycle 2:
DISPATCH: 搜索优化后的术语
EVALUATE: 找到 session-manager.ts (0.95), jwt-utils.ts (0.85)
REFINE: 足够的上下文 (2 high-relevance files)
Result: auth.ts, tokens.ts, session-manager.ts, jwt-utils.ts
Task: "添加 API 端点的速率限制"
Cycle 1:
DISPATCH: 在 routes/** 中搜索 "rate", "limit", "api"
EVALUATE: 无匹配 - 代码库使用 "throttle" 术语
REFINE: 添加 "throttle", "middleware" 关键字
Cycle 2:
DISPATCH: 搜索优化后的术语
EVALUATE: 找到 throttle.ts (0.9), middleware/index.ts (0.7)
REFINE: 需要 router 模式
Cycle 3:
DISPATCH: 搜索 "router", "express" 模式
EVALUATE: 找到 router-setup.ts (0.8)
REFINE: 足够的上下文
Result: throttle.ts, middleware/index.ts, router-setup.ts
在 agent prompts 中使用:
当为此任务检索上下文时:
1. 从广泛的关键字搜索开始
2. 评估每个文件的相关性 (0-1 等级)
3. 识别仍然缺失的上下文
4. 优化搜索条件并重复(最多 3 个周期)
5. 返回相关性 >= 0.7 的文件
continuous-learning skill - 用于随时间改进的模式~/.claude/agents/ 中的 Agent 定义What SKILL.md sets; muted values are Claude Code's defaults
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: agents: Invalid string: must end with ".md"
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
272 skills in this plugin
/accessibility使用 WCAG 2.2 AA 级标准设计、实施和审计包容性数字产品。使用此技能为 Web 和原生平台(iOS/Android)生成语义化 ARIA 和辅助功能属性。/agent-architecture-audit智能体和 LLM 应用的全栈诊断。审计 12 层智能体堆栈,检查包装器回归、内存污染、工具纪律失败、隐藏修复循环和渲染损坏。生成按严重程度排序的发现和代码优先修复。对于构建智能体应用、自主循环或任何 LLM 驱动功能的开发者至关重要。/agent-eval在自定义任务上对编码智能体(Claude Code、Aider、Codex 等)进行头对头比较,包含通过率、成本、时间和一致性指标/agent-harness-construction设计和优化 AI 智能体操作空间、工具定义和观察格式,以获得更高的完成率。Other plugins' skills for the same job