Knowledge Graph Memory for AI Coding Assistants
Share

Knowledge graph memory for AI coding assistants sounds like something you'd need a research team for. It isn't. It means your notes know about each other: this decision replaced that one, this bug depends on that config, these two rules contradict. That's the whole idea, and I learned why it matters from my own blog pipeline this morning.
The morning my notes didn't know about each other
I run a small n8n workflow that drafts a blog post twice a week. On November 13 I threw one of its drafts away because it repeated a post I'd published ten days earlier. I wrote down the fix: "add this topic to the blocked list." I saved that note. Done.
Today the same workflow wrote the same post again.
The fix was real. It just lived in a file that the workflow had stopped reading weeks before. An older note of mine said exactly that: "the workflow reads its config from its own database, not from the JSON in the repo." Two true notes, saved two months apart, and nothing connected them. When I searched my memory for "blocked topics," I got the new note. The old one, the one that made the new one useless, didn't rank, because it doesn't contain the words "blocked topics" anywhere.
That's the gap a knowledge graph closes. Not more memory. Memory with links.
Why a flat list of notes isn't enough
Most memory for coding agents works like a search box. You save text, it gets turned into an embedding, and later the agent asks a question and gets back the notes that sound most similar. That works well for facts that stand alone: "we use pnpm," "the staging database is read-only on Fridays."
It breaks on the things that matter most in a real codebase, which are almost never standalone:
- Decisions that replaced other decisions. "Use Redis for sessions" and, three weeks later, "drop Redis, sessions go in Postgres." Both are in memory. Similarity search happily returns the old one, and your agent rebuilds the thing you already tore out. I wrote a whole post on why AI coding agents contradict earlier decisions, and this is most of the answer.
- Things that only make sense together. A bug note is half useless without the config it depends on.
- Rules that conflict. Two notes that disagree are worse than none, unless something marks them as disagreeing.
Similarity can't see any of that. "Supersedes" isn't a word that appears in either note. It's a fact about the two notes.
What a knowledge graph adds
A knowledge graph stores those facts explicitly. Each note is a node. Each link between two notes has a type that says how they relate. In ContextForge there are ten: related_to, references, depends_on, implements, extends, part_of, similar_to, derived_from, supersedes and contradicts.
Applied to my morning, it looks like this:
"Block topic X in the workflow" --depends_on--> "Workflow reads config from its DB, not the repo JSON"
"Dedupe reads live published posts" --supersedes--> "Dedupe reads articles/*.md"
With the first link in place, a search for blocked topics brings back both notes, and the second one tells the agent where the change actually has to go.
That's what the links do at query time in ContextForge. When the agent searches, results that are linked to each other get a boost, and the top results pull in their linked neighbours even when those neighbours wouldn't have scored high enough on their own. The agent can also ask directly: "what's connected to the session-storage decision?" and get the list, with the link types, from memory_list_relationships.
How the links get made
Here's the part most posts about knowledge graphs skip: someone has to make the links.
In ContextForge, links get created in three ways:
- You ask your agent. "The Redis removal supersedes the old session decision, link them." The agent calls
memory_relatewith the two items and the type. This is how I make most of mine, usually right after a decision, while the context is still in the session. - From the dashboard. Open an item, go to Related Items, click Link, pick the target and the type. Useful for cleaning up after the fact.
- By importing a graph you already have. If you've been using the MCP reference Knowledge Graph Memory Server, its JSONL export (entities and relations) imports directly. Entities become items, relations become links.
What ContextForge does not do today is guess the links for you. It won't read two notes and decide one supersedes the other. I've thought about it, and I'm wary of it for now: an automatic "supersedes" that's wrong hides a correct decision, which is exactly the failure I'm trying to prevent. So the graph is only as good as the links you or your agent bother to make.
Where it's worth it, and where it isn't
Honest version: for a lot of projects, you don't need a graph.
If you're working alone on something small, and your decisions rarely get reversed, plain search over well-written notes is enough. A good CLAUDE.md plus a handful of saved decisions will carry you far. Adding links would be ceremony.
The graph starts paying off when:
- Decisions get reversed. Any project old enough to have changed its mind.
supersedesis the single most useful link type I have. - More than one agent or person writes to the same memory. Two sessions saving conflicting rules is common, and
contradictsat least makes the conflict visible instead of random. - Notes reference each other by meaning, not by words. Like my workflow notes this morning.
And the costs are real. You have to make the links, which is one more sentence to your agent but still a habit you need to build. And there's no visual graph map in the dashboard; you see links per item, in its Related Items list, and as "Linked to" badges in the item list. If you were hoping to stare at a constellation of your project, that's not what this is.
If you want to try it
The cheapest test: next time you reverse a decision, don't just save the new one. Tell your agent to link it to the old one with supersedes. Then, a week later, ask about that topic and see which note comes back first.
ContextForge works with Claude Code, Cursor, GitHub Copilot, Claude Desktop and Windsurf through MCP. Install for Claude Code:
claude mcp add contextforge -e CONTEXTFORGE_API_KEY=<key> -- npx -y contextforge-mcp
There's a free tier that's enough to find out whether links change how your agent answers. The knowledge graph docs list every link type with examples. And if you're still deciding where your memory should live at all, I wrote about what self-hosting it actually takes, including the part where ContextForge isn't the right fit.
I'll keep adding links to my own pipeline notes. After this morning, the first one is obvious.
Share this article


