🗺️

Code Map

Your agent knows where things live before it reads a single file.

soloteambuilder code-mapcontext

A fresh agent — or you at 2am in an unfamiliar repo — burns the first ten minutes grepping for where getLocalizedPath actually lives and what touches it. Code Map removes that tax. brainclaw parses your code with Tree-sitter — JavaScript, TypeScript/TSX, Python, PHP and Java in one index — and records the symbols each file defines (functions, classes, types, interfaces, React components and hooks), what it imports and exports, and how files relate — then answers “what should I read before I edit this?” in one call.

It’s a discovery aid, not a build artifact: it never changes your code, never blocks bclaw_work, and the index (JSONL shards under .brainclaw/code/) is safe to delete — a refresh rebuilds it.

brainclaw code-map status                     # coverage + freshness, never parses
brainclaw code-map refresh                    # incremental: only changed files
brainclaw code-map find getLocalizedPath
#   [10.0] getLocalizedPath  function — src/i18n/config.ts
brainclaw code-map brief src/i18n/config.ts
#   → ranked files to read next (max 12) + the decisions and traps attached

Never silently wrong

Code Map is pull-based — no daemon, no background reindex. Every status / find / brief recomputes a freshness badge from git status and file hashes, so a stale index is always visible instead of quietly misleading:

BadgeMeaning
freshMatches the working tree, the extractor config, and the parser binaries
stale_changed_filesIndexed files changed on disk since they were parsed
stale_extractor / stale_grammarThe config or a Tree-sitter grammar was bumped
missing_indexNo index exists yet for this project

refresh --changed (the default) re-parses only content-changed files and heals stale_extractor / stale_grammar on that same cheap path; --all does a full rebuild with orphan compaction. A held project lock makes refresh fail fast — it never stalls your work, so the worst case is a one-line “run refresh” hint, never a wrong answer. The Tree-sitter parser ships as bundled WASM and loads only on the first parse, so status / find / brief stay instant even before the engine is touched.

On the MCP server, and per-project

The same four calls are MCP tools — bclaw_code_status, bclaw_code_find, bclaw_code_brief, bclaw_code_refresh — so a capable agent reaches them mid-task without a shell, each carrying the same freshness badge; the read tools never trigger a parse. In a monorepo the index is per project: run it inside apps/api and you get that child’s own map. brainclaw’s project resolution routes Code Map to the project you’re working in — the same scoping that powers bclaw_work and bclaw_switch — with no --cwd juggling.

And because brainclaw already holds your decisions and traps, brief doesn’t just point at code — it surfaces the memory attached to that scope. Ask about a module and you get the files to read next and the trap someone left there last month.