By shihwesley
Maps codebases of any size using parallel Sonnet subagents with Merkle-tree change detection. Generates docs/CODEBASE_MAP.md with architecture diagrams, module guides, data flows, and navigation guides. Creates docs/.mercator.json merkle manifest for O(1) staleness checks — compare a single root hash to know if anything changed. Post-commit hook auto-refreshes hashes in ~2 seconds with zero API tokens. Supports incremental updates: only re-explores changed modules. Works without git via pure hash-based diff.
Based on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
Executes bash commands
Hook triggers when Bash tool is used
Merkle-enhanced codebase mapping for AI agents. Maps codebases of any size using parallel subagents, with O(1) change detection and zero-token staleness prevention.
Built upon Bootoshi's Cartographer, enhanced with Merkle tree change detection, post-commit hooks, and a map-first exploration protocol.
Cartographer is a Claude Code plugin by Bootoshi that maps codebases using parallel subagents and token counting. Mercator AI started as a fork and adds merkle-based change detection so you don't re-scan files that haven't changed.
| Feature | Cartographer | Mercator AI |
|---|---|---|
| Codebase scanning | Token counting | Token counting + SHA-256 hashing |
| Change detection | git log --since | Merkle tree O(1) root hash comparison |
| Update mode | Re-scan entire codebase | --diff against manifest, only re-explore changed files |
| Staleness prevention | Manual re-run | Post-commit hook auto-refreshes manifest (zero tokens) |
| Manifest | None | docs/.mercator.json with full merkle tree |
| TLDR integration | None | Auto-invalidates cached summaries for changed files |
| Exploration protocol | None | Map-first protocol documentation for agents |
| Git dependency | Required for updates | Optional — hash-based diff works without git |
/plugin marketplace add shihwesley/shihwesley-plugins
/plugin install mercator-ai@shihwesley-plugins
Or via CLI:
claude plugin marketplace add shihwesley/shihwesley-plugins
claude plugin install mercator-ai@shihwesley-plugins
git clone https://github.com/shihwesley/shihwesley-plugins.git ~/.claude/plugins/mercator-ai
The scanner requires tiktoken. With UV (recommended), it's automatic:
uv run scan-codebase.py # tiktoken auto-installed
Without UV:
pip install tiktoken
/mercator-ai
Or say: "map this codebase", "create codebase map", "document the architecture"
This creates:
docs/CODEBASE_MAP.md — Architecture documentation with diagrams, module guides, data flowsdocs/.mercator.json — Merkle manifest for change trackinguv run scan-codebase.py . --diff docs/.mercator.json
Returns instantly: has_changes: true/false with lists of changed/added/removed files.
The post-commit hook (hooks/mercator-auto-refresh.sh) automatically:
--diff against the manifest/mercator-ai runCost: ~2 seconds of Python. No API calls. No tokens.
flowchart TD
A["/mercator-ai invoked"] --> B["1. scan-codebase.py<br>Recursive file tree<br>Token count + SHA-256<br>Merkle tree + root hash"]
B --> C["2. Plan subagent assignments<br>Group files by module<br>Balance token budgets<br>Skip unchanged modules"]
C --> D["3. Spawn Sonnet subagents<br>(parallel — one per module group)<br>Read files, analyze dependencies<br>Return structured summaries"]
D --> E["4. Synthesize reports<br>Merge subagent outputs<br>Build architecture diagrams<br>Create navigation guides"]
E --> F["5. Write outputs<br>docs/CODEBASE_MAP.md<br>docs/.mercator.json<br>Update CLAUDE.md"]
F --> G["6. Post-commit hook<br>Auto-refresh manifest on commit<br>Zero tokens, ~2 seconds"]
See docs/MAP_FIRST_PROTOCOL.md for the full protocol.
TL;DR: Always read docs/CODEBASE_MAP.md before Glob/Grep. Use the manifest to skip unchanged files. Target specific files based on the map.
| Task | Blind Scan | Map-First |
|---|---|---|
| "Where is auth?" | ~15k tokens | ~2k tokens |
| "Understand API layer" | ~8k tokens | ~1.5k tokens |
| "Any changes?" | ~15k tokens | ~50 tokens |
The .mercator.json manifest contains a hierarchical merkle tree:
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimResearch pipeline + sandboxed Python execution for Claude Code. Turns any topic into agent expertise: structured question tree → source discovery → zero-context fetch (content never enters LLM context) → .mv2 indexing → REPL-based distillation → compact expertise artifact. Also runs Python in isolated Docker containers for code execution, DSPy sub-agents, and data analysis.
Reverse engineer and extract capabilities from any source — repos, configs, binaries, articles — into your agent workflow. Security scanning, manifest tracking, cross-agent restore.
TLDR-aware code simplifier — uses AST summaries for context, full reads only for target files. 80%+ token savings on large codebases. Merkle-integrated for O(1) change detection when used with mercator-ai.
Ambient dev environment management — auto-switches between dev, test, staging, and prod using Docker containers, sidecars, and task-aware classification. Provides /orbit commands for explicit control.
Ambient .tech.md generation — auto-documents and tracks freshness of your codebase
npx claudepluginhub shihwesley/shihwesley-plugins --plugin mercator-aiMaps and documents codebases of any size using parallel AI subagents
Codebase exploration, refactoring, and quality analysis
Codebase intelligence for Claude Code. Indexes your codebase into five layers (Graph, Git, Docs, Decisions, Code Health) and exposes them through nine task-shaped MCP tools — so Claude understands architecture, ownership, hotspots, why code is built the way it is, and where the defect risk lives.
Analyzes a codebase and generates animated HTML architecture reports — diagrams, data flows, component directories, metrics, and insights.
Smart codebase exploration with dependency mapping and structure analysis
AI-powered codebase understanding assistant. Learn design patterns, analyze impact, trace code flows, and understand any codebase through information theory principles. Includes 6 Agent Skills for automatic analysis triggering.