DEV Community

Igor Ganapolsky
Igor Ganapolsky

Posted on

Your AI agent forgets your repo every session. Give the repo a brain.

84% of developers now use or plan to use AI coding tools. Only about a third fully trust the output — and that trust has been falling since 2023. The usual explanations are hallucination and skill. I think a bigger, quieter one is this: the agent is amnesiac, and we've accepted it as the cost of doing business.

The tax you're already paying

Every new agent session starts from zero. It doesn't remember the approach your team rejected last week, the migration that took down staging last month, or the rule you corrected three PRs ago. So it proposes them again — and you spend your attention correcting the same things on a loop.

CLAUDE.md (and AGENTS.md, .cursorrules, and friends) was supposed to fix this. In practice it's a suggestion the model can skim or ignore, and on a long session your carefully written rules get crowded out of the context window entirely. Meanwhile the real institutional memory of your codebase lives in people's heads and in closed PR threads — exactly where an agent can't reach it.

This has a measurable price. Google's DORA research found that rising AI adoption correlated with higher bug rates and roughly 91% longer code-review time. Some of that is volume. But a real slice is repetition: the same corrections, re-litigated, because nothing the agent learned persisted past the session.

Give the repo a brain

The fix isn't a longer prompt. It's making the repo itself carry its memory.

ThumbGate (github.com/IgorGanapolsky/ThumbGate) generates a context brain for your repository:

npx thumbgate brain --write    # -> .thumbgate/BRAIN.md
Enter fullscreen mode Exit fullscreen mode

.thumbgate/BRAIN.md is a single, versioned, agent-readable artifact that consolidates everything the agent should know before it acts:

# ThumbGate Context Brain
## What this codebase taught its agents (lessons)
- Force-pushing to main was rejected — use --force-with-lease on feature branches only
## Guardrails — do NOT repeat these (prevention rules)
- Never run DROP on production tables
## Active enforcement (gates)
- DROP.*production -> block
Enter fullscreen mode Exit fullscreen mode

Three things make it different from a prompt file:

  1. It's deterministic. The output only changes when the underlying memory changes, so BRAIN.md lives in git and you review it like any other file — no mystery drift.
  2. It's loaded before action. Add "Read .thumbgate/BRAIN.md first" to your CLAUDE.md / AGENTS.md, and every Claude Code, Codex, Cursor, or Gemini CLI session boots with your repo's institutional memory already in context.
  3. The guardrails are enforced, not suggested. ThumbGate also runs at the PreToolUse hook, so the hard rules in the brain (force-push to main, rm -rf outside the workdir, destructive migrations) are deterministically blocked before the tool call executes — no LLM on that path, nothing to jailbreak.

The same idea the SEO world now calls a "client brain" — persistent context an AI reads before doing the work — applied to engineering: the institutional memory that stops your coding agent from relearning the same lesson on your dime.

The honest version

A context brain doesn't make your agent smarter, and it won't fix a bad prompt. What it fixes is forgetting — the agent stops re-proposing the things your team already rejected, and the rules that actually matter get enforced instead of skimmed. It's deterministic, local-first, and MIT-licensed.

Your agent will keep forgetting at the start of every session. Your repo doesn't have to.

npx thumbgate brain --write
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/IgorGanapolsky/ThumbGate

What does your coding agent forget at the start of every session — and what would change if it didn't?

Top comments (1)

Collapse
 
hiper2d profile image
Aliaksei Zelianouski

BRAIN.md has the same failure mode you're describing for CLAUDE.md - it's a suggestion the model skims, and on a long session it gets crowded out of context the same way. What actually does the work is the part you buried: the PreToolUse hook. Deterministic block, no LLM on the path, nothing to jailbreak.