---
title: "Code intelligence, codebase-memory-mcp + codegraph | Recipe — StudioMeyer Academy"
description: "Index your repo into a knowledge graph so Claude can answer 'who calls this function' and 'what breaks if I delete it' in one tool call instead of grepping."
canonical: "https://studiomeyer.academy/en/recipes/2.4-code-intelligence"
language: en
markdown_versions: ["https://studiomeyer.academy/en/recipes/2.4-code-intelligence.md"]
publisher: "StudioMeyer Academy, https://studiomeyer.academy (llms.txt: https://studiomeyer.academy/llms.txt)"
---

[← Alle Recipes](https://studiomeyer.academy/recipes)

Phase 2 · Connectivity·6 steps

# Code intelligence, codebase-memory-mcp + codegraph

Index your repo into a knowledge graph so Claude can answer 'who calls this function' and 'what breaks if I delete it' in one tool call instead of grepping.

6 steps0%

Du liest ohne Account. Mit [Login](https://studiomeyer.academy/login?next=/recipes/2.4-code-intelligence) speichern wir Step-Fortschritt + Notes.

# Code intelligence

Two MCP servers turn Claude from "smart grep" into "engineer who knows your codebase":

- **codebase-memory-mcp**, indexes your repo into a Postgres-backed knowledge graph. Symbols, files, edges (calls, imports, defines).
- **codegraph**, runs deep analysis on top: complexity, find\_cycles, fn\_impact, audit, communities.

Together they replace 80% of grep + ad-hoc code reading with O(1) graph queries.

The graph runs locally, your code never leaves your machine. The Postgres index sits in `.codebase-memory/graph.db.zst` next to your repo.

### Step 1: Install codebase-memory-mcp

```bash
claude mcp add codebase-memory -s user -- npx -y codebase-memory-mcp
```

For Codex:

```toml
[mcp_servers.codebase-memory]
command = "npx"
args = ["-y", "codebase-memory-mcp"]
```

### Step 2: Install codegraph (optional but recommended)

```bash
claude mcp add codegraph -s user -- codegraph mcp
```

If `codegraph` is not on PATH, install with:

```bash
npm install -g codegraph
```

Codegraph is the "deep analysis" layer. You can skip it and just use codebase-memory-mcp's basic search; you lose `fn_impact` and `find_cycles` etc.

### Step 3: Index your first repo

In a fresh Claude Code session inside your repo:

```
"index this repository"
```

Claude calls `index_repository` on codebase-memory-mcp. First index is ~1-2 minutes for a 50k-line repo. Subsequent indexes are incremental (content-hashed), sub-second.

Then ask:

```
"what's the architecture overview of this repo?"
```

Claude calls `get_architecture`, you get module hierarchy, dependency graph, and entry points. This single call replaces 30 minutes of click-around.

### Step 4: Verify

Run `academy_validate_step`. The validator looks for any of `codebase|codegraph|archtracker` in `claude mcp list`, OR a `.codebase-memory/` directory in the cwd. Either path passes.

### Step 5: Useful queries to try

Once indexed, your AI can answer:

- **"Who calls handleStartRecipe?"** → `search_graph` returns all callers in O(1).
- **"What breaks if I rename this function?"** → `codegraph fn_impact` returns transitive callers.
- **"Are there circular dependencies?"** → `codegraph find_cycles` returns SCCs.
- **"What are the most complex files?"** → `codegraph complexity` returns hotspots.
- **"Show me the call chain from POST /upgrade to Stripe"** → `trace_call_path`.

Add a CLAUDE.md hint so Claude reaches for the graph instead of grep:

```markdown
## Codebase intelligence

When working in this repo, prefer search_graph / codegraph context / fn_impact
over grep + reading whole files. Re-index after structural changes
(new files, renamed functions). The graph is faster and more accurate
than text search for "who calls X" and "what depends on Y" questions.
```

Client check · run on your machine

(claude mcp list 2>&1 | grep -iE "codebase|codegraph|archtracker") || ls -d ./.codebase-memory 2>/dev/null || echo "neither code-intel MCP nor local index"

**Expect:** Either a code-intel MCP is listed OR a \`.codebase-memory/\` directory exists in your project.

**If stuck:** Install codebase-memory-mcp (\`claude mcp add codebase-memory -s user -- npx -y codebase-memory-mcp\`) and run \`index\_repository\` once.

### Step 6: Optional, archtracker for drift detection

```bash
claude mcp add archtracker -s user -- archtracker-mcp
```

archtracker takes architecture snapshots and tells you when the codebase drifts (orphan modules, coupling hotspots, circular deps that didn't exist last week). Mostly useful for repos with multiple contributors, solo projects don't drift fast enough to need it.

After this recipe Claude understands your code structure as well as you do. The next recipe wires up GitHub so it can read PRs and issues too.

[← Web research. Brave, Exa, and](https://studiomeyer.academy/recipes/2.3-web-research) [GitHub MCP, read PRs, issues, →](https://studiomeyer.academy/recipes/2.5-github-mcp)

Phase 2

Your first MCP servers (Memory, Research, GitHub, Code Intel)

[Alle Phasen →](https://studiomeyer.academy/recipes)

Concepts

[codebase-memory-mcp](https://studiomeyer.academy/concepts/codebase_memory_mcp) [Knowledge graph](https://studiomeyer.academy/concepts/knowledge_graph)

## Sitemap

Public pages of this site as Markdown: [sitemap](https://studiomeyer.academy/sitemap.md). Curated entry point: [llms.txt](https://studiomeyer.academy/llms.txt), full text: [llms-full.txt](https://studiomeyer.academy/llms-full.txt).
