Skip to content
154.0k

BlogGuides

How to give Claude Code a code knowledge graph (2026 guide)

How to give Claude Code a code knowledge graph (2026 guide)

Claude Code starts each session by searching the repo. It greps for a name, opens the files that match, and reads them into the conversation. A code knowledge graph for Claude Code gives it a map it can query instead, so the session starts from structure that already exists on your machine.

How do you give Claude Code a code graph?

Out of the box, Claude Code finds code by searching and reading files, not from a graph. You can add one in two ways. Connect the Graphify connector, which serves a hosted graph of your repositories at https://api.graphify.com/mcp with OAuth sign in, or install open-source Graphify and build the graph on your own machine with /graphify ..

The connector gives Claude Code the same code graph your team uses in Graphify, plus team Memory and PR review status. The Wiki is read in the Graphify app, not over MCP. Start free at app.graphify.com, connect a repository, then add the server in a terminal:

bash
claude mcp add --transport http --scope user graphify https://api.graphify.com/mcp

Open /mcp, choose graphify and sign in in the browser. Then ask Claude Code what calls a function you know well. The rest of this guide is the local path, and Graphify + Claude Code covers both.

What does graphify install write for Claude Code?

The package on PyPI is graphifyy, with two y's. Install the CLI first.

bash
uv tool install graphifyy

pipx install graphifyy also works. If the shell then says graphify is not found, run uv tool update-shell and open a new terminal. ~/.local/bin is not on PATH until you do.

The bare graphify install targets Claude Code. It writes the /graphify skill to ~/.claude/skills/graphify/SKILL.md, adds a graphify section to ~/.claude/CLAUDE.md, and writes PreToolUse hooks to .claude/settings.json. When you type /graphify, that section tells Claude Code to follow the skill before it does anything else.

graphify install --project writes those pieces inside the repo, so a team can commit them. The skill path there is .claude/skills/graphify/SKILL.md, and the hook settings go in .claude/settings.json. The command prints a git add hint. Teammates need the graphifyy CLI installed.

If you see ModuleNotFoundError: No module named 'graphify', the usual cause on Mac or Windows is a plain pip install. The skill resolves Python from graphify-out/.graphify_python, which can point at a different environment than pip used. Use the uv or pipx install above. Both isolate the package.

The registration block is on Graphify + Claude Code: a code knowledge graph.

How do you build the graph?

In a Claude Code session, type /graphify .. The skill maps the project into graphify-out/. graph.html is the interactive view, GRAPH_REPORT.md has the highlights and suggested questions, and graph.json is the queryable graph.

On PowerShell, type graphify .. The leading slash in /graphify . is parsed as a path separator there.

If /graphify does nothing, check that ~/.claude/skills/graphify/SKILL.md exists and that the graphify section is in CLAUDE.md. Start a new Claude Code session so both are picked up.

The background is in What is a code knowledge graph?. The glossary page is Knowledge graph.

How does Claude Code query the graph?

Before Claude Code greps or opens files one by one, the hook-guard reminds it to try the graph. graphify query returns a scoped subgraph for a question. graphify path returns the dependency path between two symbols. graphify explain returns everything connected to a node. Ask what calls chargeCustomer, and what breaks if you change its signature.

bash
graphify query "what calls chargeCustomer, and what breaks if I change its signature?"
graphify path "A" "B"
graphify explain "chargeCustomer"

Results include file:line citations. Every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS. The tags separate what was found from what was guessed.

What does strict mode change?

A normal install nudges Claude Code toward the graph. graphify install --project --strict blocks the first raw source read of a session and redirects that read to the graph. After that one block, the hook goes back to the soft nudge.

GRAPHIFY_HOOK_STRICT=1 or 0 toggles strict mode at runtime. No reinstall.

How does the graph stay current?

graphify update . re-extracts changed files. That pass is AST-only. graphify hook install adds post-commit and post-checkout git hooks that run the update on commit and checkout. The graph does not update itself.

Hook commands store an absolute path to the interpreter at install time. After you upgrade, run graphify hook install again so the embedded interpreter path stays fresh. If the PreToolUse hooks stop firing after an upgrade, run graphify install again.

Do you need the MCP server?

The skill plus the CLI is the complete default. The MCP server is optional. Add .mcp.json at the project root when you want the graph as native tools, or when several assistants should share one graph.

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

You can call query_graph, shortest_path, god_nodes, graph_stats, and a PR-triage set. The rest are in the MCP tools reference.

When should you use grep?

Grep wins when the question is "find this string."

Code is parsed locally across about 40 languages, mostly with tree-sitter grammars. The model you already use in Claude Code reads docs and PDFs. There is no telemetry.

The installer replaces or appends only its own graphify section and leaves the rest of CLAUDE.md alone. graphify claude uninstall removes the Claude Code pieces. graphify uninstall removes every platform at once. It also removes the graphify section from CLAUDE.md, and deletes that file only if graphify created it. graphify uninstall --purge also deletes graphify-out/.

How do you install it?

bash
uv tool install graphifyy
graphify install

Then open the repo in Claude Code and run /graphify .. For the full Claude Code MCP setup, including claude mcp add, scopes, and .mcp.json, see Claude Code MCP: how to add servers and which ones to use.

Use Graphify in your agent

Add Graphify to ChatGPT, Claude, Cursor, Grok Bot and more in one click.

Try Graphify now.

Try for free