Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/mrdoe/opencoderag/agents-mdgit clone --depth 1 https://github.com/MrDoe/OpenCodeRAGWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.02603 | $0.02603 |
| Opus 5 | $0.01301 | $0.01301 |
| Sonnet 5 | $0.00521 | $0.00521 |
| Haiku 4.5 | $0.00260 | $0.00260 |
Grade A, and why
opencode-rag scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Code Navigation
ALWAYS use OpenCodeRAG tools before reading or editing:
- Search first —
search_semantic(query)instead of grep/glob. Optional args:pathHints,languageHints,fileExtensions(e.g.[".ts"]),topK - Skeleton before read —
get_file_skeleton(filePath)then read specific lines - Usages before edit —
find_usages(symbolName)before modifying any symbol - Images via describe —
describe_image(filePath, systemPrompt?)— never read raw bytes
If no results, run opencode-rag index.
Architecture
Entry points: src/index.ts (library), src/plugin-entry.ts (OpenCode plugin), src/cli.ts (CLI), src/tui.ts (TUI), src/web/server.ts (Web UI).
Core modules: src/core/ (config, interfaces, manifest), src/chunker/ (AST chunking), src/embedder/ (Ollama/OpenAI/Cohere), src/describer/ (LLM descriptions), src/retriever/ (vector + keyword hybrid), src/vectorstore/ (LanceDB), src/opencode/ (plugin integration).
Full architecture: doc/architecture.md.
Known Gotchas
- npm install: use
--legacy-peer-deps(LanceDB peer dep conflicts) - LanceDB types: cast through
unknown—rows as unknown as Record<string, unknown>[] - LanceDB index metric: the IVF index on
embeddingmust usedistanceType: "cosine"to matchsearchInternal(default isl2, which makes every query log "Requested metric Cosine is incompatible" and fall back to brute-force).LanceDbStore.ensureCosineIndex()self-heals stale L2 indexes on first search. When replacing an index, use a singlecreateIndex(..., replace: true, waitTimeoutSeconds)— adropIndex+createIndexsequence races and fails with "Retryable commit conflict". - LanceDB "partition N is empty, skipping" warnings: benign once per index build (IVF KMeans on duplicate/degenerate vectors). Constant spam = retrain churn from a store whose index commits never register (one new
_indices/<uuid>dir per attempt).repairIndexMetricOnceguards: counts only index-version dirs WITH files (empty husks from version pruning never trip it), verifies post-createIndex registration viaindexStats, gives up after 3 failed attempts per process;optimize()sweeps empty husk dirs, and rebuilds passoptimize({ skipIndex: true })to temp-store mid-run optimizes so the index is built once at the end. Fix for a truly non-converging store: delete rag_db + reindex. Note: u64-near_versions/*.manifestnames are NORMAL (counter starts at u64::MAX-1 and decrements) — not corruption. - tree-sitter: WASM-only (no native).
Parseris a class,Languageis top-level, useNodenotSyntaxNode - Plugin types:
@opencode-ai/pluginlives in.opencode/node_modules/, declared locally insrc/types/opencode-plugin.d.ts - Config loading:
loadConfig()deep-merges per section (not recursive). CLI auto-detects./opencode-rag.jsonand./.opencode/rag.json - Ollama responses: may return
{ embedding: number[] }or{ embeddings: number[][] }— both accepted - Quirk test:
opencode-rag quirk test <text>checks if a quirk already exists in the store (semantic search). Returns match details or "not appended" - Auto-capture quirks: three
memory.*flags —passiveCapture(per-turn extraction),promptEnforcement(mandatory system prompt),sessionEndExtraction(full-transcript on session end). All off by default. Requiresdescription.enabled: true(reuses description LLM for extraction). - Auto-capture dedup: candidate quirks are deduped against existing quirks via lexical similarity (
autoCaptureDedupThreshold, default 0.85) before being added. - excludeDirs/excludeFiles matching (
src/core/exclude.ts): plain names (no/, no glob chars) match basename at any depth; patterns with a separator are anchored to workspace root. Matching is case-insensitive. Usesminimatch(bundled TS types).walkFilesno longer auto-skips dotdirs — rely onexcludeDirsconfig instead. noUncheckedIndexedAccessintsconfig.json: array indexing returnsstring | undefined. Usefor...ofloops instead of indexedforin new code to avoidObject is possibly 'undefined'errors.- watch.ts ignores both excludeDirs AND excludeFiles:
createWatchIgnoreuses both matchers — any excludeFiles pattern applies to file-watch ignore too. walkFilessignature changed:excludeDirs/excludeFilesparams changed fromSet<string>toExcludeMatcher;rootDirparam added. If you importwalkFilesdirectly, update the call site or usescanWorkspaceFilesinstead.- Watcher runs once per workspace:
createBackgroundIndexerclaims{storePath}/watcher.lock(atomic O_EXCL create + PID liveness viaprocess.kill(pid, 0)). Only ONE process runs the auto-index watcher per workspace; later claimants go dormant (no chokidar/scheduler/passes) and take over via a 60s unref'd re-check timer after the owner exits. CLIindex --watchshares the same lock — if a plugin watcher already owns the workspace it warns and exits 0. Only the owner'sclose()releases the lock; stale/corrupt lock files are auto-reclaimed.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 123 lines · 2,603 tokens per session scan A 1058089e69b7
opencode-rag is an instructions file published in the GitHub repository MrDoe/OpenCodeRAG (44 stars, last pushed 13d ago), licensed MIT. It adds 2,603 tokens to every session, about $0.0130 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other instructions, from other repositories
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
buildNext
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
next.js AGENTS.md
Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).
spec-kit AGENTS.md
Instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.
langchain AGENTS.md
Instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.