Skip to main content

Token-efficient code-review-graph wrapper for AI coding agents

Project description

crg-lean

Token-efficient wrapper for code-review-graph.

The raw code-review-graph MCP tools return 15k–24k tokens per query — full absolute paths, raw graph edges, source code dumps. crg-lean strips the fat, converts paths to relative, and returns only what's useful: 10–87× fewer tokens per query.

Real measurements (53-file Next.js project)

Query Raw MCP crg-lean Reduction
detect changes ~5,456 tok ~156 tok 35×
impact radius ~15,517 tok ~179 tok 87×
minimal context ~101 tok ~73 tok 1.4×

Requirements

Install

bash install.sh

Or manually:

cp crg-lean ~/.local/bin/crg-lean
chmod +x ~/.local/bin/crg-lean

One-command project setup

Run once in any project directory:

crg-lean setup

This automatically:

  1. Installs code-review-graph if missing (tries pipx → uv → pip)
  2. Builds the code graph
  3. Adds .code-review-graph/ to .gitignore
  4. Wires SessionStart + PostToolUse hooks in .claude/settings.json
  5. Installs post-commit, post-merge, post-rebase git hooks (monorepo-aware)
  6. Creates/updates CLAUDE.md with an architecture section

Idempotent — safe to re-run, skips steps already done.

Commands

crg-lean setup                   # bootstrap a project (run once)
crg-lean changes                 # what changed since last commit + risk score
crg-lean find "<symbol>"         # locate a symbol → file:start-end (N lines)
crg-lean impact [file ...]       # blast radius — which files are affected
crg-lean context "<concept>"     # keyword search — does this already exist?
crg-lean stats                   # graph overview (files, nodes, languages)
crg-lean update-claude           # refresh architecture section in CLAUDE.md

Surgical read workflow

# 1. Find exact location
crg-lean find "authenticate"
# → src/utils/jwt.ts:7-18  (12 lines)

# 2. Read only those lines
# Read(src/utils/jwt.ts, offset=7, limit=12)
# ~48 tokens vs ~1,200 for the full file

Auto-updating CLAUDE.md

crg-lean setup installs three git hooks that keep CLAUDE.md current:

  • post-commit — after every local commit
  • post-merge — after every git pull (picks up changes from other machines)
  • post-rebase — after every rebase

The hooks only update the <!-- arch:start --> ... <!-- arch:end --> block. Human-written content below <!-- preserved-below --> is never touched.

Works in monorepos — each service can have its own CLAUDE.md and the hooks update all of them.

Claude Code skill

crg-lean ships as a Claude Code skill. Install it globally:

mkdir -p ~/.claude/skills/crg-lean
cp skills/crg-lean/SKILL.md ~/.claude/skills/crg-lean/SKILL.md

This tells Claude when and how to use crg-lean automatically, without being prompted.

How it works

crg-lean starts the code-review-graph serve MCP server as a subprocess, calls tools via JSON-RPC, then post-processes responses:

  • Strips absolute paths → relative paths
  • Removes fat fields: affected_flows, review_priorities, edges, impacted_nodes, context
  • Limits arrays to top N
  • Returns plain text instead of JSON

The MCP server is started fresh per invocation (~0.5s). No persistent daemon.

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

crg_lean-1.0.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

crg_lean-1.0.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file crg_lean-1.0.0.tar.gz.

File metadata

  • Download URL: crg_lean-1.0.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for crg_lean-1.0.0.tar.gz
Algorithm Hash digest
SHA256 75b382727ed90e2fd0d091c96def0b88d7435b11d1883f56b9a806da358cb320
MD5 efc04fa6c5f2733544391e95840d453c
BLAKE2b-256 2c545daf43c27334a156cbe54b950a40a9d204503ba7cac8db1cacf66ba2e554

See more details on using hashes here.

File details

Details for the file crg_lean-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: crg_lean-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for crg_lean-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe1b86505995a70252b67ca227d115c233f02d8b8b6bd2af4a703df5843c236f
MD5 7deb6f7e4a0afcca1a05872e3ee4dc1e
BLAKE2b-256 058d44bf436744a9eb3635fa768dff1c310f0f0cada6a31ec725d8b08abc2223

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