Skip to main content

Codebase Map

Standalone function dependency graph generator for Python (and TypeScript) projects. Output: interactive HTML + JSON. 100% offline · zero CDN. License: MIT · Version: 2.4.0

Parse your codebase into a function dependency graph (nodes = functions/classes, edges = call relationships). Foundation for understanding large codebases, PR impact analysis, and dual-snapshot diff.


Install

From PyPI (recommended for v2.2.1+):

pipx install codebase-map     # Isolated install (recommended)
# or
pip install codebase-map

From source (latest main):

pipx install "git+https://github.com/hypercommerce-vn/codebase-map.git"

For development:

git clone git@github.com:hypercommerce-vn/codebase-map.git
cd codebase-map
pip install -e ".[dev]"

For MCP server (Claude Desktop / Cowork / Claude Code):

pipx install "codebase-map[mcp]"
cbm-mcp          # stdio MCP server (blocks — this is expected)

Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "codebase-map": {
      "command": "cbm-mcp"
    }
  }
}

5 tools auto-invoke: cbm_query, cbm_search, cbm_impact, cbm_snapshot_diff, cbm_api_catalog. See integrations/mcp/README.md for the full walkthrough.

Verify:

codebase-map --version

Quick Start

1. Create config at project root

# codebase-map.yaml
project: "my-app"
sources:
  - path: "app"
    language: python
    base_module: "app"
    exclude: ["__pycache__", "migrations"]
output:
  dir: "docs/function-map"
  formats: [json, html]
graph:
  depth: 3
  group_by: module

2. Generate graph

codebase-map generate -c codebase-map.yaml

Output: docs/function-map/graph.json + interactive index.html.

3. Query the graph

codebase-map summary -f docs/function-map/graph.json
codebase-map query "CustomerService" -f docs/function-map/graph.json
codebase-map impact "AuthService" -f docs/function-map/graph.json
codebase-map search "create" -f docs/function-map/graph.json

4. Dual-snapshot diff (v2.2)

# Create baseline
codebase-map generate --label "baseline"

# ... make changes ...

codebase-map generate --label "post-dev"
codebase-map snapshot-diff --baseline baseline --current post-dev --format markdown

Commands

Command Purpose
generate Generate function dependency graph
query Look up function/class details
impact Show impact zone for a node
search Search nodes by keyword
summary Graph statistics
diff Git diff impact analysis
snapshot-diff Dual-snapshot structural diff (v2.2)
snapshots Manage snapshots (list/clean)
api-catalog List API routes
coverage Overlay test coverage
check-staleness Check graph freshness

All commands support --help for detailed options.


Features

🔍 Graph Generation

  • Python AST parser (classes, functions, methods, decorators)
  • Layer classification (route / service / model / util / schema / test)
  • Domain clustering (by module path)
  • Call graph edges + import edges
  • JSON + interactive HTML output

📊 Dual-Snapshot Diff (v2.2)

  • Compare two graph snapshots (before/after)
  • Added / removed / modified / renamed functions
  • Affected callers (transitive, 1-3 levels)
  • Rename detection via signature matching
  • Output formats: markdown (PR body), JSON (CI), text (terminal)

🎨 Interactive HTML

  • D3.js force-directed graph (bundled, offline)
  • Sidebar tree, minimap, toolbar
  • Executive view, PR Diff view, API Catalog
  • Multi-view tabs, breadcrumb navigation
  • Business Flow mapping

⚙️ CI Integration

  • cbm-baseline.yml — auto-baseline on merge to main
  • cbm-post-merge.yml — rotate baseline after PR merge
  • cbm-pr-impact.yml — post PR Impact comment (dual-snapshot)

Architecture

Source Code (Python/TS)
    ↓
  [AST Parser]
    ↓
  [Graph Builder]  → Nodes + Edges + Metadata
    ↓
  [Exporters]      → JSON + HTML (D3.js)
    ↓
  [Query Engine]   → summary, impact, search, query
    ↓
  [Snapshot Diff]  → add/remove/modify/rename + affected callers

CBM is stateless: every command takes graph.json as input. No database, no state.


Use Cases

Before modifying a function

codebase-map impact "CustomerService.create" -f graph.json
# Shows all callers — know blast radius before refactoring

In PR description

codebase-map snapshot-diff --baseline main --current feature-branch --format markdown
# Copy-paste into PR body — reviewers see structural impact

CI auto-comment

Installed workflows post impact analysis on every PR automatically.

Understand a new codebase

codebase-map summary -f graph.json       # How big is it?
codebase-map api-catalog -f graph.json    # What APIs exist?
codebase-map query "main" -f graph.json   # Where's the entry point?

Sister Project: Knowledge AI Platform

Want AI-powered Q&A on your codebase? Check out Knowledge AI Platform — adds multi-LLM RAG, MCP server, and onboarding report generator on top of CBM data.


Development

# Install
pip install -e ".[dev]"

# Test
pytest tests/ -q

# Lint
black --check codebase_map/ tests/
isort --check codebase_map/ tests/
flake8 codebase_map/ tests/

# Generate on self
codebase-map generate -c codebase-map-self.yaml

License

MIT — see LICENSE file.


Credits

Built by Hyper Commerce for internal use, open-sourced for the community.


Version 2.4.0 · Published 2026-04-20

Metadata

Release files for codebase-map 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codebase-map 2.4.0
File Size Uploaded Provenance Actions
codebase_map-2.4.0.tar.gz 174.0 kB Without provenance Details for codebase_map-2.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codebase-map 2.4.0
File Interpreter ABI Platform Actions
codebase_map-2.4.0-py3-none-any.whl Python 3 none any Details for codebase_map-2.4.0-py3-none-any.whl

Total release size: 359.8 kB

Release files / codebase_map-2.4.0.tar.gz

Download URL codebase_map-2.4.0.tar.gz
Size 174.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1bc2cc1cb9235496b6b94926bffcb98b0a2a40233d49bb9206409e922ca8ac48
BLAKE2b-256 checksum
How to use checksums
974baf4fc13d97845b202e6a2ca1c29d1d0c516cc313b7eeaf1bb530ab208154
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / codebase_map-2.4.0-py3-none-any.whl

Download URL codebase_map-2.4.0-py3-none-any.whl
Size 185.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
426416729f80de9af7ba3df89b28128713b65fe30c069e0e40cb5816a69461ed
BLAKE2b-256 checksum
How to use checksums
e38ac3d6bad0f87deeef87110ef86633a8c05e47c72d70e2bd81f034ac583b9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for codebase-map 2.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page