Memory for coding agents
Coding agents forget a repository between sessions. singularity keeps the changes they commit, and points the next session that starts a similar task to the closest one.
Abstract
An agent asked for the same kind of change twice starts from zero both times, and most of its turns go to finding places it has found before. singularity stores each change that a Claude Code, Codex or Hermes Agent session commits. When a new task starts, it points the agent to the stored change closest to it, without the diff, which git holds. It also lists the check scripts earlier sessions ran that are still on disk, and when the agent reads a stored commit in git, it adds the commands that commit's session ran. On fresh clones of chat-v2, with Claude Code's auto memory off, Opus cost 26% less with memory over 12 pairs of runs. Sonnet cost the same and passed 12 of 12 runs, against 10 of 12 without. The help came from the check scripts and the commands, not from the pointer. In daily use on markdownlint, an earlier hand-over that included the diff saved 6%, which is inside the noise.
- −26%
- cost, Opus on fresh clones
- 12 / 12
- Sonnet runs passed with memory, 10 / 12 without
- −6%
- cost in daily use, inside the noise
$ curl -fsSL https://raw.githubusercontent.com/pandacover/singularity/main/install.sh | sh
You need git. Setup asks before it changes anything.
1The same task, from zero
Ask a coding agent to add a setting to excalidraw, and it does. It reads the app state, searches for how other settings are stored, finds the menu, runs the tests, fails once on a flag and runs them again. Ask it for a second setting the next day and it does all of that again. Unless the agent keeps a memory of its own, nothing it learned about the codebase survives the session.
Figure 1 shows four real runs of one such task without memory. They spent 110 turns between them, most of them reading and searching, and all four made much the same change in the same places. A change like that, once committed, is what memory keeps.
Figure 1110 turns, one way through
A past change like your task
- Its commit, for git show
- What it was for, from its commit message
- Its files, as they are named today
- Check scripts earlier sessions ran
- The commands its session ran, on git show
2What memory keeps
When a session commits a change, memory records it. The record holds the task as the person wrote it, the files changed, the commands that ran, what failed and what fixed it, and whether the last test, typecheck, build or lint before the commit passed. It holds no code, because git has that. Memory stops handing over a change that was reverted or replaced.
It stores the change
It also notes whether the last check before the commit passed.
- The task, as the person wrote it
- The files it changed
- The commands that ran
- What failed, and what fixed it
It points to one
It hands over the commit and files of the stored change most like the new task, without the diff, and lists the check scripts earlier sessions ran.
Or later, mid-task
Reading a stored commit in git brings what git doesn't show, such as the commands its session ran. The agent can also ask.
singularity recall "make the build check pass"At task start the agent gets a pointer, not a diff: the past change's commit, the first line of its commit message, and its files as they are named today. It can read the change with git show, and it still writes every line itself. The pointer says that the names, values and details of the new task differ. Once a session, a short card follows. It lists the check scripts that earlier sessions ran before committing and that are still on disk, such as a screenshot or end-to-end script, with the pointed-to change's own scripts first.
When the agent reads a stored change in git, with git show or git log, memory adds what the commit doesn't hold: the commands its session ran, and the task when the commit message says too little. It never adds a diff or past mistakes. It adds each change once a session, and never one the session made itself. Setup also adds a note to the agent's instructions saying it can run singularity recall before work it may have done before.
3Picking the past change
A wrong pointer is worse than none, so memory picks one change or nothing. It has two ways to pick.
By words. Memory scores each stored change against the new task. The score combines how much of the change's words the new task holds with how alike the two are overall. Memory finds a change by its commit message, and by the request that asked for it only when the message says too little. Below 0.38 memory hands over nothing. It costs nothing and needs no model, but it misses a task put in other words. Codex, Gemini CLI, Droid and Hermes Agent pick this way.
By a model. In Claude Code, setup asks whether a model should pick. The default is Haiku, the cheapest, at about $0.002 a task on your Claude plan. You can choose Sonnet, Opus, another model by name, or none, which keeps word search. The model reads your task and the repository's stored changes, and picks one or none. It runs in a background hook, so the session never waits. The check scripts arrive at once, and the pointer reaches the agent with its next tool result, a few seconds in.
Figure 3 shows both on 62 real task starts. Finding changes by their commit message instead of also by their request cut wrong pointers from 6 to 1. Haiku handed over none wrong, and 10 right.
Figure 3Two ways to pick, and how often each points wrong
- Request and commit message wordsthe earlier word search6 wrong
- Commit message wordsword search today1 wrong
- Haikua model, in the background0 wrong, 10 right
- t01 heading-max-levelnew rulenothing stored yet
- t02 code-block-max-linesnew rulet01's change, 0.57
- t03 md024-ignore-caserule optiont01's change, 0.42
- t04 list-max-depthnew rulet01's change, 0.61
- t05 get-rulesone-offnothing, 0.34
- t06 rename-doc-srcupdatenothing, 0.35
- t07 link-url-schemenew rulet01's change, 0.42
- t08 todo-comments-examplelook-alikenothing, 0.34
- t09 md014-promptsrule optiont03's change, 0.49
- t10 ol-delimiter-stylenew rulet01's change, 0.47
- t11 circular-extendsone-offnothing, 0.33
- t12 no-empty-headingsnew rulet01's change, 0.53
4Results
On 2026-10-22 we gave Claude Code two tasks related to earlier work in chat-v2, an Electron app of ours. Every run started from a fresh clone with Claude Code's auto memory off, so the only memory of the repository was singularity's. Runs with memory had a copy of the memory our own sessions had built in chat-v2. Each one ran at the same time as a run without memory, on the same machine. Figure 4 shows each pair's cost with memory as a share of its cost without.
Figure 4Cost with memory, as a share of the cost without it
Opus cost 26% less with memory, and 10 of its 12 pairs were cheaper. Every Opus run passed, with memory and without. Sonnet cost the same, $3.50 with memory and $3.51 without, and passed 12 of 12 runs against 10 of 12. No task passed less often with memory.
The transcripts show where the help came from. Opus runs with memory reused the browser install that a past session had left on disk, wrote their check from that session's scripts, and tested the change in the running app. The two Sonnet runs that failed without memory committed a type error after trying npx tsc, which chat-v2 doesn't install. With memory, Sonnet ran bun run typecheck, and several runs got that command from what memory adds to git show. One task got a pointer at every start, to a weak match, and no run visibly used it.
Daily use on markdownlint tells a different story. Sonnet did 12 tasks in order, each in a fresh session, three times with memory and three times without, on an earlier version whose hand-over included the past change's diff. Cost fell 6% (95% interval −13% to +1%), which is inside the noise. A second run of the same passes, which also added notes when an agent ran git show, cost 1.9% less (−12% to +8%). There the earlier changes were in the repository's git history, and agents read them there with memory and without.
5Limitations
- It helps where git says too little. The help came from check scripts and commands that the repository doesn't hold. Where the past changes are in git and the agent reads them anyway, as on markdownlint, memory added little.
- One machine. The card lists only check scripts still on disk, so on a new machine it would list none. The chat-v2 runs were on the machine where the past sessions ran.
- Agents with a memory of their own. The runs had Claude Code's auto memory off. An agent that keeps its own notes on a repository may already know what memory tells it.
- Measured before the latest changes. The chat-v2 runs picked by word search, before the model's pick, and their notes on
git showstill listed past mistakes. The markdownlint runs had a hand-over with the diff. - A model's pick comes a step in. It reaches the agent with its first tool result after the pick, a few seconds in, so the agent starts without it. We judged picking on 62 real task starts, not on paid runs.
- Sonnet rarely asks. Across 177 sessions with the recall note on markdownlint, excalidraw and validator, Sonnet ran
singularity recallon its own once, and in its 12 runs on chat-v2 it never did. Opus ran it in 5 of its 12 runs on chat-v2. - Small samples. Twelve pairs of runs per model on chat-v2, over two tasks in one repository. Three passes of 12 tasks on markdownlint.
- Agents change. Claude Code updates itself, and each version behaves a little differently. We compare runs only within one version.
6Rules it keeps
Figure 5 draws memory as layers, from your machine up to your agent. Each layer keeps one rule.
Figure 5Layer by layer, from your machine up to your agent
- Your agentIt gets a pointer, not a diff, and writes every line itself.
- HooksThey never break a session, and take about 0.1 s a call.
- MemoryIt keeps records of commits. The code stays in git.
- Your sessionsMemory stores each commit, and whether its check passed.
- Your machineRecords stay here. In Claude Code, a model picks unless you say no.
7Use it
One command installs it. A short setup asks before it changes anything, and, for Claude Code, which model picks the past change, if any.
$ curl -fsSL https://raw.githubusercontent.com/pandacover/singularity/main/install.sh | sh
| Agent | At task start | Stores changes |
|---|---|---|
| Claude Codea model you choose picks, Haiku by default | ||
| Codex | ||
| Gemini CLI | ||
| Droid | ||
| Hermes Agentthrough a plugin | ||
| Cursor, OpenCodethrough a skill, when asked |
- singularity status
- What memory stored, per repo.
- singularity changes
- The changes stored here, or one in full.
- singularity visualise
- The same, drawn in your terminal.
- singularity recall "…"
- What a task would be handed.
- singularity store
- Store what earlier sessions here committed.
- singularity update
- Get the latest version.
- singularity uninstall
- Take it out again.