iterative-retrieval

Retrieve and refine codebase context through iterative search cycles.

1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/xxih/ai-harness-zh --skill iterative-retrieval-xxih
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: iterative-retrieval
Source: https://github.com/xxih/ai-harness-zh/tree/main/references/translations/everything-claude-code/docs/zh-CN/skills/iterative-retrieval
Command: npx skills add https://github.com/xxih/ai-harness-zh --skill iterative-retrieval-xxih

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Sub‑agents often start tasks without the necessary code context, leading to failures or inefficient token usage. This skill addresses the shortage of relevant files, patterns, and terminology that a sub‑agent needs to execute effectively.

Core Features & Use Cases

  • Iterative Retrieval Loop: Schedules a broad search, evaluates relevance, refines queries, and repeats up to three cycles to collect high‑relevance code files.
  • Dynamic Query Refinement: Automatically expands patterns and keywords while excluding low‑relevance paths based on scoring.
  • Context Optimization: Stops when sufficient high‑relevance files are found, minimizing token consumption for tasks such as bug fixing, feature addition, or rate‑limit implementation.

Quick Start

Ask the agent to retrieve relevant code context for the task “fix authentication token expiry” using the iterative‑retrieval skill.

Frequently Asked Questions about iterative-retrieval

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I retrieve relevant code context for sub-agents before starting a bug fix?

Code context retrieval minimizes token consumption by stopping the search process once sufficient high-relevance files are found. It uses relevance scoring and exclusion handling to prevent loading low-relevance paths into the sub-agent context window.

How do I refine code search queries to find relevant files in a large codebase?

Query refinement for iterative code retrieval requires no external dependencies. It operates directly on code repositories, using internal relevance scoring and pattern detection to progressively narrow down the necessary file context.

What is the best way to optimize token usage when providing codebase context to sub-agents?

Optimize token usage by implementing iterative retrieval that stops when sufficient high-relevance files are found. This prevents over-fetching by scoring file relevance and excluding low-value paths during the search and refinement cycles.

Why does my sub-agent fail to implement features due to missing code context?

Using iterative retrieval for context gathering has the limitation of running a maximum of three search cycles. If the codebase is massive and highly fragmented, three iterations may not collect sufficient context, leaving the sub-agent without complete pattern coverage.