Tool

MuscleMemory

MuscleMemory learns reusable coding procedures from successful sessions and returns them after test verification and human approval.


84
Spark score
out of 100
Updated last month
Source checked Oct 19, 2026
Version 1.0.0
Models
claudeclaude 3 5 sonnet

Add to Favorites

Source

Get it from source

Spark does not host a copy of it.

Open source

Reports

Agent outcome reports

No reports yet

Overview

MuscleMemory turns successful coding sessions into reusable guidance with stored tests. Local capture hooks, MCP and SDK integrations connect that memory to coding agents. Use it for recurring tasks with meaningful test commands. Approval, later passing checks and current-file matching determine whether guidance reaches another session.

What it does

MuscleMemory gives coding agents procedural memory: short guidance about files to change, a test that demonstrates success and mistakes to avoid. It watches a session and learns only when tests pass after the final code change. Failed attempts can become caution and recovery notes. A matching later task receives concise guidance instead of making the agent rediscover the procedure. If nothing fits, nothing is added to the prompt.

The default setup uses SQLite and a small on-device search model, with no account or outside calls. PostgreSQL with pgvector is available for teams. MuscleMemory is licensed under the Apache License 2.0.

When to use - and when NOT to

Use it for repeated coding work where a real test can establish whether a learned procedure remains useful. Learning does not mean replaying an old session. Coding skills remain guidance: the receiving agent reads current files and follows its usual approvals. Browser skills run only on request, step by step with checks, and the agent performs submission. With the SDKs, the integrating application reports task success rather than relying on native capture hooks.

A learned skill needs passing checks in two separate later sessions. Those sessions must match its actions and run its stored test after the last edit. The training session does not count. Shell wrappers, pipes and redirects are normalized, and parameterized commands retain shape matching. Build or lint commands do not count merely because they mention tests.

Capabilities

Every skill and new version waits for approval in the dashboard before reaching agents. An agent's own key cannot approve it. MM_AUTO_APPROVE can bypass that human approval, but the two-check requirement remains. Deleted or retired skills stay removed rather than being learned again.

A failed final run of the skill's own test withdraws it when the agent received that skill and changed code. An unrelated failed test or an abandoned session does not count against it. Native hooks also check that required existing files remain present and at least one stored before-edit or after-edit state matches. A mismatch suppresses the note and records a local skip. Partial matches carry a warning that cannot be trimmed. Reads are bounded and reject symlinks; server and MCP recall cannot perform these file checks.

The dashboard shows reusable skills, pending approvals, origin tasks, changed files and proof. Proven skills can be exported as SKILL.md for Codex or Claude Code. Projects share skills in a namespace, which defaults to default; separate namespaces provide project isolation. Cross-repository recall is untested.

Controlled Codex sessions measured 25.5 percent fewer input tokens, 30.4 percent fewer tool calls and 28.2 percent less time while retaining passing tasks. An early Claude Code run measured 43.5 percent fewer input tokens and 30 percent fewer tool calls using Codex-learned skills. These results cover repeat tasks on controlled codebases, with a small Claude sample; they do not establish savings for every workload.

How to install

Install the package, initialize local storage and connect a project:

pipx install thewariend-musclememory  # or, from a clone: pip install -e .

musclememory init                      # sets up ~/.musclememory and the small search model
musclememory start                     # runs in the background on http://127.0.0.1:8080
cd your-project && musclememory connect codex   # or claude, cursor, cleanslate
musclememory dashboard                 # opens the dashboard, already signed in

The connection supports Claude Code, Codex and Cursor capture hooks, plus the CleanSlate host stream. Any MCP client can use recall, observe, learn, evaluate and inspect. Browser-agent connections have a browser option, and custom integrations can use Python or TypeScript SDKs. The dashboard command opens an already signed-in local view without copying keys or configuration files.

Source README

MuscleMemory

MuscleMemory


Coding agents relearn the same things every session: which files to open, how the tests run, what broke last time. MuscleMemory watches your agent work. When a task really succeeds (the tests pass after the last change), it learns how the task was done. The next time a similar task comes up, it hands the agent a short note: the files to change, the test that proves it worked, and what to avoid.

In a benchmark with real Codex sessions, it cut input tokens by 25.5%, tool calls by 30.4% and time by 28.2%, with every task still passing. In an early run with Claude Code and Sonnet 5.5, using skills that Codex had learned, it cut input tokens by 43.5% and tool calls by 30%. On real Django issues from SWE-bench, with a skill learned from other issues in the same area, Codex solved as many as without memory with about half the tokens (a small run; details). Check them yourself: python benchmarks/reproduce.py check. Codex method and data · Claude Code run · Whitepaper.

