iterative-retrieval
Skill2 starsChanged 4 months agoMITView on GitHub
Pattern for progressively refining context retrieval to solve the subagent context problem
28 other projects use a version of this, 20 of them edited.
Adopted by
Most recently taken up by
- templetongroup/radiantedited, first seen Sep 17, 2026
- jamesdebatty/skillstheir own version, first seen Sep 8, 2026
- microsoft/fsi-banking-payments-dispute-resolution-acceleratortheir own version, first seen Aug 14, 2026
- jcarlosrodicio/pi-agent-orchestration-kitedited, first seen Aug 13, 2026
- SamuelNDCE/claude-super-skill-libraryedited, first seen Aug 1, 2026
- thanvish21/hcc-bundletheir own version, first seen Jul 25, 2026
Used with
Projects with it also use content-hash-cache-pattern, swift-protocol-di-testing and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
InfopibeSkillcontent-hash-cache-pattern
Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.
Also in 9 projects that use this
InfopibeSkillswift-protocol-di-testing
Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.
Also in 8 projects that use this
- +2 more from Infopibe
Other versions28 projects use a version of this.
Word for word · 0
None found.
Edited · 20
- xu-xiang/everything-claude-code-zh★ 2k27% same
- loulanyue/awesome-claude-notes★ 27299% same
- tpavanipradeep/everything-claude-code★ 13499% same
- templetongroup/radiant★ 11397% same
- Jamkris/everything-gemini-code★ 8798% same
- codelably/harmony-claude-code★ 4329% same
- myths-labs/muse★ 3583% same
- joneqian/claude-skills-suite★ 3298% same
- FaisalAlqarni/sp-ecc★ 998% same
- Infopibe/everything-claude-code★ 899% same
10 more not listed
Wrote their own version · 8
- github/gh-aw★ 5.3ksame name
- microsoft/Generative-AI-for-beginners-dotnet★ 3.1ksame name
- Azure/fleet★ 226same name
- noah-sheldon/ai-dev-kit★ 13same name
- peopleforrester/claude-dotfiles★ 3same name
- jamesdebatty/skills★ 0same name
- microsoft/fsi-banking-payments-dispute-resolution-accelerator★ 0same name
- thanvish21/hcc-bundle★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository169 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-guidanceSkill
- accessibilitySkill
- adaptive-languageSkill
- agent-sortSkill
- agent-workflow-opsSkill
- android-clean-architectureSkill
- api-designSkill
- architecture-decision-recordsSkill
- automation-audit-opsSkill
- backend-patternsSkill
- blender-motion-state-inspectionSkill
- blueprintSkill
- browser-qaSkill
- bun-runtimeSkill
- canary-watchSkill
- carrier-relationship-managementSkill
- ci-cd-and-automationSkill
- cisco-ios-patternsSkill
- claude-devfleetSkill
- codebase-onboardingSkill
- codehealth-mcpSkill
- code-review-and-qualitySkill
- code-simplificationSkill
- codex-vscodeSkill
- coding-standardsSkill
- compose-multiplatform-patternsSkill
- configure-eccSkill
- connections-optimizerSkill
- context-budgetSkill
- continuous-learning-v2Skill
- cost-aware-llm-pipelineSkill
- cost-trackingSkill
- councilSkill
- cpp-coding-standardsSkill
- cpp-testingSkill
- customer-billing-opsSkill
- customs-trade-complianceSkill
- database-migrationsSkill
- data-scraper-agentSkill
- debugging-and-error-recoverySkill
- deep-researchSkill
- deployment-patternsSkill
- deprecation-and-migrationSkill
- design-systemSkill
- django-celerySkill
- django-patternsSkill
- django-securitySkill
- django-tddSkill
- django-verificationSkill
- dmux-workflowsSkill
- docker-patternsSkill
- documentation-lookupSkill
- doubt-driven-developmentSkill
- e2e-testingSkill
- energy-procurementSkill
- error-handlingSkill
- eval-harnessSkill
- fastapi-patternsSkill
- finance-billing-opsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 4 are common, 0 are distinctive, and 0 are very specific to this project.
4
Common
Most of the 25 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 87
None (0-0.2): Not relevant, exclude
- Common: line 91
Update search criteria based on evaluation:
- Common: line 189
Use in agent prompts:
- Common: line 202
Start broad, narrow progressively: - Don't over-specify initial queries
“Common” is measured: kept by at least 6 in 10 of the 25 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Iterative Retrieval Pattern
Solves the "context problem" in multi-agent workflows where subagents don't know what context they need until they start working.
When to Activate
- Spawning subagents that need codebase context they cannot predict upfront
- Building multi-agent workflows where context is progressively refined
- Encountering "context too large" or "missing context" failures in agent tasks
- Designing RAG-like retrieval pipelines for code exploration
- Optimizing token usage in agent orchestration
The Problem
Subagents are spawned with limited context. They don't know:
- Which files contain relevant code
- What patterns exist in the codebase
- What terminology the project uses
Standard approaches fail:
- Send everything: Exceeds context limits
- Send nothing: Agent lacks critical information
- Guess what's needed: Often wrong
The Solution: Iterative Retrieval
A 4-phase loop that progressively refines context:
┌─────────────────────────────────────────────┐
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ DISPATCH │─────│ EVALUATE │ │
│ └──────────┘ └──────────┘ │
│ ▲ │ │
│ │ ▼ │
│ ┌──────────┐ ┌──────────┐ │
│ │ LOOP │─────│ REFINE │ │
│ └──────────┘ └──────────┘ │
│ │
│ Max 3 cycles, then proceed │
└─────────────────────────────────────────────┘Phase 1: DISPATCH
Initial broad query to gather candidate files:
// Start with high-level intent
const initialQuery = {
patterns: ['src/**/*.ts', 'lib/**/*.ts'],
keywords: ['authentication', 'user', 'session'],
excludes: ['*.test.ts', '*.spec.ts']
};
// Dispatch to retrieval agent
const candidates = await retrieveFiles(initialQuery);Phase 2: EVALUATE
Assess retrieved content for relevance:
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)
}));
}Scoring criteria:
- High (0.8-1.0): Directly implements target functionality
- Medium (0.5-0.7): Contains related patterns or types
- Low (0.2-0.4): Tangentially related
- None (0-0.2): Not relevant, exclude
Phase 3: REFINE
Update search criteria based on evaluation:
function refineQuery(evaluation, previousQuery) {
return {
// Add new patterns discovered in high-relevance files
patterns: [...previousQuery.patterns, ...extractPatterns(evaluation)],
// Add terminology found in codebase
keywords: [...previousQuery.keywords, ...extractKeywords(evaluation)],
// Exclude confirmed irrelevant paths
excludes: [...previousQuery.excludes, ...evaluation
.filter(e => e.relevance < 0.2)
.map(e => e.path)
],
// Target specific gaps
focusAreas: evaluation
.flatMap(e => e.missingContext)
.filter(unique)
};
}Phase 4: LOOP
Repeat with refined criteria (max 3 cycles):
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);
// Check if we have sufficient context
const highRelevance = evaluation.filter(e => e.relevance >= 0.7);
if (highRelevance.length >= 3 && !hasCriticalGaps(evaluation)) {
return highRelevance;
}
// Refine and continue
query = refineQuery(evaluation, query);
bestContext = mergeContext(bestContext, highRelevance);
}
return bestContext;
}Practical Examples
Example 1: Bug Fix Context
Task: "Fix the authentication token expiry bug"
Cycle 1:
DISPATCH: Search for "token", "auth", "expiry" in src/**
EVALUATE: Found auth.ts (0.9), tokens.ts (0.8), user.ts (0.3)
REFINE: Add "refresh", "jwt" keywords; exclude user.ts
Cycle 2:
DISPATCH: Search refined terms
EVALUATE: Found session-manager.ts (0.95), jwt-utils.ts (0.85)
REFINE: Sufficient context (2 high-relevance files)
Result: auth.ts, tokens.ts, session-manager.ts, jwt-utils.tsExample 2: Feature Implementation
Task: "Add rate limiting to API endpoints"
Cycle 1:
DISPATCH: Search "rate", "limit", "api" in routes/**
EVALUATE: No matches - codebase uses "throttle" terminology
REFINE: Add "throttle", "middleware" keywords
Cycle 2:
DISPATCH: Search refined terms
EVALUATE: Found throttle.ts (0.9), middleware/index.ts (0.7)
REFINE: Need router patterns
Cycle 3:
DISPATCH: Search "router", "express" patterns
EVALUATE: Found router-setup.ts (0.8)
REFINE: Sufficient context
Result: throttle.ts, middleware/index.ts, router-setup.tsIntegration with Agents
Use in agent prompts:
When retrieving context for this task:
1. Start with broad keyword search
2. Evaluate each file's relevance (0-1 scale)
3. Identify what context is still missing
4. Refine search criteria and repeat (max 3 cycles)
5. Return files with relevance >= 0.7Best Practices
- Start broad, narrow progressively - Don't over-specify initial queries
- Learn codebase terminology - First cycle often reveals naming conventions
- Track what's missing - Explicit gap identification drives refinement
- Stop at "good enough" - 3 high-relevance files beats 10 mediocre ones
- Exclude confidently - Low-relevance files won't become relevant
Related
- The Longform Guide - Subagent orchestration section
continuous-learningskill - For patterns that improve over time- Agent definitions bundled with ECC (manual install path:
agents/)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

