Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Iterative Retrieval

ASecurity

Progressive multi-pass context refinement for a context-starved subagent — a 4-phase DISPATCH-EVALUATE-REFINE-LOOP cycle, max 3 cycles, for when a subagent cannot predict upfront which files or context it needs. Narrower than skills/ai/ai-rag-patterns (general agentic RAG) and skills/ai/ai-agent-multi-agent-coordination (handoff contracts) — this skill is specifically the retrieval-refinement loop inside one subagent's own context-gathering pass.

26 stars
0 votes
0 copies
0 views
Added 9/20/2026
developmentgoapi

Works with

api

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add peterbamuhigire/chwezi-dev-engine --skill iterative-retrieval --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Iterative Retrieval?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Iterative Retrieval
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/peterbamuhigire-iterative-retrieval/badge)](https://www.skillsdirectory.com/skills/peterbamuhigire-iterative-retrieval)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: iterative-retrieval
description: Progressive multi-pass context refinement for a context-starved subagent — a 4-phase DISPATCH-EVALUATE-REFINE-LOOP cycle, max 3 cycles, for when a subagent cannot predict upfront which files or context it needs. Narrower than skills/ai/ai-rag-patterns (general agentic RAG) and skills/ai/ai-agent-multi-agent-coordination (handoff contracts) — this skill is specifically the retrieval-refinement loop inside one subagent's own context-gathering pass.
metadata:
  portable: true
  compatible_with:
  - claude-code
  - codex
  origin: "Adapted from affaan-m/ECC skills/iterative-retrieval/SKILL.md"
---

# Iterative Retrieval Pattern

Solves the "context problem" in multi-agent workflows: a subagent is spawned with limited context
and does not yet know which files are relevant, what patterns exist in the codebase, or what
terminology the project uses. This engine already covers agentic RAG broadly
(`skills/ai/ai-rag-patterns`) and multi-agent handoff contracts
(`skills/ai/ai-agent-multi-agent-coordination`); this skill is the specific missing piece —
progressive, bounded refinement of a single subagent's own retrieval pass before it starts real
work.

## When to Activate

- Spawning subagents that need codebase context they cannot predict upfront
- Building multi-agent workflows where context is progressively refined between passes
- Encountering "context too large" or "missing context" failures in agent tasks
- Optimizing token usage in agent orchestration where a naive first-pass search under- or over-retrieves

## The Problem

Standard approaches fail:
- **Send everything** — exceeds context limits, drowns the signal in noise
- **Send nothing** — the agent lacks critical information and guesses
- **Guess what's needed up front** — often wrong, especially once the codebase's own naming
  conventions diverge from the task's vocabulary

## The Solution: A 4-Phase Loop

```
DISPATCH → EVALUATE → REFINE → LOOP (max 3 cycles, then proceed with best-available context)
```

### Phase 1: DISPATCH

Initial broad query to gather candidate files, using an intentionally loose set of patterns and
keywords derived from the task description.

### Phase 2: EVALUATE

Score each retrieved file's relevance to the task:

| Band | Range | Meaning |
|---|---|---|
| High | 0.8–1.0 | Directly implements the 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 |

Alongside relevance, explicitly record **missing context**: what the task still needs that this
pass did not surface. This gap list is what drives refinement — do not skip it.

### Phase 3: REFINE

Update the search criteria from what Phase 2 learned:
- add new patterns discovered in high-relevance files
- add project-specific terminology found in the codebase (the first cycle often reveals that the
  codebase uses different vocabulary than the task description)
- exclude paths confirmed irrelevant (low-relevance files rarely become relevant on a later pass)
- target the recorded gaps specifically, rather than re-running a broader version of the same query

### Phase 4: LOOP

Repeat with refined criteria, capped at 3 cycles. Stop early once either:
- at least 3 high-relevance (≥0.7) files are found with no remaining critical gaps, or
- the cycle cap is reached — proceed with the best context gathered rather than looping indefinitely

3 high-relevance files beat 10 mediocre ones. Exclude confidently; a file scored low-relevance in
cycle 1 will very rarely score high in cycle 3 without new evidence.

## Worked Examples

**Bug fix context** — "Fix the authentication token expiry bug":
- Cycle 1: search "token", "auth", "expiry" → finds `auth.ts` (0.9), `tokens.ts` (0.8), `user.ts` (0.3, excluded)
- Cycle 2: add "refresh", "jwt" (learned from cycle 1's high-relevance files) → finds `session-manager.ts` (0.95), `jwt-utils.ts` (0.85) → sufficient, stop

**Feature implementation** — "Add rate limiting to API endpoints":
- Cycle 1: search "rate", "limit", "api" → no matches; the codebase uses "throttle" instead
- Cycle 2: add "throttle", "middleware" → finds `throttle.ts` (0.9), `middleware/index.ts` (0.7); gap noted: router wiring
- Cycle 3: search "router" patterns → finds `router-setup.ts` (0.8) → sufficient, stop

## Integration into an Agent Prompt

```markdown
When retrieving context for this task:
1. Start with a broad keyword search based on the task description.
2. Evaluate each candidate file's relevance (0-1 scale) and name what is still missing.
3. Refine search criteria from what was learned — new terminology, excluded paths, targeted gaps.
4. Repeat, capped at 3 cycles.
5. Proceed with files scoring ≥0.7, or the best available set if the cap is reached.
```

## Best Practices

1. **Start broad, narrow progressively** — do not over-specify the initial query
2. **Learn the codebase's own terminology** — the first cycle often reveals naming conventions that differ from the task's phrasing
3. **Track what's missing explicitly** — gap identification, not vague dissatisfaction, is what drives refinement
4. **Stop at "good enough"** — a small set of high-relevance files beats a large set of mediocre ones
5. **Exclude confidently** — low-relevance files won't become relevant on a later pass without new evidence

## Related

- `skills/ai/ai-rag-patterns` — general agentic RAG: query rewriting, re-ranking, production retrieval pipelines. Use this skill instead when the "corpus" is code being explored for a single subagent's task, not a document/knowledge-base retrieval system.
- `skills/ai/ai-agent-multi-agent-coordination` — the handoff contract between agents; this skill is what happens inside one agent's own context-gathering pass before or during that handoff.
- `sdlc-meta/santa-method` — for verifying the *output* produced once the subagent has enough context; this skill is about the input side.

Attribution

peterbamuhigirepeterbamuhigire
View sourceMore from peterbamuhigire →
SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

281612 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2132 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →