Agent skill · data analytics · affaan-m

iterative-retrieval

Pattern for progressively refining context retrieval to solve the subagent context problem. Use when a subagent lacks the context it needs and retrieval must be refined across passes.

Why this skill is useful

Provides a structured 4-phase pattern for refining context retrieval in multi-agent workflows, which the AI wouldn't reliably generate on its own.

What it needs

About 3k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

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: Phase 1: DISPATCH Initial broad query to gather candidate files: Phase 2: EVALUATE Assess retrieved content for relevance: 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: Phase 4: LOOP Repeat with refined criteria (max 3 cycles): Practical Examples Example 1: Bug Fix Context Example 2: Feature Implementation Integration with Agents Use in agent prompts: Best Practices 1. Start broad, narrow progressively - Don't over-specify initial queries 2. Learn codebase terminology - First cycle often reveals naming conventions 3. Track what's missing - Explicit gap identification drives refinement 4. Stop at "good enough" - 3 high-relevance files beats 10 mediocre ones 5. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/iterative-retrieval--15a04e

View the source on GitHub

Browse the @skills marketplace