xu-xiang/everything-claude-code-zh/iterative-retrieval
Claude Code and agent skill by xu-xiang/everything-claude-code-zh
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
逐步优化上下文检索以解决子智能体(subagent)上下文问题的模式。
Install
npx vskill@latest install xu-xiang/everything-claude-code-zh/iterative-retrievalSKILL.md
迭代检索模式(Iterative Retrieval Pattern)
解决了多智能体工作流(multi-agent workflows)中的“上下文问题”——子智能体(subagent)在开始工作前往往不知道自己需要哪些上下文。
何时激活
- 生成需要事先无法完全预测的代码库上下文(codebase context)的子智能体时
- 构建上下文需要逐步优化的多智能体工作流时
- 在智能体任务中遇到“上下文过大”或“缺失上下文”的失败时
- 为代码探索设计类 RAG 的检索流水线时
- 优化智能体编排(agent orchestration)中的 Token 使用时
问题背景(The Problem)
生成的子智能体通常只带有有限的上下文。它们并不清楚:
- 哪些文件包含相关的代码
- 代码库中存在哪些模式(patterns)
- 项目使用了哪些术语
标准方法往往会失败:
- 全部发送:超出上下文限制。
- 什么都不发:智能体缺少关键信息。
- 猜测需求:经常猜错。
解决方案:迭代检索(The Solution: Iterative Retrieval)
一个由 4 个阶段组成的循环,用于逐步优化上下文:
阶段 1:派发(DISPATCH)
初始的广泛查询,用于收集候选文件:
阶段 2:评估(EVALUATE)
评估检索到的内容的相关性:
评分标准:
- 高 (0.8-1.0):直接实现了目标功能
- 中 (0.5-0.7):包含相关的模式或类型
- 低 (0.2-0.4):间接相关
- 无 (0-0.2):不相关,排除
阶段 3:优化(REFINE)
根据评估结果更新搜索条件:
阶段 4:循环(LOOP)
使用优化后的条件重复执行(最多 3 个周期):
实践案例
案例 1:Bug 修复上下文
案例 2:功能实现
与智能体(Agents)集成
在智能体提示词中使用:
最佳实践
- 由广入深,逐步缩小范围 —— 初始查询不要过于具体。
- 学习代码库术语 —— 第一个周期通常能揭示命名规范。
- 追踪缺失内容 —— 明确的缺口识别是驱动优化的关键。
- 见好就收 —— 3 个高度相关的文件优于 10 个平庸的文件。
- 果断排除 —— 低相关性的文件通常不会突然变得相关。
相关资源
- 长篇指南 (The Longform Guide) —— 子智能体编排部分
continuous-learning技能 —— 用于随时间改进的模式~/.claude/agents/中的智能体定义
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/iterative-retrieval/SKILL.md
Popularity
- Repository stars
- 290
- Repository forks
- 56
- 7-day trend score
- 28
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 31 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/xu-xiang/everything-claude-code-zh/iterative-retrieval)