I Made My AI Coding Agent Forget on Purpose.
Why persistent memory needs deletion, not just better organization.Gemini generated image _ robot organizes memoriesAI coding agents now have persistent memory.md file pointing to more files, and it is wonderful until it is not. I worked with Claude Code every day for four months, on one production…
Why persistent memory needs deletion, not just better organization.Gemini generated image _ robot organizes memoriesAI coding agents now have persistent memory.md file pointing to more files, and it is wonderful until it is not. I worked with Claude Code every day for four months, on one production codebase.In that time, the agent’s memory folder grew to 150+ files, about 127,000 words. One single memory file held 40,000 words of old test logs (40K even after all the memory optimization requests and skills for it, really, Claude?What a disappointment, in more than 100 dated entries. That is the size of a short novel. Only the newest entry mattered. Every session read the whole novel before adding one more page until nothing makes sense anymore.My agent was not getting smarter with age. It was getting haunted.This is the story of why I built /forget,a small, installable skill that gives an AI agent a trash can, and what four months of agent memory taught me about why forgetting matters as much as remembering.A quick note of gratitude: these memories came from real enterprise work, my employer allows agentic development on production projects, with MCP connected to our ticketing system, and that trust made this whole experiment possible.TL;DRAgent memory grows fast, while mine is 150+ files and ~127,000 words in four months of normal work.Old memories keep sounding true after they stop being true. My agent trusted stale status notes, almost re-fixed closed bugs, and treated abandoned work as active work.About a quarter of my memory entries were dead ends: fixed, refuted, rejected, or on hold. Merging and tidying memory is not enough. Some memories must simply go, but only a human can say which ones.So I built /forget,name a dead effort, review a short list, confirm once. Files move to a trash folder. Anything cut from a surviving file is copied word-for-word into a manifest first. Nothing is ever deleted, and every forget can be undone.Memory grows faster than you thinkThe workload was ordinary. That is what makes the numbers interesting. One long-running production system. A months-long chain of bug fixes and refactors. Several sessions a day. Each session did exactly what good agent memory should do: it wrote down lessons, root causes, tried approaches, and current status.Four months later, I counted what was in the folder:150+ memory files, written over about 16 weeks.About a quarter of the entries carried a dead-end label in the title alone: fixed (10), refuted (7), deferred (6), rejected (4), plus a few marked as stale, paused, or no-go.One “current test status” file had grown, entry by entry, to 40,000 words. Only the last entry was current.Two memories disagreed about a piece of infrastructure. The index note said, word for word: “ask user which is current.” (Oh dear, now me and Claude need more tools to remember for both of us).Here is the trap. None of this was a mistake. Every entry was correct on the day it was written. But the next session reads old notes as if they describe today, regardless if yesterdays work.Four ways old memories hurt an agent:The agent gets stuck between two truths. Two memories described the same infrastructure in two different ways. A fresh session reading both either stops to ask or quietly picks one, and often picks wrong. I had to fix it by hand, comparing dates like a detective.Disproven theories +POCs come back. Seven of my memories exist only to say: this theory/POC was tested and it is wrong. That is useful, when the agent reads the verdict. But an agent that skims the old hypothesis and misses the verdict will happily bring back a theory we spent a full day burying. One memory’s entire job is to say “X does NOT cause Y, we proved it three ways,” because agents kept rebuilding the false claim from older notes(now I was about to say forbidden words).Status notes turn into zombies. A “current open bugs” memory went quiet for two months while the real status moved on. Any session that trusted it believed two bugs were still open. Both had shipped fixes. An agent could have “fixed” them again, on top of the real fix(new skill is needed here for more organization).Abandoned work looks like active work. This one pushed me to build the skill. When you drop an approach, a library you rejected, a feature you shelved, a design that lost the argument, the memories of that effort stay behind, written in the confident voice of live work. The next session cannot tell dead work from work-in-progress. It assumes the discarded effort is still real and builds on it. Or worse: it assumes the work is finished, because a memory describes it in the past tense(that burnt too many tokens and even made Claude trigger a “git historian” agent to investigate while I was blaming myself about not telling Claude that the idea was discarded).Blessed are the forgetful, for they get the better even of their blunders.- Friedrich NietzscheCleaning is not forgettingThe standard answer is memory consolidation: merge duplicates, sharpen what lasts, retire what is dated. I run it. It helps. That 40,000-word log went back to a sane size that way.But consolidation has a built-in habit: it keeps things. It tidies the attic. It never takes anything to the curb.And here is the part that took me a while to accept: not every dead-end memory is garbage. A “this was disproven” note is a gravestone, it stops the agent from digging the theory up again. Those must stay. The reason a design was rejected is worth keeping too. But the play-by-play of the dead effort itself? The stale status files? The plans that lost(specially plugin create ones)? Every one of them is a trap for the next session.So I built skill/forget/forget does one thing, carefully. You name the dead effort. The skill searches the current project's memory three ways: the index, keyword variants, then actual reading and judgment, because exact text search misses rephrased notes.Then it shows you a short list: which files are entirely about the dead effort, which only mention it, and which look important enough to deserve a warning tag. You confirm once. Then it:moves whole-match files into a .trash/ folder and renames them, so no future session will ever load them, nothing is deleted;copies every line it cuts from surviving files into a manifest, word for word, before cutting, so every forget can be fully undone from the trash alone;updates the memory index and removes links that now point at nothing;and ends with an honest report: what it removed, how to restore it, and which memory places it cannot reach. Pretending you forgot something you did not is worse than remembering it.The idea underneath is simple. An agent should work from memories that describe the world as it is now, not as it was during efforts you already abandoned. And the human decides which is which.One detail that mattered in practice: the skill does not care who wrote a memory, which plugin integrations, or whatever is written to a markdown file; it will read it and evaluate it against the concern we need to forget.How do you test a skill made of words?This skill is not code. It is a prompt. There is no function to unit-test, the “program” is whatever a model does when it reads the instructions cold. So we tested it like a procedure, in four layers:A test folder with planted traps. Five fake memories about an invented, already-dead effort. We seeded the hard cases on purpose: a file that mixes dead facts with facts that must survive, a healthy memory that links to a soon-to-be-trashed one, and an innocent bystander file that must not move at all.A round trip with a strict pass rule. Run the forget flow. Check ten written assertions: right files trashed, only the right lines cut, index consistent, nothing touched outside the sandbox. Then the step that really matters: restore everything using only the trash manifest, and compare every file, byte by byte, against the original. Not “looks right.” Identical. If any text cannot come back from the trash alone, the test itself calls that a critical bug.Reviews that assume the worst. Every piece was checked by a separate reviewer agent, told to distrust the builder’s report and verify claims against the actual changes. A final reviewer was told to attack the skill as a prompt: can the trigger fire by accident? Can a step be talked around? Can the confirm gate be skipped? That review found the first critical flaw — the manifest logged that lines were removed but kept no copy of them.A cold test. The decisive layer. Hand the shipped text to a fresh agent that knows nothing about how it was built, and watch it follow the instructions with no one explaining anything.That last layer paid for itself immediately. Our warm test, run by an agent that had watched the skill being written, passed on the first try. The cold test failed. The skill told its reader to reword an index line after a partial edit, but the manifest had no place to save the original wording. One file could never be restored from the trash alone. The warm test had “passed” only because its tester restored from a reference copy that a real user would never have.The fix was one manifest block and two sentences. The lesson was bigger: after every wording change, we ran a fresh round trip and a fresh cold test. With prompts, the only thing that ships is the text.If your agent skill makes a safety promise, test it with an agent that knows nothing. The promise has to live entirely in the shipped words.Try itThe skill is open source, a single-file Claude Code plugin: github.com/hadeelsharaf/claude-forget. Install it. The next time you abandon an approach, spend the thirty seconds: name the effort, read the list, confirm. Your future sessions will work from your decisions, not your detours.Agents do not just need to remember well. They need to forget on purpose.This story is published on Generative AI. Connect with us on LinkedIn and follow Zeniteq to stay in the loop with the latest AI stories.Subscribe to our newsletter and YouTube channel to stay updated with the latest news and updates on generative AI. Let’s shape the future of AI together!I Made My AI Coding Agent Forget on Purpose. was originally published in Generative AI on Medium, where people are continuing the conversation by highlighting and responding to this story.Source: Generative AI Pub — Published — Category: Image AI