Docs assistant¶
docs-rag answers questions about this stack, with citations. Claude Code reads a knowledge
base of every repository of the stack (this one and every service: documentation, OpenAPI
specs, Compose files and code), at the versions the release train pins.
- It is an assistant for students and a system under test for LLM-testing lessons.
- The decision is
ADR 11.
- The service is docs-rag-rs.
It runs only on your machine, as an opt-in overlay, and never in production. It needs no other service of the stack, no database and no port.
Your key¶
Put your own Anthropic API key in the git-ignored .env file in this directory:
- How it reaches the container: Docker Compose reads
.envand hands the key to the container as an environment variable. - Where it never goes: it is not in the image, not in
docker-compose.rag.yml, and not in any log. - Without a key:
asknames the missingANTHROPIC_API_KEY, and the keyless options below still work.
Ask¶
docs-rag is a one-shot container behind the docs-rag profile, so up never starts it. Run
it from this directory:
alias lsrag='docker compose -f lightweight-docker-compose.yml -f docker-compose.rag.yml run --rm docs-rag'
lsrag ask "How does a card refund reach the payment service?"
lsrag ask --json "..." # the documents consulted, tool calls, tokens, cost and a trace id
What happens inside¶
- Claude Code runs headless (
claude -p) in the knowledge base. Its only tools areRead,GrepandGlob. - It starts with
INDEX.md, a map of every document and its sections. Then it searches and reads what it needs, preferring the documentation over the code. - Every claim is cited as
[repo/path@version]or[repo/path#anchor@version]. A citation to a file it did not read, or at a wrong version, is removed. - Refusal: when no citation is left, the answer says that the documentation does not cover the question.
An answer costs about $0.05–0.15 and takes about 10 seconds. RAG_MAX_BUDGET_USD (default 1)
caps a single answer.
MCP¶
Register it with your own agent (Claude Code, Cursor). From this directory:
claude mcp add docs-rag -- docker compose -f lightweight-docker-compose.yml \
-f docker-compose.rag.yml run --rm -T docs-rag
Tools:
- ask: a complete, cited answer from the assistant. Needs your key.
- search_docs, read_document, list_sources: keyless access to the same knowledge base,
so your own agent can do the reasoning.
Keyless¶
Two things work without a key:
- The MCP tools search_docs, read_document and list_sources.
- The CLI:
lsrag sources # repositories and their versions
lsrag search feed_position # best matching files and lines (BM25), with citations
lsrag read awesome-localstack/docs/EVENT_FEED.md
RAG_MODE=mock lsrag ask "..." # the best matching lines instead of an answer
Configuration¶
Set these in .env or the shell:
| Variable | Default | Meaning |
|---|---|---|
ANTHROPIC_API_KEY |
none | Your own key |
RAG_MODE |
llm |
llm (Claude Code answers) or mock (no model) |
RAG_MODEL |
claude-sonnet-5-5 |
The answering model |
RAG_MAX_BUDGET_USD |
1 |
The most one answer may cost |
RAG_LOG |
warn |
Log level (logs go to stderr) |
Versions¶
What the image carries: - the knowledge base of the release train it was built for; - a pinned Claude Code release, checked against its SHA-256.
lsrag sources shows the version of each repository. A new release train needs a new docs-rag
image, or answers describe the old versions.
Local only. scripts/verify-rag-local-only.sh runs in CI and fails when either of these
happens:
- docs-rag appears in the server profile, Ansible or the gateway;
- the overlay publishes a port, loses its profile, or holds a key.