rag-ingest
Embed every file under targets/<name>/sources/ into a ChromaDB collection named target_<name> via the TLX rag module (Google text-embedding-004). Run after sourcemap-explode when status.json.rag.colle
SKILL.md.claude/skills/rag-ingest/SKILL.md
GitHubrag-ingest
Purpose
Build a per-target retrieval index over the exploded source tree so Claude (and Opus during audit) can fetch only the relevant code chunks instead of stuffing the entire app into context.
Inputs
targets/<name>/sources/**- env:
GOOGLE_API_KEYfor the embedder.
Steps
- Verify env. If missing, halt with
memory.md > Failure-mode reminderspointer to fix. - Resolve TLX rag module entry point. Since this folder vendors TLX
in
./tlx/, invoke via thetlxMCP. The MCP exposesdocs_querybut notdocs_ingestdirectly — we ingest by calling the underlying module function through a tiny helper atbin/rag_ingest.py target_<name> targets/<name>/sources/. - The helper does:
from kernel import Kernelawait kernel.boot(surface="mcp")then resolve the rag module'singest()function viakernel.services.get("rag")(falls back to legacy service namesdocs/docs_module).- Walk
sources/, batch-embed files (chunk size1000 tokens with ~100-token overlap), persist to `/.tlx/chroma/target_<name>`.
- Write count + model to
status.json.rag.
Outputs
~/.tlx/chroma/target_<name>collection.- updated
status.json.phases.rag.
Failure modes
PERMISSION_DENIEDon embedder → badGOOGLE_API_KEYor missing Generative Language API enablement on the GCP project.- Disk full at
~/.tlx/chroma/→ free space; rerun (idempotent). - File too large to embed → split into smaller chunks; if individual chunk exceeds embedder token limit, log skip.
Result block
"phases": { "rag": { "status": "done", "ts": "<iso>",
"collection": "target_<name>", "chunks": N, "model": "text-embedding-004" } }