{"slug": "my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow", "title": "My AI Agent Writes Great Code and Forgets All of It by Tomorrow", "summary": "A developer built a lightweight markdown-based memory system for AI coding agents to solve the problem of agents forgetting context between sessions. The system uses four files in a `docs/project_notes/` directory—bugs.md, decisions.md, key_facts.md, and issues.md—with explicit triggers in the agent's instructions file to read and write knowledge. This approach prevents repeated debugging of the same issues, such as a DEV.to API 403 error caused by a missing User-Agent header.", "body_md": "Here's a conversation I had with my coding agent three times in one week:\n\nMe:The DEV.to API 403s us.\n\nAgent:Let me add a`User-Agent`\n\nheader — their bot filter rejects the default one.\n\nMe:Right. We figured that out on Monday. And Tuesday.\n\nThe agent was correct every time. It was also starting from zero every time. Monday's hard-won lesson — *dev.to blocks the default user agent* — evaporated the moment the session closed. Wednesday-me paid the same debugging tax as Monday-me.\n\nThis is the part of \"agents write code, but they don't remember\" that actually hurts. It's not that the model is dumb. Within a session it's sharp. The problem is that **every session is session one.** All the context you built — why a function is shaped weirdly, which approach you already tried and rejected, the username that has an underscore in one place and not another — is gone. You're not pair-programming with a senior dev. You're onboarding a brilliant amnesiac, daily.\n\nThe obvious fix is to dump everything into your instructions file (`CLAUDE.md`\n\n, `AGENTS.md`\n\n, whatever your tool reads). I tried. It rots fast:\n\n`.env`\n\n\") with A single flat file is a junk drawer. What I actually wanted was a small, *typed* memory — different kinds of knowledge in different places, each with a rule for when to read and when to write.\n\nI gave the project a `docs/project_notes/`\n\ndirectory. Four files, each one job:\n\n```\ndocs/project_notes/\n├── bugs.md        # known bugs → their solutions\n├── decisions.md   # why things are built the way they are (mini-ADRs)\n├── key_facts.md   # usernames, endpoints, file purposes, run commands\n└── issues.md      # work log, newest first\n```\n\nThat's it. No database, no vector store, no embedding pipeline. Markdown the human and the model both read.\n\nThe trick isn't the files — it's wiring *triggers* into the instructions file so the agent knows when to consult and update them. The entire memory protocol is four lines in `CLAUDE.md`\n\n:\n\n```\n## Project Memory System\n- Encountering an error → search `bugs.md` first\n- Proposing an architecture change → check `decisions.md` for conflicts\n- Need a username/endpoint/command → check `key_facts.md`\n- Completing a phase of work → log it in `issues.md`\n```\n\nNow the DEV.to 403 lives in `bugs.md`\n\nonce, as a fact, not a rediscovery:\n\n```\n### dev.to API returns 403 on every request\n**Cause:** dev.to rejects the default HTTP-client User-Agent (bot filter).\n**Fix:** send `User-Agent: Mozilla/5.0`. Applies to all /api/articles calls.\n```\n\nAnd the gotcha that bit me twice — same person, two usernames — lives in `key_facts.md`\n\n:\n\n```\n## Usernames\n- GitHub:  enjoykumawat      (no underscore)\n- DEV.to:  enjoy_kumawat     (with underscore)\n```\n\nThe next time the agent reaches for a username, it reads the fact instead of guessing and getting it half-right.\n\nReading is easy. The discipline is *writing*. A memory system only compounds if knowledge flows back in. So the single most important protocol is the last one: **when you finish a chunk of work, log it.** My `issues.md`\n\nis append-only, newest first:\n\n```\n### 2026-06-23 - DEV.to publisher + 403 fix\n- Status: Completed\n- Built reusable stdlib publisher. Root cause of the\n  intermittent 403 was the default User-Agent. Fixed with\n  a Mozilla UA + H1-strip on the markdown body.\n```\n\nThat one entry means future-me (and future-agent) gets the *outcome and the reason* for free. The work log is the difference between \"we have notes\" and \"we have memory.\"\n\n`decisions.md`\n\nreminds me Two failure modes to avoid, both learned the hard way:\n\n`x`\n\nto `y`\n\n\" is in the diff. Memory is for the `decisions.md`\n\nno longer reflects reality, the fix is a The whole system is four markdown files and four lines of protocol. No framework. The insight isn't technical — it's that an agent's memory has to live *outside* the agent, in artifacts that survive the session, with explicit rules for when to read and write them.\n\nYour agent doesn't need a bigger context window. It needs a place to write things down — and a habit of reading them back.", "url": "https://wpnews.pro/news/my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow", "canonical_source": "https://dev.to/enjoy_kumawat/my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow-32ec", "published_at": "2026-06-24 10:26:45+00:00", "updated_at": "2026-06-24 10:43:48.259812+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "large-language-models"], "entities": ["DEV.to", "GitHub", "CLAUDE.md", "AGENTS.md"], "alternates": {"html": "https://wpnews.pro/news/my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow", "markdown": "https://wpnews.pro/news/my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow.md", "text": "https://wpnews.pro/news/my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow.txt", "jsonld": "https://wpnews.pro/news/my-ai-agent-writes-great-code-and-forgets-all-of-it-by-tomorrow.jsonld"}}