Loading...
Loading...
Progressive context refinement pattern for subagents. Solves the problem of agents not knowing what context they need until they start working. Uses a 4-phase loop: DISPATCH, EVALUATE, REFINE, LOOP.
npx skill4agent add peopleforrester/claude-dotfiles iterative-retrievalSearch for files related to: [topic]
Keywords: [initial keywords]
File patterns: [likely patterns]
Return: File paths with relevance scores| File | Relevance | Reason |
|------|-----------|--------|
| src/auth/login.ts | 0.9 | Core auth logic |
| src/utils/hash.ts | 0.7 | Used by auth |
| src/config.ts | 0.3 | Has auth config section |
| src/routes.ts | 0.2 | Only references auth path |Updated keywords: [refined keywords from codebase terminology]
New file patterns: [patterns discovered during evaluation]
Specific files to read: [high-relevance files]
Gaps to fill: [what's still missing]async function iterativeRetrieve(topic: string, maxIterations = 3) {
let keywords = extractKeywords(topic);
let context: FileContext[] = [];
for (let i = 0; i < maxIterations; i++) {
// DISPATCH
const candidates = await searchCodebase(keywords);
// EVALUATE
const scored = await scoreRelevance(candidates, topic);
context = mergeContext(context, scored.filter(s => s.relevance >= 0.5));
// Check stopping criteria
const highRelevance = context.filter(c => c.relevance >= 0.7);
if (highRelevance.length >= 3) break;
// REFINE
keywords = refineKeywords(keywords, scored);
}
return context;
}