Skip to main content

A codebase brain for AI coding assistants — pre-indexed navigation, blast radius, dead code detection

Project description

nervx

A codebase brain for AI coding assistants. Pre-indexed navigation, blast radius analysis, dead code detection, and architectural pattern recognition — all from a single pip install.

Install

pip install nervx

Quick Start

# Build the brain for your project
nervx build .

# Ask questions in natural language
nervx nav "how does authentication work"

# 50-token preview of a symbol — signature, callees, caller count, no source
nervx peek validate_token

# Structural overview of a file — ~150 tokens instead of 4000
nervx tree src/auth.py

# Read a function's source + everything it calls
nervx read validate_token --context 1

# Quick yes/no: does A call B?
nervx ask calls login validate_token

# Confirm a call path with BFS (up to 6 hops)
nervx verify "login calls validate_token"

# Shortest call path between two symbols
nervx trace login validate_token

# Find where a string literal appears across all languages
nervx string-refs "user_id"

# Check blast radius before refactoring
nervx blast-radius validate_token

# Find dead code (framework-aware — skips decorated handlers)
nervx find --dead

# Run pytest with compact output (~80 tokens vs 8000 of traceback)
nervx run pytest tests/

# Open interactive visualization
nervx viz .

Benchmarks

Tested on FastAPI — 3 identical questions asked with and without nervx:

Metric Without nervx With nervx Reduction
Tool calls 93 56 -40%
Output tokens 15,694 8,196 -48%
Grep searches 63 22 -65%
API calls 115 73 -37%
Peak context 70,503 57,141 -19%

nervx replaces dozens of blind grep/read cycles with pre-indexed lookups. Fewer tool calls, less token waste, faster answers.

What It Does

nervx parses your codebase with tree-sitter, builds a graph of every function, class, and method, then pre-computes:

  • Edges: who calls what, who imports what, who inherits from what, and — new in 0.2.2 — which base-class methods dispatch to which concrete overrides (dispatches_to), so trace can follow polymorphic calls that static resolution misses
  • Importance scores: weighted per edge type (calls×2, inherits×1.5, imports×0.5) with a 0–100 percentile rank
  • Path categories: every node tagged category:{vendor,generated,test,example,doc,script,core} so find/nav/blast-radius can drop noise with --exclude-category — new in 0.2.4, script catches scripts/, ci/, build_scripts/, .github/ paths that otherwise pollute importance rankings
  • Architectural patterns: factories, singletons, event buses, strategy patterns, repositories
  • Concept paths: end-to-end call chains and domain clusters
  • Git intelligence: hotspots, temporal coupling, churn analysis — cochange --why exposes the actual commit hashes behind each coupling
  • Contract analysis: callers that disagree on error handling
  • Warning provenance: every warning carries its methodology, confidence, and evidence (visible via nav --verbose-warnings or --json)
  • Dead code: unreferenced functions and classes

All stored in a single SQLite database (.nervx/brain.db), queryable in milliseconds.

Commands

Build

Command What it does
nervx build <path> Full build of the brain
nervx update <path> Incremental update (only changed files)
nervx watch <path> Auto-update on file changes (requires nervx[watch])

Exploration

Command What it does
nervx nav "<question>" Natural language navigation with execution flows
nervx tree <file> Structural overview of a file (~150 tokens)
nervx peek <symbol> 50-token preview — signature, callees, caller count

Reading

Command What it does
nervx read <symbol> Source of one function/method
nervx read <symbol> --context 1 Symbol source + everything it calls
nervx read <symbol> --since <hash> Returns "unchanged" if symbol hasn't been edited

Quick Answers (5–30 tokens each)

Command Answers
nervx ask exists <symbol> yes / no
nervx ask signature <symbol> the function signature
nervx ask calls <A> <B> does A call B directly?
nervx ask imports <file> what this file imports
nervx ask is-async <symbol> yes / no
nervx ask returns-type <symbol> return type from signature
nervx ask callers-count <symbol> integer
nervx ask has-tests <symbol> yes / no + count
nervx verify "A calls B" confirms or denies a call path (up to 6 hops)

Analysis

