/rag-rat:using-rag-ratfrom rag-rat
Establishes a workflow for repos indexed by rag-rat: use MCP tools (semantic_search, symbol_lookup, impact_surface) to find and understand code before grep/cat, and record durable learnings as memories.
Ships in rag-rat. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This repo is indexed by rag-rat, a local repo-intelligence index + MCP server. One MCP call
returns graph (callers/callees), git, GitHub papertrail, and drive-by repo memories
(source-anchored invariants, decisions, risks) — all validated against current source. A grep
can't surface any of that. Two rules follow.
Prefer these over grep/cat/file sweeps when browsing or understanding code:
semantic_search — "where is this concept implemented?" Current source chunks with inline
graph, git, and papertrail.symbol_lookup — exact/fuzzy symbol resolution (Rust/TS/Kotlin/C/C++/Python/Swift/Go), with
any bound memories attached.impact_surface — the coding preflight before editing any non-trivial symbol: callers,
callees, tests, git history, papertrail, and the repo memories crossing that call path. Run it
before you change something load-bearing — it's how you avoid missing an invariant.find_callers / trace_callees — reverse/forward graph traversal instead of grepping for
call sites.read_chunk — current text for a chunk with anchor validation + graph + memories.repo_brief / repo_clusters — orientation (spine, churn, god-modules, ownership clusters).important_symbols — load-bearing symbols by (SCIP-aware) PageRank; pass personalize to bias
toward what you're editing.That's the daily loop. The MCP exposes many more tools — reach past the core ones by the question
you're actually asking (full schemas: docs/mcp-tools.md):
| When you want to… | Reach for |
|---|---|
| Find where a concept/behavior lives | semantic_search |
| Resolve a symbol by name (exact/fuzzy) | symbol_lookup |
| See what calls X / what X calls | find_callers / trace_callees |
| Know the blast radius before editing | impact_surface (callers, callees, tests, history, memories — the preflight) |
| Read a chunk's exact current text | read_chunk |
| Orient in an unfamiliar repo | repo_brief (spine / churn / god_modules / refactor_candidates), repo_clusters |
| Find the load-bearing symbols | important_symbols |
| Check if code duplicates what's already here | find_clones (repo-wide), or find_clones with a symbol (id / ref, or path + line) for its clone class |
| Understand why code exists, or when/why it changed | history_for a symbol (symbol/ref/id), path, chunk_id or commit — commits, blame, and the tracker issues / reviews that reference it |
| Search history by keyword | history_search with source: commits, changes (commits + the files they touched), issues, rationale |
| Read docs / doc-comments for a symbol | docs_for_symbol |
| Recall prior notes | memory_search (keywords), memory_get (by memory_id, symbol, path, or call path) |
| Check index / embedding / tracker-cache health | index_status (include: ["embeddings"] for embedding coverage) |
Optional toolsets. Maintenance and diagnostics are off the default tool list; if you need one and
it is not among your tools, ask the user to add it to [mcp] toolsets in rag-rat.toml and reconnect:
| Toolset | Tools |
|---|---|
admin | dream → dream_review (see the dream-review skill), heal_index (repair drift), memory_doctor, memory_validate, compare_graph_to_scip / compare_graph_to_text (is the graph trustworthy here?), check_library_usage, ffi_surface, llm_status, papertrail_sync_status |
graph | memory_edges, memory_edge_add, memory_edge_remove (memory task-graph links) |
Reaching for the right tool is cheap and eager: prefer the specific one (history_for for why,
find_clones before writing a helper) over defaulting to semantic_search for everything.
Symbol handle: symbol-returning tools emit id, an opaque sym_<hex> token — the stable handle
to cache and pass back into graph/impact/memory tools as id (copy verbatim; never parse it as a
number). Use ref (the path::name qualified name) for human-readable identity.
Why this beats grep: results carry provenance (confidence, coverage warnings, raw evidence) so
you can judge them; a function may carry an Invariant/Decision/Risk memory that explains a
non-obvious constraint grep can't show; and the index is kept fresh by git hooks, so what the
MCP returns matches HEAD.
Use the MCP to find and understand; use your file tools to change (and to confirm exact text before an edit). The MCP is read-only on source — it never edits files.
If the MCP returns empty/thin results, the index is stale or mis-rooted: rag-rat index --discover
then rag-rat reconcile. (Optional but recommended: install the rag-rat plugin — it registers a
PreToolUse hook that auto-augments your grep/rg calls with symbol + memory context.)
The gate, before anything else: could the next agent recover this by reading the repo? If yes, don't record it. A memory that restates what the code, the types, the tests, or the history already say leaves the reader worse off, not merely no better — it costs attention and returns nothing. On most tasks the honest answer is record nothing; that is the common outcome, not a failure to try hard enough. What passes the gate is what you had to read several files and reason to learn, and that the repo states nowhere.
Rejected alternatives lead. The approach that was not taken leaves no artifact anywhere — not
in the diff, not in the types, not in the history — which makes it at once the most-asked question
about unfamiliar code and the least-supplied answer. If your task settled a choice, record the
alternative and why it lost (RejectedAlternative) before you record anything about what the code
now does.
Why rag-rat and not your harness's own notes: rag-rat memories live in the repo's shared index, so they surface for every agent that queries it — Claude Code, Codex, any future tool — not just the one that wrote them. Your harness's private memory is invisible to the others. rag-rat is the cross-agent memory layer.
Translate; never store the trajectory. What you did, in what order, is worth less than nothing to the next reader — a replayed trace scores worse than having no memory at all. Distill it to a situation and an action — when X, do Y, because Z — and quote the evidence you generalised from (the failing line, the error, the constraint). Situated questions are not answered by general advice, and the quote is what spares the reader from trusting a summary of a summary.
Revise before you create. A memory that has drifted actively misleads, while a missing one
merely fails to help — so correcting or retiring a wrong record is the highest-value write
available. memory_search first: if something already covers the ground, memory_update it; reach
for memory_create only when nothing does.
Terseness is a staleness strategy, not a style preference. Every extra detail is one more thing a later change can falsify, and a record that contradicts the source on one line gets distrusted on all of them. State the rule and the reason, then stop. Aim under 900 characters; most memories land at 300–600. Past that you are usually restating code the reader can go read.
Write the present tense, not a changelog. A memory is read by someone about to change the code,
so it must say what is true now and what to do about it. "This was fixed in #123", "the predicate
used to fail open", "stage 2 landed the split" are unactionable, and history goes stale the moment
the next change lands. The same applies when you update one: if the thing a memory warned about has
been fixed, rewrite the body to state the rule that now holds rather than appending a status section,
and retire it (memory_update with status: "obsolete") if nothing actionable survives.
Keep: invariants, the reasoning behind a decision, traps and their failure modes, what to reach for, what is still unresolved. Drop: PR/stage narration, "used to be", anything whose only value is that it happened. Referencing an issue or test name is fine when it is a pointer the reader can follow — it is the story that does not belong.
Do it well:
id binding (the sym_<hex> handle —
self-heals across cross-file moves); fall back to a path binding for file/area notes, or a
commit/GitHub ref for historical rationale.kind: Invariant (must stay true), Decision/RejectedAlternative (why
this / why not that), Risk/BugPattern (footguns), PerformanceNote, PlatformQuirk,
FFIBoundary. The body carries the why + how to apply — not just the what, and not what
changed.#407 E3a: …, C4.3b, V042 … (phase A5) are
titles nobody can act on: they name the work, so the reader must open the body to learn whether it
concerns them. Name the constraint or the trap instead, and leave an issue number as a trailing
pointer only when it earns its place. Max 160 characters.memory_doctor (admin toolset) flags gone anchors and
memory_update with bind re-anchors them.The memory layer is kept honest by dream — a maintenance worklist of load-bearing code with no
memory (coverage gaps) and memories that have drifted from the source. The dream-review skill is
the loop for triaging it.
The equivalents exist on the CLI too (rag-rat memory …) — use whichever your harness exposes.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
rag-rat, mcp, code-navigation, repo-intelligence, code-understanding
npx claudepluginhub cq27-dev/rag-rat --plugin rag-rat4 skills in this plugin
/configure-rag-rat-dreamUse to enable and operate rag-rat's optional AI memory-maintenance passes — the `dream --verify` / `--compact` model turns that verify repo memories (flag claims that no longer hold) and compact them (shorter summaries). Off by default. This configures `[llm.dream]` / `[llm.dream.remote]` (a chat model, over a Connect endpoint or an ephemeral Modal/RunPod cookbook box — vllm/ollama, never infinity), and sets up running it on demand or on a schedule (systemd timer). Pairs with the `dream-review` skill, which triages the findings these passes produce. Triggers: "configure dream", "enable dream", "AI memory verification", "memory compaction", "schedule dream maintenance", "set up the dream model".
/dream-reviewUse when asked to review, triage, or resolve rag-rat "dream" findings — the memory-maintenance worklist the `dream` tool produces. Walks the open findings and, per kind, either fixes the underlying memory / coverage gap (which resolves the finding at the root) or records an accept / dismiss verdict with `dream_review`. Triggers: "dream review", "resolve dream findings", "triage the dream worklist", "go through pending dream findings".
/init-rag-ratUse to set up rag-rat in a repository that is not indexed yet — when the rag-rat MCP server is DORMANT (its tools return {"status":"no_index"} with a "Run rag-rat init … then restart" remedy), or when the user asks to initialize / configure / "set up rag-rat" / "index this repo" / choose an embedding backend. Drives the setup conversationally: scans the repo, explains only the material choices, recommends the local FastEmbed default for a modest machine, and — only when a remote / GPU embedder is worth it — loads a reference for local infinity (Docker) or an ephemeral Modal/RunPod worker, then previews the config, writes it after confirmation, runs the first index, offers to set up the git maintenance hooks (asks before touching `.git/hooks`), and tells the user to restart the MCP server. Triggers: "set up rag-rat", "rag-rat is dormant", "no rag-rat.toml", "index this repo", "configure rag-rat embeddings".
Other plugins' skills for the same job