skills/iterative-retrieval/SKILL.md
Pattern for progressively refining context retrieval to solve the subagent context problem
npx skillsauth add nhouseholder/nicks-claude-code-superpowers iterative-retrievalInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Solves the "context problem" in multi-agent workflows where subagents don't know what context they need until they start working.
Subagents are spawned with limited context. Standard approaches fail:
const initialQuery = {
patterns: ['src/**/*.ts', 'lib/**/*.ts'],
keywords: ['authentication', 'user', 'session'],
excludes: ['*.test.ts', '*.spec.ts']
};
const candidates = await retrieveFiles(initialQuery);
Score each file 0-1:
Identify what context is still missing.
function refineQuery(evaluation, previousQuery) {
return {
patterns: [...previousQuery.patterns, ...extractPatterns(evaluation)],
keywords: [...previousQuery.keywords, ...extractKeywords(evaluation)],
excludes: [...previousQuery.excludes, ...lowRelevancePaths(evaluation)],
focusAreas: evaluation.flatMap(e => e.missingContext).filter(unique)
};
}
Exit when: 3+ high-relevance files AND no critical gaps. Otherwise refine and repeat (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);
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: "Fix the authentication token expiry bug"
Cycle 1:
DISPATCH: Search "token", "auth", "expiry" in src/**
EVALUATE: auth.ts (0.9), tokens.ts (0.8), user.ts (0.3)
REFINE: Add "refresh", "jwt"; exclude user.ts
Cycle 2:
DISPATCH: Search refined terms
EVALUATE: session-manager.ts (0.95), jwt-utils.ts (0.85)
EXIT: Sufficient context
Result: auth.ts, tokens.ts, session-manager.ts, jwt-utils.ts
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 and repeat (max 3 cycles)
5. Return files with relevance >= 0.7
tools
Unified context management and session continuity skill. Combines total-recall, strategic-compact, /ledger, and session continuity. Runs in background to preserve critical context across compaction and sessions.
tools
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
tools
Suggest /ultraplan for complex planning tasks on Claude Code CLI (2.1.91+ only). Research preview.
tools
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.