A long project with an AI agent: memory and external connections
Getting a few days of work done with an AI agent is easy. Running a project for months is a different problem entirely.
The problem is not context size, as people usually assume. The problem is that every new conversation starts from zero. You explain again why you made that particular decision three months ago, which path you tried and rejected, which trap you already fell into.
And more often you do not explain — because you do not remember either. The result is that the agent proposes, once more, the solution you rejected a year ago.
This article is about fixing that.
What code does not tell you
The first question: the agent can read the code, so what else does it need?
The answer: code shows what was done, but says nothing about why it was done that way.
An example. In my project the TypeScript version is pinned hard to 6.0.3, with no caret. You can see that in the code. But not why. Somebody decides the version is "outdated" and bumps it — and lint dies completely.
The reason is not in the code: the newer TypeScript is not yet compatible with the linting tooling. That is a decision, not code.
Here is what gets lost this way:
- Why this technology was chosen and which alternative was rejected
- Which path was tried and did not work
- Project-specific traps — mistakes eaten once already
- Constraints the user accepted deliberately
- Identifiers and settings in external systems
None of this is in the code, and none of it can be recovered from git history — a commit message usually records the "what", not the "why".
How to organise memory
The shape that worked for me is simple: one fact, one file, plus an index on top.
Every file opens with a little metadata:
---
name: project-notion-writer
description: CLI and skill for writing articles and saving them to Notion
type: project
---
`~/Projects/notion-writer` — saves an article in three languages to
Notion as a draft. Distribution is automatic...The index file gives each entry one line: a title, a link and a one-sentence hook. At the start of a conversation the agent sees only the index, and opens the specific file later.
This structure solves two problems at once. First, context does not fill up. Second, entries are easy to update, because each fact lives in its own file, unmixed with others.
I split facts into four types: about the user, instructions about how to work, projects, and pointers to external resources. The types are not arbitrary — they answer the question "when will this entry be needed?".
The most valuable entries are traps
If I could keep only one category, I would keep the traps.
A few real examples from my own projects:
"Do not enable this setting — it blocks certain functions." That one line saves me from a second day of debugging.
"The free tier allows only two active scenarios — so instead of a third we rebuilt the existing one." Without it, the wrong suggestion ("let's add another scenario") arrives every time.
"If these two date columns drift apart, the article publishes with the wrong date." That actually happened, and would have happened again unrecorded.
The rule: every time something breaks unexpectedly and you fix it, ask yourself — "will this recur?". If yes, write one line.
External connections
Memory holds the past. But the agent also needs the present state — what is in the database, whether an automation is running, which task is open.
That is what MCP connections are for: the agent can reach an external system directly.
Mine genuinely work. I did not build my content distribution scenarios by hand — the agent connected to the automation platform, configured the modules and started them. I check data in the database the same way.
But there is an important detail worth saying up front: you should not connect everything.
Every connection takes context space and adds choices for the agent. More connections mean more distraction. I connected only the systems I genuinely need often; everything else I handle with an ordinary script.
The second detail is security. A connection gives the agent the right to write into a real system. Not granting direct write access to a production database should be a simple, hard rule.
Living with the context limit
In a long conversation context fills up regardless. The answer is not to fight it but to learn to live with it.
Three habits stuck for me.
First, write results to a file immediately. A conversation can be compacted; a file cannot. In a long task, flush every finished stage to disk.
Second, make state observable. My content queue is a plain markdown table: date, topic, status. Even if the conversation breaks, that file tells me exactly where we stopped next time. That is not memory, it is a checkpoint.
Third, break big work into pieces. Instead of "do everything", it is "do the first one, save it, move on". By the end of each piece the result is already somewhere safe.
What not to write down
Memory must not turn into a dumping ground, or it stops being useful.
I do not record:
- Things visible in the code. Folder structure, function names, the dependency list.
- Things in git history. "Fixed such-and-such bug" is already in the commit.
- Things that only matter in this conversation. A temp file path, a one-off command.
- Things that change often. Frozen volatile data quickly becomes a lie.
That last point matters: stale memory is worse than no memory, because the agent trusts it and makes a wrong decision. So when an entry names a file or a setting, verify it still exists before acting on it.
The practical result
After a few months the difference looks like this.
Without memory: every conversation opens with explaining context, the agent re-proposes rejected solutions, and traps you solved once get eaten again.
With memory: you name the topic and work starts immediately. The agent knows the project's constraints, remembers which path was rejected, and avoids the traps on its own.
This is not magic — it is ordinary documentation, in a form that is guaranteed to be read. And the main benefit is not really about the agent at all: six months from now, you will also be able to answer "why did I do it that way?".