c-04-retrieval-strategy-router
Skill27 starsChanged 6 months agoMITView on GitHub
Choose retrieval strategies across memory substrates: semantics for known concepts with unknown structure, relationships for known anchors with unknown connections, and intent for hidden contracts and code truths.
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github-vscode/copilot-instructions.mdCopilot instructions
- .cursor/rules/agents-remember.mdcCursor rule
- docs/llms.txtllms.txt
- c-00-initialize-memory-repoSkill
- c-01-findings-captureSkill
- c-02-memory-quality-controlSkill
- c-03-repo-bootstrapSkill
- c-04-retrieval-strategy-routerSkill
- c-05-create-or-update-onboarding-filesSkill
- c-08-ar-coordination-context-resolverSkill
- c-09-git-worktree-managerSkill
- c-10-adopt-memory-baselineSkill
- c-11-memory-carryover-from-branchSkill
- c-12-closeoutSkill
- c-13-install-and-onboardSkill
- l-01-agent-lifecyclesSkill
- w-02-light-task-workflowSkill
- c-00-initialize-memory-repoSkill
- c-01-findings-captureSkill
- c-02-memory-quality-controlSkill
- c-03-repo-bootstrapSkill
- c-04-retrieval-strategy-routerSkill
- c-05-create-or-update-onboarding-filesSkill
- c-08-ar-coordination-context-resolverSkill
- c-09-git-worktree-managerSkill
- c-10-adopt-memory-baselineSkill
- c-11-memory-carryover-from-branchSkill
- c-12-closeoutSkill
- c-13-install-and-onboardSkill
- l-01-agent-lifecyclesSkill
- w-02-light-task-workflowSkill
- c-00-initialize-memory-repoSkill
- c-01-findings-captureSkill
- c-02-memory-quality-controlSkill
- c-03-repo-bootstrapSkill
- c-04-retrieval-strategy-routerSkill
- c-05-create-or-update-onboarding-filesSkill
- c-08-ar-coordination-context-resolverSkill
- c-09-git-worktree-managerSkill
- c-10-adopt-memory-baselineSkill
- c-11-memory-carryover-from-branchSkill
- c-12-closeoutSkill
- c-13-install-and-onboardSkill
- l-01-agent-lifecyclesSkill
- w-02-light-task-workflowSkill
- c-00-initialize-memory-repoSkill
- c-01-findings-captureSkill
- c-02-memory-quality-controlSkill
- c-03-repo-bootstrapSkill
- c-05-create-or-update-onboarding-filesSkill
- c-08-ar-coordination-context-resolverSkill
- c-09-git-worktree-managerSkill
- c-10-adopt-memory-baselineSkill
- c-11-memory-carryover-from-branchSkill
- c-12-closeoutSkill
- c-13-install-and-onboardSkill
- l-01-agent-lifecyclesSkill
- w-02-light-task-workflowSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 8 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when repository work needs context before source decisions.
- Very specific: line 34
Use Semantics when the request is vague or fuzzy.
- Distinctive: line 57
Use this when the route is unknown and the next step is choosing which overview, sidecar, or source area to confirm.
- Very specific: line 77
Use --project after the relevant memory root is known.
- Very specific: line 84
Use CGC (CodeGraphContext) when an anchor/symbol is known to find relationships and structure.
- Very specific: line 107
Use analyze callers for the reverse direction and analyze chain when two symbols are known and the missing question is whether one can …
- Very specific: line 120
Use analyze complexity as an early risk map before touching large or tangled functions.
- Distinctive: line 127
Use CGC first for structure and relationships.
- Distinctive: line 128
Use direct source reads only to confirm specific anchors CGC surfaced.
- Distinctive: line 137
Use Intent when the route, file, or anchor is known and their relationships (CGC) are understood.
- Distinctive: line 141
Read only what is needed to prove the packet:
- Very specific: line 143
Read <onboarding_root>/overview.index.json when the route is unknown.
- Very specific: line 145
Read <onboarding_root>/overview.md only when the root index is insufficient.
- Very specific: line 146
Read selected route overview.index.json first.
- Very specific: line 148
Read selected route overview.md only when hotPath/index is insufficient.
- Distinctive: line 153
If one named source question remains, run one capped source-anchor search over candidate files.
- Distinctive: line 156
Stop confirmation as soon as source proves the subsystem boundary, immediate cause, user-facing consequence, and next fix direction.
- Very specific: line 168
Keep a running count of your read_ar_files calls and list them as research evidence, alongside Semantics (GrepAI) and Relationship (CGC) …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
c-04-retrieval-strategy-router Retrieval Strategy Router
Use this skill when repository work needs context before source decisions. The job is to choose the retrieval contract first, then the cheapest substrate that can satisfy it. Providers are fast discovery accelerators.
Retrieval Substrates
Choose the next substrate by the missing context bundle:
Semantics: a fuzzy concept or request is known, but structure, route, or file location is unknown. Prefer GrepAI over the memory repos when available.Relationship: an anchor is known, but callers, callees, dependencies, ownership, inheritance, impact paths, or neighboring code are unknown. Prefer CodeGraphContext over the configured code repo when available.Intent: an anchor/location + relationships are known, but hidden contracts, invariants, branch-valid truths, behavioral expectations, or code intent are unknown. Use onboarding plus bounded source confirmation. Prefer theread_ar_filesMCP tool for the paired onboarding + source read (mirrors how Semantics prefers GrepAI and Relationship prefers CodeGraphContext).
Substrates can be chained. A triage prompt may start with Relationship to find the neighborhood around a ticket anchor, then switch to Intent to prove the contract and fix direction from source. A vague concept may start with Semantics, then switch to Intent once candidate routes are known.
Semantics: GrepAI
Use Semantics when the request is vague or fuzzy. Semantics will retrieve from onboardings which allows to discover the symbols/routes/files hints to relevant source code.
First request an MCP context_packet(repo_id="<repoId>", include_providers=true)
when the MCP server is configured. Use provider results only when the packet
reports healthy provider state and the MCP exposes an appropriate provider
query tool. Coordinator-local provider lifecycle scripts are not installed
runtime tools.
The two highest-value GrepAI patterns are broad semantic routing and scoped memory-project search. Examples here are synthetic response shapes only; do not copy private repository names, symbols, paths, snippets, or results into reusable skill examples.
Synthetic answer shape:
results[3]{project,path,lines,score}:
1 | <memoryProject> | onboarding/src/jobs/retry-policy.ts.md | 18-34 | 0.84
2 | <memoryProject> | onboarding/src/http/client.ts.md | 41-59 | 0.78
3 | <memoryProject> | onboarding/overview.md | 72-81 | 0.73Use this when the route is unknown and the next step is choosing which overview, sidecar, or source area to confirm.
Synthetic answer shape:
{
"query": "validation rules for imported records",
"results": [
{
"project": "<memoryProject>",
"path": "onboarding/src/import/record-validator.ts.md",
"startLine": 22,
"endLine": 46,
"score": 0.86
}
]
}Use --project after the relevant memory root is known. Use --path after
route discovery narrows the search further. For the full GrepAI usage catalog
with synthetic example outputs, read
grepai-high-leverage-usage.md beside this skill.
Relationship: CodeGraphContext
Use CGC (CodeGraphContext) when an anchor/symbol is known to find relationships and structure. One CGC query
can replace multiple direct rg reads. CGC is a powerful substrate for relationship questions:
callers, callees, dependencies, ownership, inheritance, impact paths, or neighboring code.
First request an MCP context_packet(repo_id="<repoId>", include_providers=true)
when the MCP server is configured. Use CGC only when the packet reports healthy
CGC state and the MCP exposes an appropriate relationship query tool.
The two highest-value CGC patterns are impact tracing and complexity triage. Examples here are synthetic response shapes only; do not copy private repository names, symbols, or paths into reusable skill examples.
Synthetic answer shape:
Function 'handleRequest' calls:
validateRequest <repo>/src/http/validation.ts:42
loadSession <repo>/src/auth/session.ts:18
dispatchCommand <repo>/src/app/command-router.ts:77
Total: 3 function(s)Use analyze callers for the reverse direction and analyze chain when two
symbols are known and the missing question is whether one can reach the other.
Synthetic answer shape:
Most Complex Functions (threshold: 10):
Function Complexity Location
renderDashboard 42 <repo>/src/ui/dashboard.tsx:88
buildReport 37 <repo>/src/reports/report-builder.ts:114
syncExternalState 31 <repo>/src/sync/state-sync.ts:57Use analyze complexity as an early risk map before touching large or tangled
functions. Use deps with the module import string recorded in code, not
necessarily the source file path. For the full CGC method catalog with
synthetic example outputs, read
codegraphcontext-high-level-methods.md beside this skill.
Rules:
Use CGC first for structure and relationships. Use direct source reads only to confirm specific anchors CGC surfaced.
Intent: Onboarding And Source
The read_ar_files MCP tool performs this entire paired-read recipe in one batch call: each
source path is returned with its deterministic sidecar, plus the repository overview and the
governing route-overview chain auto-attached.
Use Intent when the route, file, or anchor is known and their relationships (CGC) are understood. The missing context is the code's contract, invariant, behavioral expectation, branch-valid truth, or fix direction.
Read only what is needed to prove the packet:
- Read
<onboarding_root>/overview.index.jsonwhen the route is unknown; use roothotPath,childRoutes, and routing terms to pick likely routes. - Read
<onboarding_root>/overview.mdonly when the root index is insufficient. - Read selected route
overview.index.jsonfirst; usehotPathsummary, candidate hints, and anchor hints as the cheap route packet. - Read selected route
overview.mdonly whenhotPath/index is insufficient. - For
present-by-index, read the source with its deterministic sidecar. - For
absent-by-index, do not probe the sidecar; read source first. - Without a route index, probe only the deterministic sidecar for the candidate source being confirmed.
- If one named source question remains, run one capped source-anchor search over candidate files; use the selected route only after filename narrowing.
Stop confirmation as soon as source proves the subsystem boundary, immediate cause, user-facing consequence, and next fix direction. After that, do not read more overviews, sidecars, provider results, or broad searches unless the packet names an unresolved source question.
Rules:
- During the research phase (the lifecycle up to the build decision), read managed-repo
source with
read_ar_files, not the native read tool — one call returns each file paired with its onboarding plus the repository and governing route overviews (the recipe above, batched and observable). - Native read is reserved as the edit precondition once building begins.
- Keep a running count of your
read_ar_filescalls and list them as research evidence, alongside Semantics (GrepAI) and Relationship (CGC) queries.
Route Index Semantics
overview.index.json is generated metadata: sourceScope governs the route;
childRoutes narrows; coveredFiles lists sidecars; hotPath gives cheap
summary/anchors; fallback.governingOverview names absent-sidecar fallback.
For a source path inside sourceScope but absent from coveredFiles, infer
that no generated file-level sidecar exists for that route. This only skips the
sidecar probe; it never forbids reading source.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