Command What it does
nervx callers <symbol> Who calls this function
nervx blast-radius <symbol> Full downstream impact (before refactors)
nervx trace <from> <to> Shortest call path (falls back to inheritance + dynamic dispatch)
nervx find --dead Unreferenced code (framework-aware)
nervx find --no-tests --importance-gt 20 Critical untested code
nervx find --exclude-category vendor,test Drop noise paths (vendor/test/generated/example/doc)
nervx flows [keyword] End-to-end execution paths
nervx diff --days 7 Recent structural changes
nervx cochange <file> --why Co-modified files with the commit hashes behind each coupling
nervx string-refs <identifier> Every file:line where the identifier appears as a quoted string literal (JSON/YAML keys, dict subscripts)
nervx uses <identifier> Every source line where the identifier appears as a bare token (attribute access, assignments, type hints, destructuring — complements string-refs)

Diagnostics

Command What it does
nervx doctor Self-check: brain age, staleness, schema sanity, .gitignore coverage
nervx nav "<q>" --verbose-warnings Show warning provenance (methodology, confidence, evidence)

Testing

Command What it does
nervx run pytest [args] Structured summary (~80 tokens vs 8000)
nervx run pytest --raw <run_id> Retrieve cached raw output

Visualization & Stats

Command What it does
nervx viz . Interactive D3 visualization
nervx stats Graph statistics

All output commands support --json for machine-parseable output.

Excluding Files

Create a .nervxignore in the repo root (gitignore syntax) to exclude files from indexing. Defaults already skip __pycache__/, node_modules/, dist/, build/, .venv/, minified bundles, lockfiles, and vendor directories.

Claude Code Integration

When you run nervx build, it automatically adds instructions to your project's CLAUDE.md that teach Claude Code to use nervx commands. Claude will use nervx nav before exploring code, nervx peek/nervx tree instead of reading full files, nervx ask/nervx verify for quick verification, and nervx blast-radius before refactoring — saving tokens and tool calls.

Supported Languages

Python, JavaScript/TypeScript, Java, Go, Rust, C/C++, C#, Ruby

Watch Mode (Optional)

pip install nervx[watch]
nervx watch .

Auto-updates the brain when files change.

Changelog

0.2.6

  • Instance-method dispatch — the Python parser now infers a receiver type for sp.verify() style calls by scanning local assignments (sp = SamplingParams()), annotations (sp: SamplingParams), parameter hints, and self.foo = Foo() in __init__. The linker uses the hint to pick the correct class when a method name is shared. When a receiver type is unknown, the linker fans out to every plausible candidate and marks the edge with confidence="low" so coverage and caller counts still see the call. Strict consumers (ask calls, verify, trace) filter out the low-confidence edges.
  • Full import index — every import/use/using/require now persists to a new raw_imports table, including external modules (numpy, torch, std, java.util.List, System.Text, ...). ask imports <file> returns the full picture instead of only intra-project resolutions.
  • nervx uses <identifier> — new command. Scans source lines for bare-token occurrences of an identifier (attribute access, assignments, type hints, destructuring, match arms). Complements string-refs, which remains the quoted-literal-only lookup.

0.2.5

  • Scale-invariant fuzzy symbol resolution and coverage-tier navigation ranking — consistent behavior from 50-file prototypes to 50k-file monorepos.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nervx-0.2.6.tar.gz (162.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nervx-0.2.6-py3-none-any.whl (181.2 kB view details)

Uploaded Python 3

File details

Details for the file nervx-0.2.6.tar.gz.

File metadata

  • Download URL: nervx-0.2.6.tar.gz
  • Upload date:
  • Size: 162.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for nervx-0.2.6.tar.gz
Algorithm Hash digest
SHA256 7a01c2c6d4b9d9d40114c4fc04ddcbac1ace68323dca1a22faa96323c956f4d6
MD5 5519589cf50735b3e44d29e26fad05c2
BLAKE2b-256 9b85c0fed0bb2c49bf98ab049329943ad3202200d07ef8beb72481af29b2b406

See more details on using hashes here.

File details

Details for the file nervx-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: nervx-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 181.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for nervx-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1d1f9af1c8b67aa01248570c2a59e1871848beb3d70ab778a7eda918a4464615
MD5 42e10a993d168611f2f1efa5f2f4484c
BLAKE2b-256 350433456b30e3e1d04246ab1a3fb8478af96bfa03bc8f8a8e726c86267067c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page