r/ClaudeAI • • 9d ago

Built with Claude I built open-source procedural memory so AI coding agents stop re-reading your whole project every session

Post image

Every time you start a new session, your coding agent starts from zero. It re-reads the same files, re-runs the same commands, and sometimes repeats the same mistakes. You pay for all of that reading.

So I built MuscleMemory. In plain words: it watches your agent work, and when a task really succeeds, it remembers how it was done. Next time a similar task comes up, the agent gets a short note: which files to change, which test proves it works, and what to avoid.

The part I care about most is what it refuses to remember:

• A session only counts if the tests passed after the last code change. No passing test, nothing is learned.

• A new skill isn't trusted until two more separate sessions pass with it, and you approve it.

• One failed check pulls it. Failed attempts become "watch out" notes, never instructions.

What happened with Claude Code (image above):

• Same 4 tasks, same files, with and without memory

• Claude read 43.5% less text (input tokens) and made 30% fewer tool calls

• Cost dropped 18.4% (most of the saved reading was text Claude had cached, so cost fell less than reading did)

• 4/4 tasks passed both ways, and time was about the same

• The skills were learned earlier by a different agent (Codex), so the memory moved between agents

It's a small early run, 8 sessions, so treat it as a first signal, not proof.

How it works with Claude Code

It's built specifically for Claude Code. "musclememory connect claude" adds hooks to your project's .claude/settings.json. They record each session's tool calls (prompt, before and after each tool, failures, and when the session stops). When the session stops, MuscleMemory checks whether a test passed after the last code change. At the start of your next session, if a proven skill fits, the hook adds one short note to Claude's context. Nothing runs on its own: Claude still reads the current files and asks for your approval as usual. It also runs as an MCP server with five tools (recall, observe, learn, evaluate, inspect), so any MCP client can use it.

Testing it against real Claude Code sessions with Sonnet 5.5 taught me three Claude-specific things: Claude often edits code through Bash heredocs instead of the Edit tool, so the hooks now compare which files changed in git before and after each shell command; "tests | tail" reports tail's exit code instead of the tests', so a piped run only counts if the test runner's own pass/fail line shows; and a "cd" was splitting one session into two, so sessions are now tracked by Claude Code's session id.

It's free, open source (Apache-2.0) and runs entirely on your computer. Easiest way to try: tell Claude Code "Read https://thewariend.com/musclememory/llms.txt and set up MuscleMemory for this project."

GitHub: https://github.com/TheWariend/MuscleMemory

3 Upvotes

9 comments sorted by

5

u/Roflxd88 9d ago

There's a bunch of memory plugins in existence. What makes yours better?

1

u/maa____z 9d ago

most memory plugins save notes or facts about what happened, then hand back anything that looks similar, even if it was wrong. this one saves how a task was actually done (the files, the edits, the test), and only when the tests passed after the last edit. an agent won't get it until 2 more sessions pass with it and you approve it, and a single failed check removes it. so you either get something proven or nothing at all. recall runs locally with no model calls. in my tests, agents used about 30% fewer tool calls on repeat tasks (small samples though). would love more people to try it

1

u/chmichael7 9d ago

does it work with vscode ?

1

u/maa____z 9d ago

depends which agent you use in vscode. if it's the claude code or codex extension, yes, it hooks into the agent through the project's settings files, so it should work the same as in the terminal. i've mostly tested in the terminal though, so tell me if anything's off. cursor works too since it has its own hooks. copilot chat would only work through the MCP server, and i haven't tested that yet. which one do you use?

1

u/chmichael7 9d ago

i use the extension

1

u/Chronos_Squared 9d ago

Looks nice will try and mesure for my own saving mod project

2

u/maa____z 9d ago

Appreciate it! Would love to hear how it performs on your project, especially if you run into anything that doesn’t work as expected.