Dev48
Language
  • About
  • Services
  • Industries
  • Technologies
  • Articles
  • Contacts
Book a call
    Home/Articles/Your coding agent can read the code give it the history with relate by neo4j
Dev48
info@dev48.org+375 29 320-40-96WhatsApp@isky_by

© 2026 · All rights reserved.

Your Coding Agent Can Read the Code. Give It the History with Relate by Neo4j

Source: Neo4j Graph Intelligence Platform•November 19, 2026 at 02:04 AM

Your Coding Agent Can Read the Code. Give It the History with Relate by Neo4j

Load a repository’s git history into a graph with Relate’s git-to-graph extension, serve it read-only, and see what a coding agent finds with it that it cannot find in the source tree. In a popular open source codebase, security/api_key.py has… Read more →

Load a repository’s git history into a graph with Relate’s git-to-graph extension, serve it read-only, and see what a coding agent finds with it that it cannot find in the source tree.

In a popular open source codebase, security/api_key.py has been changed in 28 commits. In 18 of them oauth2.py changed too. http.py changed in 17, and open_id_connect_url.py in 16. None of those four modules imports another so nothing obvious inapi_key.py points you at the other three files.

The history is clear about why. Each time someone added a behavior to one security scheme, they added it to all of them: auto_error in #134, description in #1757, the 401 status code in #13786, WebSocket support in #10147.

We asked three coding agents what else they would need to change before adding a constructor argument to APIKeyHeader. With only the source tree to read, none of them named those three modules. With the repository’s history loaded into a graph, all three did.

This post shows how to build that graph with Relate’s git-to-graph extension, what to ask it, and what changed when Codex, OpenCode and Pi could query it.

Relate: The agent native database

Relate is an open-source graph database built for AI agents to use directly. It is embedded: one binary, no server to deploy and no signup, and a whole database is a single .rl file on your machine that your agent queries in Cypher.

“Agent-native” means the pieces an agent needs come with it. relate skill install gives a coding agent a skill that documents the CLI, its Cypher dialect and includes a catalog of ready-made queries. relate serve — mcp exposes any database as MCP tools, and --read-only makes it refuse every write.

Relate extensions can be used to load outside data into the graph. This post uses two of them, for a repository’s history and fs-to-graph for its working tree.

Build the graph: two commands, about 20 seconds

git-to-graph reads a checkout’s commit history. fs-to-graph reads its working tree. Both write into the same Relate store, so one graph holds what the code is and how it got there.

On FastAPI (8,102 commits from December 2018 to November 2026) the history import took 4.6 seconds and the file import 14 seconds. The store is one 30 MB file; the clone it came from is 101 MB. Running the history import again is safe: it merges, so a second run left the same 48,322 co-change edges.

Two details matter later:

  • Paths include the directory you imported. We ran the importers from the parent directory, so the package file is fastapi/fastapi/routing.py.
  • Raise the content cap for large files. fs-to-graph stores file text up to 64 KB by default. FastAPI’s routing.py is 260 KB and applications.py is 185 KB, so the default left the two most-edited files without text. The --max-content-bytes 400000 flag above covers every Python file in the repository.

Three questions before an edit

A CO_CHANGED relationship joins two files that appeared in the same commit, and its count is the number of commits where this pattern occured. That one relationship answers the first question an agent should ask before it edits a file.

What else will I need to touch?

For fastapi/fastapi/security/api_key.py:

For fastapi/fastapi/routing.py, a 6,552-line file with 193 commits, the top of the list is applications.py (58), dependencies/utils.py (47) and openapi/utils.py (39). A third of all commits to routing.py also changed applications.py.

Has someone made this kind of change before?

Counts say which files move together. Earlier commits say what a change of this kind looked like. This query finds commits on a file whose subject matches a term, and lists what else each one touched:

