Teach your coding agent to write down what it learns. Next session, it reads those notes and skips the mistake. No fine-tuning. No embeddings. Plain files.
Your agent calls an API. The call fails because the endpoint uses cursor-based pagination, not page offsets. You explain the fix. Two days later, a new session hits the same endpoint. The agent tries page offsets again.
The problem is not the model. Session memory dies with the session. CLAUDE.md is for instructions, not for accumulated discoveries. The agent needs a place to write what it learned and a habit of reading those notes before it starts work.
On failure-then-success, write what worked to a learnings file. On task start, read the relevant learnings first. Each file covers one topic. Each entry has a date and the specific detail that matters.
That file is five lines. It saves the agent (and you) from a failed request, a stack trace, a debugging cycle, and a second explanation. Every entry compounds.
The learnings files need a home the agent can read and write to across sessions. gcontext is an open-source MCP server that serves a folder of plain text files as persistent state.
The server exposes read_file, write_file, list_dir, and grep as MCP tools. Any MCP client can connect. The folder persists on disk. Push it to git and it persists across machines.
The agent needs one instruction. Add it to your CLAUDE.md, a skill, or your system prompt.
Before you start a task, read learnings/ via the gcontext MCP server for relevant notes. After you solve a non-obvious problem, write what you learned to learnings/topic.md.
That is the entire mechanism. The agent reads before it works. It writes after it discovers. The folder accumulates knowledge session by session. The agent uses list_dir to see what learnings exist and grep to find relevant entries.
On the next session, the agent hits the same API. This time it reads the learnings folder first. No failed request. No debugging. No second explanation.
After a few weeks, the learnings folder holds dozens of entries: API quirks, deployment gotchas, schema constraints, environment differences. Each one is a mistake the agent makes at most once.
You can ask the agent to do this review: "Review the learnings folder. Remove duplicates and delete entries that are no longer relevant."
You can read the memory in any editor. You can correct mistakes with a text edit. You can git diff what the agent added. No database to manage. No embeddings to regenerate.
When the agent writes something wrong, you open the file and fix it. Try that with a vector database or a fine-tuned model. Plain files give you full control over what the agent remembers.
An agent that writes down what it learns and reads those notes in future sessions. No fine-tuning or weight changes are involved. The agent stays the same; its context grows.
No. The agent's weights stay the same. It reads its own notes as context, the same way you read your own documentation.
Any MCP client: Claude Code, Cursor, Codex, Claude Desktop. The learnings folder lives behind an MCP server, so any tool that speaks the protocol can read and write to it.
Install gcontext. Add the learnings rule. Your agent remembers what it learns.