Code graph example
Context
“Where is this function, and who calls it?” is a question about structure, not about reading prose.
The problem
Without a map, the agent opens file after file until it finds the answer. On a large repo that search is most of the chat. On a small repo the map costs more to build than the searches it saves.
What you do
When the repo is large enough, you install a code graph on your machine, index the repo locally, and add one line telling the agent to ask the graph before it opens whole files. The setup prompt does not do this step.
What this achieves
A location question comes back as symbols and calls. The agent then opens the few files that matter, instead of a tour of the tree.
Who reads it
Cursor reads .cursor/mcp.json in the project, or ~/.cursor/mcp.json for every project. Claude Code reads .mcp.json in the project. The agent then calls the graph's tools instead of opening files to answer a location question.
What it is for
A code graph indexes functions, imports, and calls so the agent can ask where something lives and who calls it. That avoids reading a pile of files to answer a structural question.
On a small repo the index is more work than the searches it saves. Set it up when location questions keep pulling in whole files. Skip it on a new project with a handful of folders.
The GitHub links below are the install path. The sample config is what you commit after install, so the next person does not have to rediscover the command.
What goes in
- The MCP server entry in .cursor/mcp.json and, if you use Claude Code, the same entry in .mcp.json.
- One line in AGENTS.md telling the agent to ask the graph before opening whole files for a location question.
Sample
.cursor/mcp.json
{
"mcpServers": {
"gitnexus": {
"command": "npx",
"args": ["-y", "gitnexus@latest", "mcp"]
}
}
}.mcp.json
{
"mcpServers": {
"gitnexus": {
"command": "npx",
"args": ["-y", "gitnexus@latest", "mcp"]
}
}
}AGENTS.md (one line to add)
For "where is this" or "who calls this", ask the code graph if one is configured. Do not open whole files to answer a location question.Install from GitHub
These are local tools. Pick one, open its repository, and follow the README there. The sample config below is the manual form, so a team can commit it after the tool is installed.
- GitNexus
Indexes this repo on your machine and exposes the graph to Cursor and Claude Code. In the repo, run npx gitnexus analyze, then npx gitnexus setup. Setup writes the editor config. Read the README on GitHub before you run it. Commands change.
- codebase-memory-mcp
A local program that builds a graph of functions, calls, and routes. No API key, and the code stays on the machine. The GitHub README has the install for macOS, Linux, and Windows. Read that page before you run an install command.
What stays out
- A graph on a tiny repo, installed by the setup prompt. This step stays manual.
- A claim that the graph cuts token use by a fixed percent. It depends on the repo and the question.
- Source code uploaded to a service you have not reviewed. Prefer a tool that indexes on the machine.
Before launch, run the Vibe Coding Security Checklist. These files do not replace that audit. Open the Vibe Coding Security Checklist.
