{"slug": "my-project-has-a-memory-file-so-my-agent-doesn-t-reread-everything-it-never-my", "title": "My Project Has a Memory File So My Agent Doesn't Reread Everything. It Never Learned My Most-Used Script Existed.", "summary": "A developer discovered that their Claude Code agent's curated memory file, `key_facts.md`, was missing a critical script (`scripts/sync-main.sh`) and had buried another (`publish_devto.py`) under a retired script's entry, undermining the agent's ability to discover important files. The developer built a diff checker to verify the file's accuracy and found that the agent's reliance on a hand-curated summary instead of fresh directory scans had silently omitted load-bearing scripts for months.", "body_md": "I run a small side project where a Claude Code session publishes to DEV.to twice a day on a schedule, with no human reading along in real time. To keep each run cheap, it doesn't reread the whole repo from scratch every time — it reads `docs/project_notes/key_facts.md`\n\n, a hand-curated table of \"what each file does,\" and trusts it. That's the whole point of the file: a distilled summary instead of a fresh `ls`\n\nand a dozen `Read`\n\ncalls every run.\n\nThis morning I was scrolling dev.to's trending feed for source material and hit a post about an agent deliberately built to forget things on purpose, with the author spending two days proving the forgetting didn't lose anything important. It made me realize I'd never done the mirror check on my own setup. My project has an informal version of the same idea — three short, curated files (`bugs.md`\n\n, `decisions.md`\n\n, `key_facts.md`\n\n) that are supposed to stay small and trustworthy while the real work log (`issues.md`\n\n) grows without limit underneath them. Nobody had ever verified the curated files were actually still accurate. I decided to check the easiest one first: does `key_facts.md`\n\n's \"Project Files\" table still match what's on disk?\n\nNothing clever — walk the directories that hold scripts, pull every backticked filename out of the markdown, diff the two lists.\n\n```\nROOT = pathlib.Path(__file__).resolve().parent.parent\nKEY_FACTS = ROOT / \"docs\" / \"project_notes\" / \"key_facts.md\"\nTRACKED_DIRS = [ROOT, ROOT / \"scripts\", ROOT / \"hooks\"]\nEXTS = (\".py\", \".sh\")\n\ndef real_files():\n    found = []\n    for d in TRACKED_DIRS:\n        if not d.exists():\n            continue\n        for p in d.iterdir():\n            if p.is_file() and p.suffix in EXTS:\n                found.append(p.relative_to(ROOT).as_posix())\n    return sorted(found)\n\ndef documented_files():\n    text = KEY_FACTS.read_text()\n    return set(re.findall(r\"`([\\w./-]+\\.(?:py|sh))`\", text))\n\ndef main():\n    missing = [f for f in real_files() if f not in documented_files()]\n    if missing:\n        print(\"key_facts.md's Project Files table is missing:\")\n        for f in missing:\n            print(f\"  - {f}\")\n        sys.exit(1)\n```\n\nFirst run:\n\n```\nkey_facts.md's Project Files table is missing:\n  - scripts/sync-main.sh\n```\n\n`scripts/sync-main.sh`\n\nis not a minor file. It's the script that recovers from a detached-HEAD state at the start of nearly every scheduled run in this project — it's been load-bearing since the day it was written, referenced repeatedly in `bugs.md`\n\n. It had simply never been added to the one file whose entire job is \"list what the scripts in this repo do.\"\n\nI expected the same script to flag `publish_devto.py`\n\n— the script the daily publishing task actually shells out to every single run. It didn't. I went and grepped the raw markdown to see why, assuming a bug in my regex.\n\nThere was no bug. `publish_devto.py`\n\nis in the file — once, as a parenthetical inside the row for a different, already-deleted script:\n\n```\n| `article_draft.md` | Source for DEV.to article (published 2026-06-21) —\n`post_article.py`, the script that posted it, was removed 2026-07-16 as a\nsuperseded duplicate of `publish_devto.py` |\n```\n\nMy checker does a string-presence test: is this filename anywhere in backticks in the document? By that test, `publish_devto.py`\n\nis documented. But an agent skimming the table for \"what publishes my articles\" would never find this row — it's filed under the retired script it replaced, not under its own name. Presence isn't discoverability. I gave it its own row.\n\nWhile fixing the table I looked for one more candidate: `hooks/prepare-commit-msg`\n\n, a git hook referenced several times in `bugs.md`\n\nfor a silent-failure bug I'd fixed weeks earlier. My script never flagged it, and this time it actually was a bug — in the checker, not the docs. Git hook filenames have no extension (`prepare-commit-msg`\n\n, not `prepare-commit-msg.sh`\n\n), and my `EXTS = (\".py\", \".sh\")`\n\nfilter walked straight past it without ever looking.\n\n```\n# hooks/ files are named by git, not chosen by us — no extension convention\n# to filter on, so track them unconditionally instead of by suffix.\nTRACKED = [(ROOT, (\".py\", \".sh\")), (ROOT / \"scripts\", (\".py\", \".sh\")), (ROOT / \"hooks\", None)]\n\ndef real_files():\n    found = []\n    for d, exts in TRACKED:\n        if not d.exists():\n            continue\n        for p in d.iterdir():\n            if p.is_file() and (exts is None or p.suffix in exts):\n                found.append(p.relative_to(ROOT).as_posix())\n    return sorted(found)\n```\n\nWith that fixed, plus a row for `hooks/prepare-commit-msg`\n\nand `scripts/sync-main.sh`\n\nin `key_facts.md`\n\n, a clean run:\n\n```\nkey_facts.md is in sync with repo scripts.\n```\n\nEvery scheduled run in this project has one job that touches the memory system: append a new entry to `issues.md`\n\n. Nothing in the loop ever asks \"does the *curated* summary still match reality?\" — that direction only runs one way, raw log growing, distilled files sitting untouched unless something happens to go visibly wrong first. `scripts/sync-main.sh`\n\nand `hooks/prepare-commit-msg`\n\nweren't hidden on purpose. They were added on days when the priority was \"fix the bug,\" and updating a documentation table wasn't part of the definition of done for either fix.\n\nThe dev.to post that started this used two days of testing to prove that what its agent forgot on purpose was safe to lose. My problem was the opposite shape: nothing was forgotten on purpose, things just never got remembered in the first place, because remembering was nobody's job. A distilled memory file doesn't drift because someone decided to prune it — it drifts because writing to it isn't wired into the habit of changing the thing it describes. The forgetting-on-purpose agent earns its trust by testing the forgetting. My curated files were going to keep earning trust by accident until something actually broke because of a missing row, which is a worse way to find out.\n\nThe check is nine lines shorter than this article and it isn't hooked into anything yet — no pre-commit hook, no CI, just a script I now know to run before I trust the table again. That's the honest state of it: a tripwire, not a guarantee. But it's a tripwire that already found two real gaps and one bug in itself on its first two runs, which is a better hit rate than the zero checks that existed before it.", "url": "https://wpnews.pro/news/my-project-has-a-memory-file-so-my-agent-doesn-t-reread-everything-it-never-my", "canonical_source": "https://dev.to/enjoy_kumawat/my-project-has-a-memory-file-so-my-agent-doesnt-reread-everything-it-never-learned-my-most-used-3hgj", "published_at": "2026-07-25 03:37:16+00:00", "updated_at": "2026-07-25 04:28:24.460746+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "large-language-models"], "entities": ["Claude Code", "DEV.to"], "alternates": {"html": "https://wpnews.pro/news/my-project-has-a-memory-file-so-my-agent-doesn-t-reread-everything-it-never-my", "markdown": "https://wpnews.pro/news/my-project-has-a-memory-file-so-my-agent-doesn-t-reread-everything-it-never-my.md", "text": "https://wpnews.pro/news/my-project-has-a-memory-file-so-my-agent-doesn-t-reread-everything-it-never-my.txt", "jsonld": "https://wpnews.pro/news/my-project-has-a-memory-file-so-my-agent-doesn-t-reread-everything-it-never-my.jsonld"}}