With $path set to api_key.py and $term to security, four of the five rows touched exactly the same three source files:

  • 1884325c (2026-10-18) — Add WebSocket support to security dependencies (#10147). Source files: open_id_connect_url.py, oauth2.py, http.py. Tests: 3.
  • 51ad909f (2025-11-24) — Use 401 status code in security classes when credentials… Source files: open_id_connect_url.py, oauth2.py, http.py. Tests: 23.
  • 3b2e8919 (2021-07-29) — Add description parameter to all the security scheme classes… Source files: open_id_connect_url.py, oauth2.py, http.py. Tests: 11.
  • fad3a9e1 (2019-04-03) — Add auto_error to security utils (#134). Source files: open_id_connect_url.py, oauth2.py, http.py. Tests: 10.

That is a template for the change: the description commit is an earlier constructor argument, and it shows which files and how many tests came with it.

Who should review it?

For routing.py and applications.py:

The last_touch column earns its place. Ranked by commits alone, the second reviewer is someone whose last change to these files was in 2019. Two people lower in the list touched them within the last year or so.

What reading the code does not show

The security modules are not a one-off. Because fs-to-graph puts each file’s text on the same node as its history, one query can ask for files that change together although neither one’s text names the other:

Inside the fastapi/ package, 126 pairs of files have changed together five or more times. For 42 of them, a third, this query finds no reference in either direction. The check is a name match on file text, not an import graph, so treat the number as approximate. It is still a list no amount of following imports would produce.

Hand it to an agent

Relate can serve a store over MCP, in read-only mode:

The server exposes two tools, read_cypher and get_schema. Sending MATCH (n:Person) DETACH DELETE n to read_cypher comes back as a tool error and leaves the store unchanged:

For Codex, add the server to ~/.codex/config.toml:

For OpenCode, add it to ~/.config/opencode/opencode.json:

Pi reached the same store through the relate command line, also read-only:

For all three, relate skill install --agent <name> adds a skill that includes a catalog of ready-made history queries, so the agent does not start from an empty page.

Here is one of the read_cypher calls Codex made on the security task. The prompt told it to use the graph but did not supply any queries. The engine answered in 0.3 ms:

The comparison

We gave Codex 0.167.1, OpenCode 2.2.7 and Pi 1.5.2 the same two tasks, all on the same model (gpt-6.1-sol, medium reasoning). Each agent ran in a fresh container.

  • Tasks. Add an optional constructor argument to APIKeyHeader, and add a keyword argument to APIRouter.add_api_route. In both cases the agent was told not to edit anything and to brief us first: which other files will change, which tests to run, and who should review.
  • Code only. The agent has the FastAPI checkout with its .git directory removed, and its usual search and read tools.
  • With the graph. The same checkout, also without .git, plus the graph. Its only source of history is Relate.

Here is what each briefing contained across the 12 sessions:

Three things stand out:

Code is enough for tests, and for files an import makes visible. Every agent in both arms named the same core tests; the code-only agents got there by reading the test files. Every agent found applications.py, which imports routing.

Code is not enough for files that leaves no reference. No code-only briefing mentions any of the three sibling security modules. The graph-backed agents did, and qualified it sensibly. OpenCode wrote that the three modules “co-changed with api_key.py 17, 18, and 16 times respectively” and should be inspected for API consistency, “not automatic edits”. Codex added: “Both previous additions of description and auto_error changed all four modules.”

Code cannot say who has worked on a file. The code-only agents found the project’s maintainer in docs/en/docs/management.md and stopped there, and they said so. Codex: “I cannot identify a routing specialist or recent contributor to these methods from this checkout alone.” Pi: “Without history or explicit component ownership, I cannot identify recent maintainers of this particular code.” With the graph, all three named people by what they had changed, such as the author of the earlier description argument.

How it works

git-to-graph makes one git log call for the whole history, builds the plan in memory, and writes it in six batched MERGE phases: people, commits, files, then the three relationship types. It creates the range indexes before writing and the full-text index on commit subjects after.

The extension itself is small because it does not own the database. It is a child process that talks to the Relate host over MCP; the host owns the store, the transaction batching and the limits. If you want an importer for a source Relate does not cover, relate extension init <name> scaffolds one in shell, Python, TypeScript or Rust.

Two flags control the window. --since reads everything after a date, and --untilcloses the range, so an older era imports the same way every time:

Try it on your codebase

Everything in this post runs on your own repository in four steps: installrelate, load the history, start a read-only server, and tell your agent aboutit.

Install the binary and the two extensions:

Run the importers from the directory above your checkout, so that paths inthe graph start with the repository’s name. The first reads the commithistory and the second adds the working tree, both into one file:

Then give the graph to your agent. Install the skill, which carries thecatalog of history queries, and register the store as a read-only MCP server.

Any agent that speaks MCP over stdio can launch this command:

Now ask the question from the top of this post about a file you know well:

  • What else changes when this file changes?
  • Has anyone made this kind of change before?
  • Who has worked on it?

Resources

Relate

  • Relate by Neo4j home page
  • Install relate: the CLI on macOS, Linux or Windows
  • Source on GitHub

The extensions in this post

  • Import git history with git-to-graph: the graph it builds, its flags and its limits
  • Import a directory tree with fs-to-graph: file text, the content cap and the full-text index
  • Install and run an extension
  • Write an extension: scaffold an importer for a source relate does not cover

Giving the graph to an agent

  • Connect your agent to relate: the agent quickstart
  • Connect over MCP: config blocks for Claude Code, Cursor, Codex, OpenCode and others
  • Install the agent skill
  • Keep an agent safe: read-only opens, limits and backups
  • Agent-native by design: why the CLI and server behave the way they do

Going further

  • Answer codebase questions text search can’t: a cookbook recipe that builds on the same graph
  • The relate cookbook
  • Model Context Protocol

The repositories and tools used here

  • FastAPI, the repository the examples come from
  • Codex and OpenCode, two of the three agents
  • agent-lab, the container harness the agent sessions ran in
← All articles

What this article says

More in Software Development

All →
Agile Development: Develop Hardware Like Software
PTC

Agile Development: Develop Hardware Like Software

Mathcad API in Action
PTC

Mathcad API in Action

ABI Report: PTC Named Top Generative Design Solution
PTC

ABI Report: PTC Named Top Generative Design Solution

Social media governance: 9 risks and how to avoid them
Sprout Social

Social media governance: 9 risks and how to avoid them

Microsoft CEO Satya Nadella remains confident in Nvidia after Huang’s exitПресса
Microsoft

Microsoft CEO Satya Nadella remains confident in Nvidia after Huang’s exit

Java4Shell Remote Code Execution (RCE) Vulnerability - CVE-2026-114938
Elastic

Java4Shell Remote Code Execution (RCE) Vulnerability - CVE-2026-114938

More from Neo4j

The knowledge layer for enterprise AI: Domain Ontology
Neo4j

The knowledge layer for enterprise AI: Domain Ontology

Euler meets Codd
Neo4j

Euler meets Codd

Using Neo4j Change Data Capture to Orchestrate Agents
Neo4j

Using Neo4j Change Data Capture to Orchestrate Agents

Announcing the Relate by Neo4j Hackathon 2026: Build AI Agents on an Embedded Graph Database
Neo4j

Announcing the Relate by Neo4j Hackathon 2026: Build AI Agents on an Embedded Graph Database

Meet Relate by Neo4j: An Embedded Database for AI Agents
Neo4j

Meet Relate by Neo4j: An Embedded Database for AI Agents

Agentic GraphRAG and an explorer for your own stack
Neo4j

Agentic GraphRAG and an explorer for your own stack