Last week I watched an AI coding agent make the exact same mistake for the third time.
It reintroduced a bug we’d already fixed, ignored a project convention we’d explained twice, and suggested an architecture decision we had explicitly rejected a few days earlier.
Nothing was “wrong” with the model.
It just had no memory.
That’s the part nobody tells you when you start using AI coding agents in real projects: they’re smart inside a session, but stateless across sessions. Close the tab, start a new task, switch repos, and a lot of the hard-won context is gone.
So you end up doing this over and over:
- re-explaining folder structure
- re-describing why you don’t use a certain library
- re-teaching the same bug fix
- re-listing all the project gotchas
That’s fine for a demo. It’s painful in production.
The real problem isn’t code generation
Most agent discussions focus on which model writes better code.
In practice, the bigger issue is often continuity.
A useful coding agent needs to remember things like:
- “We wrap all API calls in
safeRequest()” - “Don’t use local time here; this service must be UTC-only”
- “This auth middleware breaks on preview deployments”
- “We tried library X and replaced it with Y because of bundle size”
- “In this repo, migrations must be backward-compatible for one release”
That’s not just “context.” That’s working team knowledge.
And if it disappears between sessions, your agent keeps acting like a new hire on day one.
What most teams do instead
Usually, developers try one of these:
Put everything in README files
Good idea, but READMEs get stale fast.Keep giant prompt files
Works until they become long, repetitive, and impossible to maintain.Rely on the agent to scan the codebase every time
Better than nothing, but expensive and inconsistent. Also, code doesn’t explain why decisions were made.Accept the repetition
This is where a lot of teams land. It’s annoying, but it feels easier than building a memory layer.
If your needs are simple, a good AGENTS.md, project docs, and repo conventions may be enough. Not every team needs a separate memory system.
But once you’re juggling multiple repos, multiple agents, or recurring architectural gotchas, the lack of persistent memory starts costing real time.
What a persistent memory layer looks like
The missing piece is a system that stores knowledge outside the chat session, then gives it back to the agent when relevant.
Something like this:
[Code / chats / docs / bugs]
|
v
[Knowledge extraction]
|
v
[Structured memory / graph]
|
v
[Agent retrieves relevant context]
|
v
Better decisions next session
The key is that the memory shouldn’t just be raw logs.
It should capture:
- decisions
- patterns
- bug fixes
- gotchas
- dependencies
- relationships between concepts
That’s where a knowledge graph approach gets useful. Instead of storing random notes, you store connected knowledge: what uses what, what replaced what, what conflicts with what, what depends on what.
A simple example
Here’s the kind of thing you want an agent to remember automatically:
npm install -g @pekg/cli
pekg remember "In this project, use zod for runtime validation. We replaced yup because zod integrates better with our tRPC stack."
Then later, when your MCP-compatible agent is working in that repo, it can retrieve that decision instead of proposing yup again.
That’s the idea behind PeKG: a personal knowledge graph for AI coding agents.
It gives agents persistent memory across sessions and projects by storing decisions, patterns, fixes, and architecture knowledge in a searchable graph. It works with MCP-compatible agents like Claude Code, Cursor, Windsurf, Cline, Aider, and Roo Code.
A few things that matter in practice:
- BYOLLM: your agent does the reasoning; PeKG stores and retrieves knowledge
- Cross-project synthesis: learn something in Project A, reuse it in Project B
- Automatic compilation: raw notes and sources get turned into structured wiki-style knowledge
- Deep scan: extract knowledge from source code files
- Tiered knowledge: personal, team, shared, and public hive knowledge with trust scoring
That matters because a lot of useful engineering knowledge is not just “facts.” It’s accumulated judgment.
Why this matters more than people expect
Without memory, agents repeat effort.
With memory, they start compounding effort.
That changes the workflow:
- bug fixes become reusable knowledge
- architecture decisions stop disappearing into Slack
- project-specific gotchas get surfaced before mistakes happen
- patterns learned in one repo can help in another
And importantly, this doesn’t have to be all-or-nothing. You can still use docs, READMEs, and prompt files. A memory layer just gives your agent somewhere durable to put what it learns.
Try it yourself
If you’re already using an MCP-compatible coding agent, the easiest experiment is to give it persistent memory and see whether repeated explanations drop off after a week.
PeKG has a free tier: 100 articles, 5 projects, 1 user. If you want to test the idea, try https://app.pekg.ai. For MCP setup, check out https://pekg.ai/docs. And if you’re thinking about knowledge capture more broadly, see https://pekg.ai/hints.txt for 115 practical tips.
If PeKG isn’t the right fit, the broader takeaway still stands: don’t treat session memory as team memory. They are not the same thing.
Your model may be smart. But if it forgets every lesson by tomorrow, your team keeps paying to teach it the same things again.
How are you handling agent memory today: giant prompts, repo docs, MCP tools, or something else? Drop your approach below.
-- PeKG team
This post was created with AI assistance.
Top comments (0)