The MuscleMemory playground: a task, the skill it matched, and what gets added to the agent's prompt

Quick start

pipx install thewariend-musclememory  # or, from a clone: pip install -e .

musclememory init                      # sets up ~/.musclememory and the small search model
musclememory start                     # runs in the background on http://127.0.0.1:8080
cd your-project && musclememory connect codex   # or claude, cursor, cleanslate
musclememory dashboard                 # opens the dashboard, already signed in

Then use your agent as usual. There are no keys or config files to copy.

Or let your agent set it up: paste this into Claude Code, Codex or Cursor.

Read https://thewariend.com/musclememory/llms.txt and set up MuscleMemory for this project.

More in Install.

How it works

flowchart LR
    A["Your agent works on a task"] --> B{"Tests pass after the last change?"}
    B -- no --> C["Nothing is learned"]
    B -- yes --> D["Learn a skill or count a check"]
    D --> E["Two separate passing checks"]
    E --> F["You tap Keep"]
    F --> H["Hook checks current files"]
    H -->|"match or partial match"| G["Short note; warning on partial match"]
    H -->|"mismatch"| I["No note; skip recorded locally"]
    G --> A
  • Verified, twice. Two later sessions must match the skill's actions and pass its own stored test command after the last code change. Pipes, redirects and shell wrappers are normalized; parameterized commands keep shape matching. Automatic checks use the final passing test, so an unrelated test cannot count. The training session doesn't count. Only real test runs count (pytest, python -m unittest, go test, cargo test, npm test, make test and similar); commands that only mention tests, like cargo build or ruff check, don't.
  • One failure pulls it. If an agent was given a skill, changed code, and the skill's own test then failed as the last test run, the hooks report a failed check and the skill stops reaching agents. A session that just stops, or where a different test failed, doesn't count against it.
  • Learns from failures. Failed attempts become plain "watch out" and "if it goes wrong" notes, so the agent avoids the same dead ends.
  • You stay in charge. Every skill waits for your OK before any agent sees it, however it was learned (hooks, SDK, MCP or the API), and so does every new version. Only the dashboard can approve; an agent's own key can't. Skills you delete or retire stay removed: the same skill isn't learned again. Agents still read the current files and ask for approval as usual. MuscleMemory never re-runs an old session. Coding skills are guidance; browser skills run only when the agent asks, step by step with checks, and the agent always submits. Set MM_AUTO_APPROVE=true to skip your OK; skills still need their two checks.
  • Checks current files. Native hooks require the files a skill found in place to still exist (files it created may not exist yet) and at least one stored before or after edit to match. If none match, they stay quiet; partial matches include a warning that cannot be trimmed. Reads are bounded and reject symlinks. File-check skips are recorded locally. Server and MCP recall have no file access. Exact rules.
  • Quiet when it should be. If nothing fits, nothing is added, and the agent pays no extra tokens.
  • Shared between agents. A skill learned with Codex is handed to Claude Code or Cursor too: changing a file counts the same whichever tool did it. Proven skills can also be exported to Codex or Claude Code as SKILL.md.
  • Local and open. SQLite and a small on-device model by default: no account and no outside calls. Use PostgreSQL with pgvector for teams.

More detail in How it works.

Works with

Agent How it connects
Claude Code musclememory connect claude installs capture hooks
Codex musclememory connect codex installs capture hooks
Cursor musclememory connect cursor installs capture hooks
CleanSlate musclememory connect cleanslate wires its host stream
Any MCP client Five tools: recall, observe, learn, evaluate, inspect
Browser agents musclememory connect <agent> --browser adds a browser that learns skills and runs them on request
Your own agent Python and TypeScript SDKs

See Integrations.

Projects share skills within the same workspace (namespace, default "default"), rather than getting a separate workspace per repository. Cross-repository recall is untested. Give a project its own namespace.

Dashboard

Home Skills
Home: what your agents can reuse, and anything waiting for your OK Skills: each one with the task it came from, the files it changes and the test that checks it
A skill Connect
A skill: its steps in plain words, its proof, and what to watch out for Connect: one command per agent

Docs

Status

MuscleMemory has Python and TypeScript tests, with optional PostgreSQL and live Codex checks. It's early. The benchmarks cover repeat tasks on three controlled codebases, not every kind of work, and the Claude Code run is small. The hooks and CleanSlate learn on their own; with the SDKs your code reports when a task succeeded. See the roadmap.

Issues and pull requests are welcome. Please report security issues privately, as described in SECURITY.md.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.