Skip to main content

codebase-index logo

codebase-index

Give AI coding agents a precise map of your codebase — locally, privately, and with evidence.

Find implementations. Trace behavior. Predict change impact.

Quick start · Install · Benchmarks · Security · MCP

PyPI version CI Python 3.11+ MCP ready No network by default MIT license

codebase-index showing a Find, Trace, Predict workflow with precise file and line evidence

The short version

codebase-index is a local retrieval and code-graph layer for Claude Code, Codex CLI, OpenCode, and MCP clients. It indexes a repository into SQLite, extracts symbols and relationships with Tree-sitter, and gives agents ranked file:line evidence instead of making them scan broad sets of files.

Question → ranked retrieval → dependency evidence → precise answer

It is not an IDE and not another coding agent. Your existing agent remains the interface; codebase-index gives it better aim.

Find. Trace. Predict.

Job Question Command
Find Where is authentication implemented? codebase-index search "authentication"
Trace How does checkout reach the database? codebase-index explain "checkout flow"
Trace How are two components connected? codebase-index path ApiController Database
Predict What breaks if User changes? codebase-index impact User
Predict What does my current diff affect? codebase-index diff-impact

Every retrieval packet carries:

  • ranked matches and the reason each match scored;
  • exact line ranges to read next;
  • index freshness;
  • answer confidence and targeted fallbacks;
  • graph coverage and edge confidence where relevant.

That evidence contract lets an agent distinguish “nothing references this” from “the graph is partial, so verify with a targeted search.”

Install in five minutes

pip install codebase-index
cd your-project
codebase-index init
codebase-index index
codebase-index search "where is authentication implemented?"

init can install resources for Claude Code, Codex CLI, OpenCode, and detected MCP clients:

codebase-index init --target auto
codebase-index init --target codex
codebase-index init --target claude
codebase-index init --target opencode

pipx install codebase-index is supported as an isolated alternative. See the installation guide for pinned releases, editable installs, hooks, Windows details, and troubleshooting.

Claude Code plugin

/plugin marketplace add denfry/codebase-index
/plugin install codebase-index@codebase-index

The plugin provisions a private environment on first use. Later sessions run offline, and the first codebase question builds the index automatically.

What the agent receives

{
  "query": "where is authentication implemented?",
  "confidence": "high",
  "results": [
    {
      "path": "src/auth/AuthService.ts",
      "line_start": 12,
      "line_end": 148,
      "score": 0.92,
      "reason": "exact symbol match, 4 callers"
    }
  ],
  "recommended_reads": [
    {
      "path": "src/auth/AuthService.ts",
      "line_start": 12,
      "line_end": 148
    }
  ],
  "index": {
    "exists": true,
    "stale": false
  }
}

Snippets are skeletonized when that preserves evidence while saving tokens. Unrelated bodies collapse, but imports, signatures, matched lines, and exact read ranges remain.

Core commands

# Find
codebase-index search "auth token refresh"
codebase-index symbol AuthService

# Trace
codebase-index explain "authentication flow"
codebase-index refs send_email
codebase-index path ApiController Database
codebase-index describe Database
codebase-index architecture

# Predict
codebase-index impact User --direction up --depth 2
codebase-index diff-impact --base HEAD --direction up --depth 2

# Inspect and visualize
codebase-index graph User --direction both --depth 2 --output graph.html
codebase-index stats
codebase-index doctor

Add --json for agents and automation. Search supports hybrid, fts, symbol, and opt-in vector modes.

Why not just grep?

Grep is excellent when you know the exact text. Repository questions often need more:

Capability rg / grep codebase-index
Exact text matching Yes Yes
Ranked results No Yes
Symbol definitions vs calls No Yes
Dependency and impact graph No Yes
Token-budgeted read plan No Yes
Freshness and coverage signals No Yes
Local and scriptable Yes Yes

Use grep for one known string. Use codebase-index when the agent must locate, understand, or assess a change across a repository.

The comparison guide also covers Cursor, Aider repo-map, Sourcegraph, Continue, Amp, and Codebase-Memory MCP—including when those tools are the better choice.

Measured results

On the published 55k LOC Java benchmark:

  • Recall@3: 70% for codebase-index versus 40% for the rg baseline;
  • answer-context tokens: approximately 13× fewer;
  • raw results and methodology are checked into the repository.

These results are evidence for that benchmark, not a claim of universal superiority. Large public-repository and framework-graph evaluations remain on the roadmap. Read the complete methodology and limitations in BENCHMARKS.md.

Local by default

