CodeGraph Mapper has been merged into coder-workflow (v0.3.0+).
All functionality described below is now available as part of the coder-workflow plugin. See DEPRECATED.md for migration instructions.
Graph-first codebase intelligence for Claude Code.
CodeGraph Mapper scans a repository, builds a SQLite-backed graph of files, symbols, imports, calls, routes, handlers, components, and dependencies, then exposes that graph through Claude skills, MCP tools, CLI commands, exports, and a local UI.
It is built for questions that normal text search cannot answer well:
- Where is this implemented?
- Who calls this function?
- What depends on this module?
- What breaks if this file changes?
- Which routes map to which handlers?
- Which modules are hotspots before refactor?
It also ships a production-grade text search tool for exact literal/regex lookup, so grep/rg becomes fallback instead of default.
- Multi-language scanner: JavaScript, TypeScript, Python, Go, Rust, Java.
- SQLite graph store at
.codegraph/graph.db. - Nodes for files, modules, functions, classes, methods, components, routes, handlers.
- Edges for imports, exports, calls, extends, implements, dependencies, route handlers, component usage.
- Graph-backed query, impact analysis, architecture summary, cycles, orphans, quality gates.
- Production text search with literal/regex modes, include/exclude globs, context lines, max-result limits, binary/large-file guards, and structured stats.
- MCP tools for Claude Code workflows.
- Skills and agents for graph-first routing before broad search.
- Local interactive UI with search, filters, zoom, pan, and node detail panels.
- Exports to JSON, Mermaid, DOT/Graphviz, Markdown, and standalone HTML.
- Stop hook support for incremental graph updates.
npm install
npm run build
node dist/cli.js scan
node dist/cli.js summaryIf installed globally:
codegraph-mapper scan
codegraph-mapper summaryThen ask Claude Code:
where is scanCodebase implemented?
what depends on src/graph/db.ts?
what calls analyzeGraphQuality?
analyze impact if I change src/analysis.ts
find routes and handlers
search exact text "TODO_AUTH"
regex search "function\\s+scan"
export graph as mermaid and markdown
codegraph-mapper scan
codegraph-mapper update
codegraph-mapper query "scanCodebase"
codegraph-mapper impact "src/graph.ts"
codegraph-mapper cycles
codegraph-mapper orphans
codegraph-mapper summary
codegraph-mapper quality --fail-on medium
codegraph-mapper search "scanCodebase" --case-sensitive
codegraph-mapper search "function\\s+scan" --regex --context 1 --max-results 10
codegraph-mapper export mermaid markdown
codegraph-mapper ui
codegraph-mapper mcpCommand guide:
| Command | Purpose |
|---|---|
scan / update |
Build or refresh .codegraph/graph.db. |
query |
Find files, symbols, imports, exports, dependencies, routes, handlers, callers/callees. |
impact |
Show upstream/downstream blast radius for a file, symbol, or module. |
cycles |
Detect circular relationships. |
orphans |
Find disconnected files or symbols. |
summary |
Summarize architecture, directories, metadata, and hotspots. |
quality |
Report unresolved imports, duplicates, stale graph data, coverage, and quality gate result. |
search |
Exact literal/regex text search with safe limits and structured stats. |
export |
Write graph artifacts: JSON, Mermaid, DOT, Markdown, HTML. |
ui |
Launch local graph explorer. |
mcp |
Start MCP server for Claude Code. |
Use graph search when the question is about structure:
codegraph-mapper query "scanCodebase"
codegraph-mapper impact "src/analysis.ts"
codegraph-mapper summaryUse text search when the question is about exact content:
codegraph-mapper search "TODO"
codegraph-mapper search "scanCodebase" --case-sensitive
codegraph-mapper search "function\\s+scan" --regex --context 2
codegraph-mapper search "openGraphDb" --include "src/**/*.ts" --exclude "**/*.test.ts"Text search returns:
{
"results": [
{
"file": "src/graph.ts",
"line": 47,
"column": 17,
"text": "export function scanCodebase(root: string, settings: CodeGraphSettings): CodeGraph {",
"contextBefore": [],
"contextAfter": [" const files = listSourceFiles(root, settings);"],
"fileSizeBytes": 9295,
"matchLength": 12
}
],
"stats": {
"filesConsidered": 25,
"filesSearched": 25,
"filesSkipped": 0,
"binaryFilesSkipped": 0,
"oversizedFilesSkipped": 0,
"readErrors": [],
"totalMatches": 1,
"truncated": false
}
}Why use built-in search instead of raw grep:
- respects CodeGraph language and ignore settings
- supports literal and regex search
- supports
--include/--excludeglobs - skips binary files
- skips oversized files
- protects result volume with
--max-results - reports truncation and read errors
- returns machine-readable JSON for Claude/MCP workflows
The bundled MCP server exposes graph and search tools to Claude Code:
| Tool | Purpose |
|---|---|
scan_codebase |
Build/refresh graph. |
query_graph |
Query definitions, references, callers, dependencies, routes, components. |
search_code |
Safe literal/regex text search across source files. |
analyze_impact |
Analyze upstream/downstream change impact. |
summarize_architecture |
Summarize architecture and hotspots. |
find_cycles |
Detect circular dependencies. |
find_orphans |
Detect orphan files/symbols. |
analyze_quality |
Produce graph quality report. |
quality_gate |
Evaluate quality gate threshold. |
export_graph |
Export graph artifacts. |
open_graph_ui |
Start interactive local graph UI. |
- Scan once after meaningful changes.
- Ask graph questions first for architecture, dependencies, flow, callers, and impact.
- Use built-in
search/search_codefor exact literal or regex text lookup. - Use
impactbefore refactors. - Use
quality --fail-on mediumbefore merge. - Use
exportoruiwhen sharing architecture context.
This gives Claude better signal than broad grep because it starts from code relationships, then falls back to safe text search only when needed.
skills/: scan, query, analyze, export, open UI, and orchestration workflows.agents/: graph builder and graph analyst subagents.commands/: plugin slash commands.hooks/: Claude Code hook definitions, including Stop update workflow..claude-plugin/plugin.json: plugin manifest..mcp.json: MCP server configuration.
Runtime graph data lives under .codegraph/ in each analyzed project:
.codegraph/
graph.db
exports/
ui/
Notes:
.codegraph/graph.dbstores nodes, edges, metadata, indexes, and scan cache..codegraph/exports/contains generated JSON/Mermaid/DOT/Markdown/HTML artifacts when exported..codegraph/ui/contains local UI runtime assets.- Generated runtime data should usually stay uncommitted unless your team explicitly wants graph artifacts in git.
CodeGraph Mapper respects target-project .gitignore by default. ignorePaths adds CodeGraph-specific exclusions that should not live in .gitignore.
From this repository:
npm install
npm run build
npm run typecheck
npm run testUseful checks:
npm run check
node --test dist/test/graph.test.js
node --test dist/test/search.test.js
node dist/cli.js scan
node dist/cli.js quality --fail-on mediumRun Claude with local plugin directory:
claude --plugin-dir /mnt/code/djnaidwhbwda/codegraph-mapperThen ask Claude to scan, query, search, export, or analyze the graph.
Install the package globally, then point Claude at the installed plugin directory:
npm install -g /mnt/code/djnaidwhbwda/codegraph-mapper
claude --plugin-dir "$(npm root -g)/codegraph-mapper"After that, codegraph-mapper is available as a global CLI.
Install skills, hooks, agents, and MCP server to Claude Code:
./install.shThis will:
- Build the project
- Install
codegraph-mapperglobally - Configure MCP server in
~/.claude.json(user scope, available in all projects) - Copy skills, agents, and hooks to
~/.claude/
Then restart Claude Code and the MCP tools will be available in all your projects.
# Install everything to user scope (default, available in all projects)
./install.sh
# Install MCP server only (skip skills/agents/hooks)
./install.sh --mcp-only
# Install to project scope (.mcp.json in project root, committed to repo)
./install.sh --project
# Link instead of copy (for development)
./install.sh --link
# Install specific skills only
./install.sh query-codegraph analyze-codegraph
# Skip commands installation
./install.sh --no-commandsIf you prefer manual setup:
npm install
npm run build
claude --plugin-dir /path/to/codegraph-mapperThen add MCP server to ~/.claude.json:
claude mcp add --transport stdio codegraph -- /path/to/codegraph-mapper/dist/cli.js mcpnpm install -g /path/to/codegraph-mapper
claude --plugin-dir "$(npm root -g)/codegraph-mapper"Then add MCP server:
claude mcp add --transport stdio codegraph -- codegraph-mapper mcpcd /path/to/codegraph-mapper
npm link
npm link codegraph-mapper
claude --plugin-dir "$(npm root -g)/codegraph-mapper"Then add MCP server:
claude mcp add --transport stdio codegraph -- codegraph-mapper mcpcodegraph-mapper mcpStop with Ctrl+C. If the server starts without errors, MCP is ready.
Check in Claude Code:
/mcp
You should see codegraph listed with available tools.
Create .claude/codegraph-mapper.local.md in target projects:
---
languages:
- javascript
- typescript
- python
- go
- rust
- java
ignorePaths:
- node_modules
- .git
- dist
- build
- .next
- vendor
- .codegraph/cache
updateOnStop: true
updateOnEdit: false
commitGraphJson: false
maxDepth: 4
uiPort: 3737
exports:
- json
- mermaid
- dot
- markdown
---
Project-specific CodeGraph Mapper settings.Before relying on graph output in CI or review workflows:
codegraph-mapper scan
codegraph-mapper quality --fail-on medium
codegraph-mapper cycles
codegraph-mapper orphansHealthy signal:
- quality gate passes
- no unexpected cycles
- no unexpected orphans
- relationship coverage is high
- hotspots are understood before refactor
MIT or project-defined license.