Skip to content
Skills Library
Programming · Research

context-retrieval-loop

/context-retrieval-loop

Use when starting work in an unfamiliar area of a codebase, spawning a subagent that needs targeted file context, a first search pass missed the relevant file, or the file scope of a task is unclear.

Licence
Apache-2.0
Last repository change
27.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.09.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Use when starting work in an unfamiliar area of a codebase, spawning a subagent that needs targeted file context, a first search pass missed the relevant file, or the file scope of a task is unclear.

Original author description

Use when starting work in an unfamiliar area of a codebase, spawning a subagent that needs targeted file context, a first search pass missed the relevant file, or the file scope of a task is unclear.

How it works

  1. When to Use
  2. The 3-Cycle Loop
  3. Stopping Conditions
  4. Output
  5. Integration with Subagents
  6. Constraints
  7. Verification
Original SKILL.md headings · 108 lines, 512 words
SKILL.md preview
---
name: context-retrieval-loop
description: Use when starting work in an unfamiliar area of a codebase, spawning a subagent that needs targeted file context, a first search pass missed the relevant file, or the file scope of a task is unclear.
---

# Context Retrieval Loop

Gather the right codebase context before making changes or spawning subagents. Prevents acting on incomplete information.

## When to Use

- Starting work on an unfamiliar area of a codebase
- Spawning a subagent that needs targeted file context
- Failing to find a relevant file on the first search pass
- Unsure which files are in scope for a task

## The 3-Cycle Loop

Each cycle builds on the previous. Stop early when you have enough context. Do not exceed 3 cycles.

### Cycle 1 — Broad Search

```bash
# Find files by keyword
rg "<primary-keyword>" --type ts --type js -l
rg "<primary-keyword>" --glob "*.py" -l

# Find by filename pattern
find . -name "*<keyword>*" -not -path "*/node_modules/*" -not -path "*/.git/*"
```

Collect: file paths, key terms, naming conventions seen.

**Stop here if:** 3 or more directly relevant files found with no critical gaps.

### Cycle 2 — Exact Source and Tests

Read the most relevant files from Cycle 1 in full. Then:

```bash
# Find tests for those files
rg "<filename-stem>" --glob "*.test.*" --glob "*.spec.*" -l
rg "import.*<module-name>" -l

# Find call sites
rg "<function-name>|<class-name>" --type ts --type js -l
```

Collect: imports used, function signatures, test patterns, adjacent files referenced.

**Stop here if:** You can describe the change needed and its blast radius.

### Cycle 3 — Docs and Setup

```bash
# Check project-specific docs
ls docs/ README.md AGENTS.md CLAUDE.md .claude/ 2>/dev/null

# Check config for feature flags, env vars, or schema
rg "<keyword>" .env.example *.config.* *.toml *.yaml -l 2>/dev/null
```

Collect: configuration constraints, environment requirements, anything that would block a change.

## Stopping Conditions

Stop the loop (whichever comes first):
- You have 3+ high-relevance files and understand the change scope
- Cycle 3 complete
- Each new cycle returns only files already seen

## Output

After the loop, report:

```
Context gathered:
  <file-path> — <one-line reason for relevance>
  ...

Missing context (if any):
  <what is still unclear and why it matters>
```

If context is missing, state it explicitly. Do not proceed with guesses when a known gap exists.

## Integration with Subagents

When dispatching a subagent, pass only the gathered file list — not the full conversation context:

```
Relevant files for this task:
  src/auth/tokens.ts — contains TokenService used by the bug
  src/auth/session.ts — session state management
  src/auth/tokens.test.ts — existing test patterns
```

## Constraints

- Max 3 cycles. Diminishing returns beyond that.
- Do not read files speculatively. Read only files flagged as relevant.
- Do not inline entire file contents into the subagent prompt; pass paths.
- Report gaps rather than silently proceeding with incomplete context.

## Verification

- [ ] The loop stopped at a stopping condition — never past 3 cycles
- [ ] Every gathered file is listed with a one-line relevance reason
- [ ] Missing context is stated explicitly — no proceeding on guesses when a gap is known
- [ ] Subagents received the file-path list, not inlined file contents
- [ ] No speculative reads — only files flagged as relevant were opened

Versions

RepositoryScoreLicence
This page · yeaight7/agent-powerups100Apache-2.0
yeaight7/agent-powerups100Apache-2.0
yeaight7/agent-powerups100Apache-2.0
yeaight7/agent-powerups100Apache-2.0

Identical content appears in 2 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version a3ee7d431345 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100explore-area
    Orient on a new codebase area using get_context for token-budgeted exploration. Use when the user asks "what does this module do", "explain this part", or wants to understand an unfamiliar area before making changes.
  • 100iterative-retrieval
    Pattern for progressively refining context retrieval to solve the subagent context problem. Use when spawning subagents that need codebase context they cannot predict upfront, or when building multi-agent workflows where context is progressively refined.
  • 100map
    Generate semantic codebase symbol map. Use when navigating unfamiliar code or before refactoring.
  • 100focus
    Use to narrow attention to a feature/file set/area for the current session. Different from /scope (which enforces via hook) — focus is advisory + helps memory + retrieval prioritise the area.
  • 100research-first
    Researches existing code, docs, and prior art before proposing designs or writing code. Use this skill when entering an unfamiliar area, choosing a library, or before design-exploration when facts are missing. Do not use when/for executing an already-researched implementation…
  • 100ds-plan-loop
    Write a numbered plan with an acceptance check for each step, critique it once in a fresh pass, revise it, then execute one step at a time. Use when a task touches more than one file, has unclear scope, or failed before because steps were missed. Invoke as /ds-plan-loop.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.