The base install:

  • makes no network requests;
  • sends no telemetry;
  • stores the derived index inside the project cache;
  • excludes dependency, build, binary, oversized, generated, and secret-like files before indexing;
  • redacts secret patterns again at output time;
  • exposes doctor --strict for CI and security checks.

Embeddings are optional. Local embeddings stay on the machine; external embeddings require explicit configuration, an API key, and an endpoint acknowledgement.

See the security model for trust boundaries, gates, failure modes, and residual risks.

How it works

Repository
   │
   ├─ discovery + ignore and secret gates
   ├─ Tree-sitter symbols and relationships
   ├─ line and symbol-aligned chunks
   └─ optional embeddings
          │
          ▼
      local SQLite
   FTS5 + symbols + graph
          │
          ▼
 intent routing → hybrid retrieval → rerank → token budget
          │
          ▼
 ranked file:line evidence for CLI, Skill, and MCP

The three product surfaces share one service layer, so retrieval behavior does not drift between the CLI, installed agent skills, and MCP tools.

Detailed internals:

Supported surfaces

Surface Integration
Claude Code Skill, plugin, optional hooks
Codex CLI AGENTS.md plus project skill
OpenCode Command, agent, and skill resources
MCP clients stdio server with versioned JSON envelopes
Shell and automation CLI, --json, and local SQLite

Run the MCP server with:

codebase-index mcp --root /path/to/repository

Available MCP tools include search, explain, symbols, references, impact, diff impact, architecture, shortest path, node description, health, and index statistics. See MCP.md for client configuration.

Project status

The latest released line is 1.9.0. It includes:

  • hybrid and optional vector retrieval;
  • Tree-sitter symbol extraction across the documented language tiers;
  • import, call, reference, and inheritance graphs;
  • architecture communities, central nodes, and surprising cross-module links;
  • shortest dependency paths and node descriptions;
  • token-budgeted and skeletonized retrieval packets;
  • benchmark-calibrated lexical expansion, fuzzy identifier matching, and source-aware ranking;
  • rank fusion that scores cross-retriever agreement at file level, not just at a locator;
  • bounded, intent-directed graph discovery with optional diversity and duplicate suppression;
  • CLI, Skill, plugin, and MCP delivery;
  • incremental updates, watch hooks, diagnostics, skill rollback, and diff-aware impact analysis;
  • a multi-repository retrieval evaluation with leak-free git-derived ground truth, one-signal ablations, and paired significance tests (tests/eval).

Every shipped ranking signal has to survive that evaluation: 1.9.0 removed the cost of two signals that could not demonstrate a benefit and rejected several plausible ones outright (IDF-weighted coverage, stemming, graph propagation, MMR, a file-length prior). Planned work is deliberately separated from shipped capability. The next product priorities are typed framework edges and an even more direct task-context workflow. See the roadmap.

Documentation

Start here Deep dives Project trust
Quick start Retrieval Benchmarks
Installation Architecture Security
FAQ MCP Release checklist
Skill design Schema Changelog

Contributing

Contributions should preserve three invariants:

  1. retrieval quality is measured, not asserted;
  2. the default path remains local and fails closed at security boundaries;
  3. machine-readable contracts stay stable across CLI and MCP.

Before opening a pull request:

pytest
ruff check .
mypy src
python scripts/sync_skill_copies.py --check

Add user-visible changes under [Unreleased] in CHANGELOG.md. See CONTRIBUTING.md if present and the repository instructions for branch and review policy.

License

MIT

Release files for codebase-index 1.9.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-index 1.9.0
File Size Uploaded
codebase_index-1.9.0.tar.gz 868.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codebase-index 1.9.0
File Interpreter ABI Platform
codebase_index-1.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / codebase_index-1.9.0.tar.gz

Download URL codebase_index-1.9.0.tar.gz
Size 868.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6f4be0255ee37712e2d1214be33b3b571bcfad3c8e807ca61fb707022a248740
BLAKE2b-256 checksum
How to use checksums
86da27b96d57ce723706bcec87e943be8e5c3561886a5da0192f73f558f0eda8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / codebase_index-1.9.0-py3-none-any.whl

Download URL codebase_index-1.9.0-py3-none-any.whl
Size 151.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f91f4cab3e0b630af0d60172912c79ccab1affc9fd710b29ac4a0fc78551d92
BLAKE2b-256 checksum
How to use checksums
cb7a49a2642d73805f61208145bce23245c7a60a1480c02f7c3e40390c7728ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

This release

1.9.0 This release

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

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