# 🧠 Make Your AI Coding Assistant 500x Smarter — Complete Guide to graphify + code-review-graph + MCP (Knowledge Graphs for Claude Code, Cursor, Windsurf)

> Source: <https://gist.github.com/ashokvarmamatta/344a642e8b5bd286be605a8f439c3848>
> Published: 2026-04-13 05:36:47+00:00

<div align="center">

# 🧠 Make Your AI Coding Assistant 500x Smarter

### Stop Burning Tokens — Use Knowledge Graphs + MCP to Give AI a Map of Your Code

<img src="https://readme-typing-svg.herokuapp.com?font=Fira+Code&weight=600&size=20&pause=1000&color=00D4AA&center=true&vCenter=true&width=700&lines=500x+fewer+tokens+per+query;AI+reads+a+graph+instead+of+your+entire+codebase;Auto-updates+on+every+git+commit;Works+with+Claude+Code%2C+Cursor%2C+Windsurf;Zero+config+after+setup+%E2%80%94+fully+automatic" alt="Typing SVG" />

<br/>

[![graphify](https://img.shields.io/badge/graphify-Knowledge_Graph-00D4AA?style=for-the-badge)](https://pypi.org/project/graphifyy/)
[![code-review-graph](https://img.shields.io/badge/code--review--graph-AST_MCP_Server-FF6F00?style=for-the-badge)](https://pypi.org/project/code-review-graph/)
[![MCP](https://img.shields.io/badge/MCP-Model_Context_Protocol-7F52FF?style=for-the-badge)](https://modelcontextprotocol.io)
[![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-E8590C?style=for-the-badge)](https://claude.ai/code)
[![Cursor](https://img.shields.io/badge/Cursor-Compatible-000000?style=for-the-badge)](https://cursor.sh)

</div>

---

## 📖 What This Guide Covers

```
Your AI assistant reads your ENTIRE codebase every time you ask a question.
That's slow, expensive, and dumb.

This guide gives your AI a MAP of your code — so it looks up answers
instead of reading everything from scratch.

         ┌──────────────────────────────────┐
         │  1. What is MCP?                 │  ← The "USB port" for AI
         │  2. Install graphify             │  ← Builds the knowledge graph
         │  3. Install code-review-graph    │  ← Fast code-only MCP server
         │  4. Connect via MCP              │  ← Wire it to Claude Code
         │  5. Automate updates             │  ← Graph stays fresh forever
         │  6. Use it                       │  ← 500x less tokens
         └──────────────────────────────────┘
```

---

## 🤔 Wait, What is MCP?

**MCP = Model Context Protocol**

Think of it like a **USB port for AI**.

```
USB lets ANY device talk to ANY computer:

  🖨️ Printer ──┐
  📷 Camera  ──┤── USB ──── 💻 Computer
  🎮 Gamepad ──┘

MCP lets ANY tool talk to ANY AI assistant:

  📊 Graph DB    ──┐
  💬 Slack       ──┤── MCP ──── 🤖 AI Assistant
  📁 Code Graph  ──┘
```

**Without MCP:**
```
You: "How does LlmRouter work?"

AI: "Let me read... *reads 143 files* ... *burns 362,000 tokens* ... here's what I found"
    ⏱️ 30 seconds
    💰 $$$ tokens burned
```

**With MCP:**
```
You: "How does LlmRouter work?"

AI: "Let me check the graph..."
    → query_graph("callers_of", "LlmRouter")
    → gets back 10 precise connections in 0.2 seconds
    "LlmRouter has 47 connections. It's called by WebChatServer, ZeroClawService..."
    ⏱️ 2 seconds
    💰 ~700 tokens (that's 500x less!)
```

### The Restaurant Analogy 🍕

```
WITHOUT MCP (reading files):
┌──────────────────────────────────────────┐
│                                          │
│  You walk into a restaurant.             │
│  There's no menu.                        │
│  You go to the kitchen.                  │
│  You open EVERY fridge.                  │
│  You read EVERY ingredient label.        │
│  Then you decide what to order.          │
│                                          │
│  That's your AI reading your codebase.   │
│                                          │
└──────────────────────────────────────────┘

WITH MCP (using graph):
┌──────────────────────────────────────────┐
│                                          │
│  You walk into a restaurant.             │
│  There's a MENU on the table.            │
│  You pick what you want.                 │
│  Done.                                   │
│                                          │
│  The graph IS the menu.                  │
│  MCP IS the waiter.                      │
│                                          │
└──────────────────────────────────────────┘
```

---

## 🧩 The Two Tools (And Why You Need Both)

```
┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│   graphify                        code-review-graph             │
│   ════════                        ═════════════════             │
│                                                                 │
│   📚 The FULL picture             ⚡ The FAST picture           │
│                                                                 │
│   ✅ Code (functions, classes)    ✅ Code (functions, classes)  │
│   ✅ Docs (README, guides)        ❌ No docs                   │
│   ✅ Images (screenshots)         ❌ No images                  │
│   ✅ Bugs & plans                 ❌ No docs                    │
│   ✅ Semantic connections         ❌ Only structural            │
│   ✅ Community clusters           ❌ Basic clusters             │
│   ✅ Interactive HTML viz         ✅ HTML viz                   │
│                                                                 │
│   🐌 Needs LLM for docs/images   ⚡ Pure AST, no LLM needed   │
│   📊 1,479 nodes example          📊 1,411 nodes example       │
│                                                                 │
│   Best for:                       Best for:                     │
│   "How does feature X relate      "Who calls this function?"    │
│    to the bug in BUGS.md?"        "What imports this class?"    │
│                                   "Impact of changing this?"    │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

USE BOTH. They complement each other.
code-review-graph = your quick dictionary
graphify = your full encyclopedia
```

---

## 📦 Step 1 — Install Everything

### 1a. Install graphify

```bash
pip install graphifyy
```

> Yes, it's `graphifyy` with two y's on PyPI.

### 1b. Install code-review-graph

```bash
pip install code-review-graph
```

### 1c. Verify both installed

```bash
graphify --version
code-review-graph --help
```

You should see version info and help text. If not, make sure Python is in your PATH.

---

## 🔨 Step 2 — Build Your First Graph

### 2a. Build the graphify knowledge graph

Navigate to your project root and run:

```bash
cd /path/to/your/project
```

Then in Claude Code (or any AI assistant with graphify skill):

```
/graphify .
```

This will:
1. Detect all files (code, docs, images)
2. Parse code via AST (free, no LLM)
3. Extract concepts from docs/images (uses LLM)
4. Build a graph with nodes + edges
5. Cluster into communities
6. Generate `graphify-out/graph.html` (interactive viz!)

```
What happens:

  Your Project                          graphify-out/
  ├── src/                              ├── graph.json      ← The graph data
  │   ├── auth.kt        ──────►       ├── graph.html      ← Open in browser!
  │   ├── router.kt      ──────►       ├── GRAPH_REPORT.md ← Audit report
  │   └── database.kt    ──────►       └── cost.json       ← Token usage
  ├── README.md           ──────►
  ├── BUGS.md             ──────►
  └── screenshots/        ──────►
        All files become graph nodes
        with edges showing relationships
```

### 2b. Build the code-review-graph

```bash
code-review-graph build
```

This is instant — it only parses code via AST (no LLM needed):

```
$ code-review-graph build
INFO: Progress: 50/140 files parsed
INFO: Progress: 100/140 files parsed
INFO: Progress: 140/140 files parsed
Full build: 140 files, 1411 nodes, 2801 edges
```

### 2c. Open the graph in your browser

```bash
# graphify interactive visualization
open graphify-out/graph.html    # macOS
start graphify-out/graph.html   # Windows
xdg-open graphify-out/graph.html # Linux
```

You'll see something like this:
```
    ┌─────────────────────────────────────────────┐
    │                                             │
    │    ○ LlmRouter                              │
    │   /|\                                       │
    │  / | \                                      │
    │ ○  ○  ○  WebChat  KeyManager  ToolSystem    │
    │ |  |  |                                     │
    │ ○  ○  ○  Service  Agents  OfflineModel      │
    │                                             │
    │   Nodes colored by community                │
    │   Click any node to see connections          │
    │   Zoom, pan, drag                           │
    │                                             │
    └─────────────────────────────────────────────┘
```

---

## 🔌 Step 3 — Connect to Your AI via MCP

### What are we doing here?

```
Right now:

  Claude Code ──── ??? ──── Your graph
  (can't see the graph)

After this step:

  Claude Code ──── MCP ──── code-review-graph server ──── Fast code lookups
       │
       └────────── MCP ──── graphify server ──────────── Full knowledge graph
```

### 3a. Create `.mcp.json` in your project root

Create a file called `.mcp.json` (note the dot!) in your project's root directory:

```json
{
  "mcpServers": {
    "code-review-graph": {
      "command": "code-review-graph",
      "args": ["serve"],
      "type": "stdio"
    },
    "graphify": {
      "command": "python",
      "args": ["-m", "graphify.serve", "graphify-out/graph.json"],
      "type": "stdio"
    }
  }
}
```

> **That's it.** Claude Code reads `.mcp.json` on startup and connects to both servers automatically.

### 3b. What each server provides

**code-review-graph MCP tools:**

| Tool | What it does | Example |
|------|-------------|---------|
| `semantic_search_nodes` | Find code by keyword | "Find all auth-related classes" |
| `query_graph` | Trace relationships | "Who calls LlmRouter?" |
| `get_impact_radius` | Blast radius of a change | "What breaks if I change this?" |
| `detect_changes` | Risk-scored code review | "Review my last commit" |
| `get_review_context` | Token-efficient snippets | "Show me relevant code for review" |
| `get_affected_flows` | Execution path analysis | "Which flows does this change affect?" |

**graphify MCP tools:**

| Tool | What it does | Example |
|------|-------------|---------|
| `query_graph` | Search the full graph | "How does auth relate to the API?" |
| `get_node` | Get node details | "Tell me about OfflineModelManager" |
| `get_neighbors` | Find connected nodes | "What's connected to LlmRouter?" |
| `get_community` | See a cluster | "Show me the memory subsystem" |
| `god_nodes` | Most connected nodes | "What are the core abstractions?" |
| `graph_stats` | Graph overview | "How big is the graph?" |
| `shortest_path` | Find path between concepts | "How does auth connect to database?" |

### 3c. Restart Claude Code

```bash
# Close and reopen Claude Code, or start a new session
# The MCP servers will connect automatically
```

### 3d. Verify it works

In your new Claude Code session, ask:

```
"What are the most connected nodes in this codebase?"
```

If it uses MCP tools (you'll see tool calls like `god_nodes` or `semantic_search_nodes`) instead of running Grep/Read on your files — **it's working!**

```
BEFORE MCP (what you DON'T want to see):
┌────────────────────────────────────────┐
│  🔍 Grep("class.*Router", **/*.kt)    │  ← Reading files
│  📖 Read(src/LlmRouter.kt)            │  ← Reading files
│  📖 Read(src/ProviderRouter.kt)        │  ← Reading files
│  📖 Read(src/WebChatServer.kt)         │  ← More files...
│                                        │
│  💰 Used: ~50,000 tokens              │
└────────────────────────────────────────┘

AFTER MCP (what you WANT to see):
┌────────────────────────────────────────┐
│  🔌 query_graph("callers_of",          │  ← Graph lookup!
│       "LlmRouter")                     │
│                                        │
│  💰 Used: ~700 tokens                 │
└────────────────────────────────────────┘
```

---

## 🤖 Step 4 — Automate Everything (Set and Forget)

This is the magic part. After this, your graphs **update themselves** every time you commit code.

### 4a. Install the graphify git hook

```bash
graphify hook install
```

Output:
```
post-commit: appended to .git/hooks/post-commit
post-checkout: appended to .git/hooks/post-checkout
```

### 4b. Add code-review-graph to the same hook

Open `.git/hooks/post-commit` and add at the bottom:

```bash
# code-review-graph: incremental update for MCP server
if command -v code-review-graph >/dev/null 2>&1; then
    code-review-graph update 2>/dev/null || true
fi
```

### 4c. What happens now on every commit

```
You type: git commit -m "add new feature"

                    ┌──────────────┐
                    │  git commit  │
                    └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │ post-commit  │
                    │    hook      │
                    └──────┬───────┘
                           │
              ┌────────────┼────────────┐
              ▼                         ▼
    ┌─────────────────┐     ┌──────────────────────┐
    │    graphify      │     │  code-review-graph   │
    │                  │     │                      │
    │ Re-extracts only │     │ Re-parses only       │
    │ CHANGED files    │     │ CHANGED files        │
    │ (AST, no LLM)   │     │ (AST, no LLM)        │
    │                  │     │                      │
    │ Updates:         │     │ Updates:             │
    │ graph.json       │     │ internal graph       │
    │ GRAPH_REPORT.md  │     │ MCP serves new data  │
    └─────────────────┘     └──────────────────────┘

    ⚡ Both take < 5 seconds for code-only changes
    ⚡ No LLM tokens consumed
    ⚡ No internet needed
    ⚡ Completely automatic
```

### 4d. What about docs and images?

Code changes auto-update (AST parsing, free).
Docs/images need LLM — run manually when you update docs:

```bash
/graphify . --update
```

This only re-extracts **new/changed** files (cached results are reused):

```
$ /graphify . --update
Cache: 165 files hit, 2 files need extraction
Semantic extraction: ~2 files → 1 agent, estimated ~45s
...done!
```

### 4e. Manual update (no commit needed)

Don't want to commit just to update the graph? Run these anytime:

```bash
# Update code-review-graph (instant, no LLM)
code-review-graph update

# Or full rebuild from scratch
code-review-graph build
```

For graphify, in Claude Code:
```
/graphify . --update
```

```
┌──────────────────────────────────────────────────────────────┐
│                                                              │
│   HOW THE GRAPH STAYS FRESH                                  │
│                                                              │
│   Option 1: Automatic (git commit)                           │
│   ════════════════════════════════                            │
│   git commit → hook runs → both graphs update                │
│   You do nothing. It just works.                             │
│                                                              │
│   Option 2: Manual (anytime)                                 │
│   ═════════════════════════                                   │
│   code-review-graph update    ← run in terminal              │
│   /graphify . --update        ← run in Claude Code           │
│   No commit needed. Run after any edit.                      │
│                                                              │
│   Option 3: Full rebuild (switch branch, big changes)        │
│   ═════════════════════════════════════════════════           │
│   code-review-graph build     ← rebuild from scratch         │
│   /graphify .                 ← full rebuild in Claude Code  │
│                                                              │
└──────────────────────────────────────────────────────────────┘
```

### Summary: What's automatic vs manual

| Change Type | Auto-updates? | Cost |
|-------------|:------------:|------|
| New `.kt` / `.java` / `.py` file | ✅ On commit | Free (AST) |
| Modified code file | ✅ On commit | Free (AST) |
| New/changed `.md` / `.txt` doc | ❌ Manual: `/graphify . --update` | LLM tokens |
| New screenshot / image | ❌ Manual: `/graphify . --update` | LLM tokens |

---

## 📊 Step 5 — See the Token Savings

After graphify builds, it prints a benchmark:

```
graphify token reduction benchmark
──────────────────────────────────────────────────
  Corpus:          271,756 words → ~362,341 tokens (naive)
  Graph:           1,479 nodes, 1,326 edges
  Avg query cost:  ~706 tokens
  Reduction:       513.2x fewer tokens per query

  Per question:
    [787.7x] how does authentication work
    [469.4x] what is the main entry point
    [332.1x] how are errors handled
    [827.3x] what connects the data layer to the api
    [469.4x] what are the core abstractions
```

### What does 500x mean in practice?

```
Without graph:
  10 questions × 362,341 tokens = 3,623,410 tokens
  💰 ~$10-15 in API costs

With graph:
  10 questions × 706 tokens = 7,060 tokens
  💰 ~$0.02 in API costs

  That's like paying $0.02 instead of $10.
  For the SAME answers.
  Actually BETTER answers (structural context).
```

---

## 🎯 Real Usage Examples

### Example 1: "What does LlmRouter do?"

```
WITHOUT graph:
  AI reads LlmRouter.kt (500 lines)
  AI reads every file that imports it (20+ files)
  AI reads docs mentioning it
  Total: ~50,000 tokens, 30 seconds

WITH graph:
  AI calls: get_node("LlmRouter")
  AI calls: get_neighbors("LlmRouter")
  Gets back: 47 connections, callers, callees, related docs
  Total: ~700 tokens, 2 seconds
```

### Example 2: "What breaks if I change OfflineModelManager?"

```
WITHOUT graph:
  AI greps for "OfflineModelManager" in all files
  AI reads each file to understand the dependency
  AI guesses at impact
  Total: ~30,000 tokens, maybe misses indirect deps

WITH graph:
  AI calls: get_impact_radius("OfflineModelManager")
  Gets back: direct deps, transitive deps, affected flows, test coverage
  Total: ~500 tokens, complete picture
```

### Example 3: "Review my last commit"

```
WITHOUT graph:
  AI reads the diff
  AI reads surrounding code for context
  AI reads test files
  Total: ~40,000 tokens

WITH graph:
  AI calls: detect_changes()
  Gets back: risk score, affected communities, missing test coverage
  AI calls: get_review_context() for only the risky parts
  Total: ~2,000 tokens, better review
```

---

## 🗂️ Project Structure After Setup

```
your-project/
├── .mcp.json                    ← MCP server config (commit this!)
├── .gitignore                   ← Add: graphify-out/
├── .git/hooks/post-commit       ← Auto-update hook
├── graphify-out/                ← ⚠️ GITIGNORED
│   ├── graph.json               ← The knowledge graph
│   ├── graph.html               ← Interactive visualization
│   ├── GRAPH_REPORT.md          ← Audit report (god nodes, surprises)
│   └── cost.json                ← Token usage tracker
├── src/
│   └── ... your code ...
└── README.md
```

### What to commit, what to gitignore

| File | Commit? | Why |
|------|:-------:|-----|
| `.mcp.json` | ✅ Yes | Team members get MCP servers too |
| `graphify-out/` | ❌ No | Generated, can be rebuilt |
| `.git/hooks/` | ❌ No | Local only (each dev runs `graphify hook install`) |

Add to your `.gitignore`:
```
# Knowledge graph outputs (rebuild with: /graphify . )
graphify-out/
```

---

## 🚀 Quick Start — Set Up ANY Project in 2 Minutes

Copy-paste these commands in your project root:

```bash
# 1. Install (one-time, works for all projects)
pip install graphifyy code-review-graph

# 2. Build the code-review-graph (instant, no LLM)
code-review-graph build

# 3. Create MCP config for your AI editor
cat > .mcp.json << 'EOF'
{
  "mcpServers": {
    "code-review-graph": {
      "command": "code-review-graph",
      "args": ["serve"],
      "type": "stdio"
    },
    "graphify": {
      "command": "python",
      "args": ["-m", "graphify.serve", "graphify-out/graph.json"],
      "type": "stdio"
    }
  }
}
EOF

# 4. Install auto-update git hooks
graphify hook install

# 5. Add code-review-graph to the same hook
cat >> .git/hooks/post-commit << 'HOOK'

# code-review-graph: incremental update for MCP server
if command -v code-review-graph >/dev/null 2>&1; then
    code-review-graph update 2>/dev/null || true
fi
HOOK

# 6. Gitignore the output
echo -e "\n# Knowledge graph outputs\ngraphify-out/" >> .gitignore

# 7. Auto-configure your AI editor (pick ONE):
graphify claude install       # Claude Code
graphify cursor install       # Cursor
graphify gemini install       # Gemini CLI / Android Studio Gemini
graphify antigravity install  # Google Antigravity
graphify codex install        # OpenAI Codex
graphify copilot install      # GitHub Copilot CLI
graphify opencode install     # OpenCode
graphify aider install        # Aider
graphify droid install        # Factory Droid
graphify claw install         # OpenClaw
graphify trae install         # Trae
graphify trae-cn install      # Trae CN
```

### 8. Build the graphify knowledge graph

**In Claude Code**, just type:
```
/graphify .
```

This is a Claude Code **skill** (slash command). It reads all your code, docs, and images, then builds the full knowledge graph.

**Not using Claude Code?** You can still build the code graph (no LLM needed):
```bash
code-review-graph build
```
This gives you the AST-based graph with MCP. The full graphify graph (with docs/images/semantic connections) requires `/graphify .` in Claude Code or another AI editor with the graphify skill installed.

### 9. Start a new session

Close and reopen your AI editor. The MCP servers load on startup. **Done!**

```
┌────────────────────────────────────────────────────┐
│                                                    │
│  ✅ code-review-graph MCP    → code lookups        │
│  ✅ graphify MCP             → full knowledge graph│
│  ✅ git hook                 → auto-updates        │
│  ✅ CLAUDE.md / .cursorrules → AI knows to use it  │
│                                                    │
│  Your AI is now 500x smarter. For every project.   │
│                                                    │
└────────────────────────────────────────────────────┘
```

---

## 🔄 Setting Up Your NEXT Project

Already did the Quick Start once? For each new project, it's even faster:

```bash
cd /path/to/new/project

# Build + configure (30 seconds)
code-review-graph build
graphify hook install
graphify claude install    # or: cursor, gemini, antigravity, codex, copilot, etc.

# Create MCP config
cat > .mcp.json << 'EOF'
{
  "mcpServers": {
    "code-review-graph": {
      "command": "code-review-graph",
      "args": ["serve"],
      "type": "stdio"
    },
    "graphify": {
      "command": "python",
      "args": ["-m", "graphify.serve", "graphify-out/graph.json"],
      "type": "stdio"
    }
  }
}
EOF

echo -e "\ngraphify-out/" >> .gitignore

# Add code-review-graph to hook
cat >> .git/hooks/post-commit << 'HOOK'

if command -v code-review-graph >/dev/null 2>&1; then
    code-review-graph update 2>/dev/null || true
fi
HOOK

# Then in Claude Code: /graphify .
```

That's it — 30 seconds per project after the first time.

---

## 🌐 Multi-Project Setup — Query ALL Your Projects From ONE Session

<div align="center">

[![Multi-Project](https://img.shields.io/badge/Multi--Project-Query_All_From_Anywhere-FF6F00?style=for-the-badge)](.)
[![Global MCP](https://img.shields.io/badge/Global_MCP-Works_In_Every_Session-00D4AA?style=for-the-badge)](.)

</div>

> 💡 **The Problem:** You graphified Project A and Project B separately. But when you open Claude Code in Project A, it only sees Project A's graph. How do you query both?

> ✅ **The Solution:** Set MCP servers **globally** so they're available in EVERY session, from ANY folder.

### 🤔 Local vs Global — What's the Difference?

```
LOCAL (.mcp.json in project folder)          GLOBAL (~/.claude.json in home folder)
═══════════════════════════════════          ════════════════════════════════════

  📁 Project-A/                                🏠 ~/.claude.json
  │  └── .mcp.json                             │
  │       └── graphify-A  ✅                    ├── graphify-A  ✅
  │                                             ├── graphify-B  ✅
  📁 Project-B/                                 └── graphify-C  ✅
  │  └── .mcp.json
  │       └── graphify-B  ✅                   Open Claude Code ANYWHERE:
  │                                             → ALL graphs available ✅
  Open Claude Code in Project-A:
  → Only sees graphify-A ❌
  → Can't query Project-B ❌
```

### 🚀 Step 1 — Graphify Each Project First

```bash
# Project A
cd /path/to/project-A
code-review-graph build
# In Claude Code: /graphify .

# Project B
cd /path/to/project-B
code-review-graph build
# In Claude Code: /graphify .

# Project C ... repeat for each project
```

### 🔗 Step 2 — Register All Projects in code-review-graph

```bash
# code-review-graph has BUILT-IN multi-repo support 🎉
code-review-graph register "/path/to/project-A" --alias projectA
code-review-graph register "/path/to/project-B" --alias projectB
code-review-graph register "/path/to/project-C" --alias projectC

# Check what's registered
code-review-graph repos
```

```
┌──────────────────────────────────────────────────────────┐
│                                                          │
│  $ code-review-graph repos                               │
│                                                          │
│  ✅ projectA  → /path/to/project-A  (1,411 nodes)       │
│  ✅ projectB  → /path/to/project-B  (892 nodes)         │
│  ✅ projectC  → /path/to/project-C  (2,100 nodes)       │
│                                                          │
│  ONE MCP server. ALL projects. 🔥                        │
│                                                          │
└──────────────────────────────────────────────────────────┘
```

> 🎯 **That's it for code-review-graph!** The single `code-review-graph serve` MCP server now queries ALL registered repos automatically.

### 🧠 Step 3 — Set graphify MCP Globally

For graphify, add each project's graph server to your **global** `~/.claude.json`:

**Tell your AI assistant:**
> "Set up global MCP servers for all my graphified projects"

Or manually add to `~/.claude.json`:

```json
{
  "mcpServers": {
    "code-review-graph": {
      "command": "code-review-graph",
      "args": ["serve"],
      "type": "stdio"
    },
    "graphify-projectA": {
      "command": "python",
      "args": ["-m", "graphify.serve", "/path/to/project-A/graphify-out/graph.json"]
    },
    "graphify-projectB": {
      "command": "python",
      "args": ["-m", "graphify.serve", "/path/to/project-B/graphify-out/graph.json"]
    },
    "graphify-projectC": {
      "command": "python",
      "args": ["-m", "graphify.serve", "/path/to/project-C/graphify-out/graph.json"]
    }
  }
}
```

> ⚠️ **Important:** Each graphify server needs a **unique name** (`graphify-projectA`, `graphify-projectB`, etc.)

### ✅ Result — Everything Connected

```
┌──────────────────────────────────────────────────────────────────┐
│                                                                  │
│         🌐 OPEN CLAUDE CODE FROM ANY FOLDER                      │
│                                                                  │
│                    ┌─────────────────┐                           │
│                    │   Claude Code   │                           │
│                    │   (any folder)  │                           │
│                    └────────┬────────┘                           │
│                             │                                    │
│              Global MCP Servers Load Automatically               │
│                             │                                    │
│         ┌───────────────────┼───────────────────┐               │
│         │                   │                   │               │
│         ▼                   ▼                   ▼               │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐          │
│  │ 📱 Project A │  │ 🌐 Project B │  │ 🎮 Project C │          │
│  │              │  │              │  │              │          │
│  │ graphify-A   │  │ graphify-B   │  │ graphify-C   │          │
│  │ code-review  │  │ code-review  │  │ code-review  │          │
│  │              │  │              │  │              │          │
│  │ 1,411 nodes  │  │ 892 nodes    │  │ 2,100 nodes  │          │
│  └──────────────┘  └──────────────┘  └──────────────┘          │
│                                                                  │
│  🔍 "How does auth work in Project A?"  → queries graphify-A    │
│  🔍 "Compare Project B's DB to C's"    → queries both B and C   │
│  🔍 "Impact of changing this class?"    → queries code-review    │
│                                                                  │
│         ALL PROJECTS. ANY SESSION. ZERO SETUP PER SESSION.       │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘
```

### 📊 Quick Reference

```
┌─────────────────────┬──────────────────────┬────────────────────────┐
│       Tool          │  Multi-Project How?  │  Where to Configure    │
├─────────────────────┼──────────────────────┼────────────────────────┤
│                     │                      │                        │
│  code-review-graph  │  Built-in!           │  code-review-graph     │
│                     │  register command    │  register <path>       │
│                     │  1 server = N repos  │                        │
│                     │                      │                        │
│  graphify           │  1 server per        │  ~/.claude.json        │
│                     │  project             │  (global mcpServers)   │
│                     │  unique name each    │                        │
│                     │                      │                        │
└─────────────────────┴──────────────────────┴────────────────────────┘
```

> 💡 **Pro tip:** After graphifying a new project, just add one more `graphify-newproject` entry to `~/.claude.json` and restart Claude Code. That's it — the new project is connected to all your sessions.

---

## ❓ FAQ

### Q: Does this work with Cursor / Windsurf / other AI editors?

**Yes!** graphify supports **12 AI editors/agents** out of the box:

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│  EDITOR / AGENT             INSTALL COMMAND          WHAT IT WRITES  │
│  ═══════════════            ═══════════════          ══════════════  │
│                                                                      │
│  Claude Code                graphify claude install     CLAUDE.md    │
│  Cursor                     graphify cursor install     .cursorrules │
│  Gemini CLI / Android Studio graphify gemini install    GEMINI.md    │
│  Google Antigravity         graphify antigravity install .agent/     │
│  OpenAI Codex               graphify codex install      AGENTS.md   │
│  GitHub Copilot CLI         graphify copilot install    ~/.copilot/  │
│  OpenCode                   graphify opencode install   AGENTS.md   │
│  Aider                      graphify aider install      AGENTS.md   │
│  Factory Droid              graphify droid install       AGENTS.md   │
│  OpenClaw                   graphify claw install        AGENTS.md   │
│  Trae                       graphify trae install        AGENTS.md   │
│  Trae CN                    graphify trae-cn install     AGENTS.md   │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

MCP is a standard protocol. The `.mcp.json` config works with any editor that supports MCP.

> **Android Studio users:** If you use Gemini in Android Studio, run `graphify gemini install`. The MCP config (`.mcp.json`) is project-level so the `code-review-graph` server is available too.

### Q: What languages are supported?

**code-review-graph:** Kotlin, Java, Python, TypeScript, JavaScript, Go, Rust, C/C++, Ruby, Swift, Scala, PHP, Lua — anything with AST parsing.

**graphify:** ALL files. Code via AST, docs/images via LLM semantic extraction.

### Q: Does this cost money?

- **code-review-graph:** 100% free. Pure AST parsing, no LLM.
- **graphify AST extraction:** Free. No LLM needed for code files.
- **graphify semantic extraction:** Uses your AI tokens for docs/images only. One-time cost, then cached.
- **Auto-updates on commit:** Free (AST only for code changes).

### Q: My graph is out of date after switching branches

```bash
code-review-graph build          # rebuild from scratch (instant)
# Then in Claude Code:
# /graphify . --update           # incremental update (only changed files)
```

### Q: Can I query the graph without Claude Code?

Yes! graphify has a built-in CLI:

```bash
graphify query "how does authentication work?"
graphify query "how does authentication work?" --dfs    # depth-first trace
graphify query "how does authentication work?" --budget 1500  # limit tokens
```

And in Claude Code, you can use slash commands:
```
/graphify query "how does authentication work?"
/graphify path "AuthModule" "Database"
/graphify explain "LlmRouter"
```

### Q: How big can the graph get?

Tested with 1,500+ nodes and 2,800+ edges without issues. The HTML visualization handles up to 5,000 nodes. Beyond that, use Obsidian vault (`/graphify . --obsidian`).

---

## 🔧 Troubleshooting

| Problem | Fix |
|---------|-----|
| `graphify: command not found` | `pip install graphifyy` (two y's!) |
| `code-review-graph: command not found` | `pip install code-review-graph` |
| MCP tools not showing in Claude Code | Restart session (MCP loads at startup) |
| Graph out of date | Run `code-review-graph build` + in Claude Code: `/graphify . --update` |
| `UnicodeEncodeError` on Windows | Set `PYTHONUTF8=1` environment variable |
| HTML viz won't open | Try: `python -m http.server 8080` in `graphify-out/`, open `localhost:8080/graph.html` |
| Hook not running on commit | Check: `ls -la .git/hooks/post-commit` (must be executable) |
| `Graph was built on different branch` | Run `code-review-graph build` to rebuild |

---

## 🎁 Bonus: The Full Picture

```
┌──────────────────────────────────────────────────────────────────┐
│                                                                  │
│                    YOUR DEVELOPMENT WORKFLOW                      │
│                                                                  │
│  ┌──────────┐     ┌──────────┐     ┌──────────┐                │
│  │  Write    │────►│  Commit  │────►│  Hook    │                │
│  │  Code     │     │  (git)   │     │  Runs    │                │
│  └──────────┘     └──────────┘     └─────┬────┘                │
│                                          │                       │
│                            ┌─────────────┼─────────────┐        │
│                            ▼                           ▼        │
│                   ┌────────────────┐        ┌─────────────────┐ │
│                   │   graphify     │        │ code-review-    │ │
│                   │   updates      │        │ graph updates   │ │
│                   │   graph.json   │        │ internal graph  │ │
│                   └───────┬────────┘        └────────┬────────┘ │
│                           │                          │          │
│                           ▼                          ▼          │
│                   ┌────────────────┐        ┌─────────────────┐ │
│                   │   graphify     │        │ code-review-    │ │
│                   │   MCP server   │        │ graph MCP       │ │
│                   │   (full graph) │        │ server (fast)   │ │
│                   └───────┬────────┘        └────────┬────────┘ │
│                           │                          │          │
│                           └──────────┬───────────────┘          │
│                                      │                          │
│                                      ▼                          │
│                             ┌────────────────┐                  │
│                             │  Claude Code   │                  │
│                             │  / Cursor /    │                  │
│                             │  Any AI Editor │                  │
│                             └────────────────┘                  │
│                                      │                          │
│                                      ▼                          │
│                             ┌────────────────┐                  │
│                             │  500x FASTER   │                  │
│                             │  500x CHEAPER  │                  │
│                             │  BETTER ANSWERS│                  │
│                             └────────────────┘                  │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘
```

---

<div align="center">

### Made with 🧠 by [Ashok Varma Matta](https://github.com/ashokvarmamatta)

*If this saved you time, star the gist and share it with your team!*

[![graphify](https://img.shields.io/badge/graphify-GitHub-00D4AA?style=flat-square)](https://github.com/graphify-ai/graphify)
[![code-review-graph](https://img.shields.io/badge/code--review--graph-PyPI-FF6F00?style=flat-square)](https://pypi.org/project/code-review-graph/)

</div>

