Skip to main content

Procedural memory for coding agents. Your past sessions, compiled.

Project description

Pixel art of a vintage CRT monitor with a tiny brain character flexing a bicep on its amber phosphor screen

muscle-memory

Procedural memory for coding agents. Your past sessions, compiled.

muscle-memory gives Claude Code a memory that actually compounds. Instead of dumping prose into CLAUDE.md files that bloat every context, it watches your sessions, extracts reusable Skills — executable playbooks with activation conditions, steps, and termination criteria — and retrieves the right ones on demand when you start a new task.

Inspired by ProcMEM (arxiv:2602.01869), but purpose-built for coding agents.

The problem

Session 1:  Figure out the monorepo's weird test runner (15 min)
Session 2:  Figure it out again (15 min)
Session 3:  Add a note to CLAUDE.md (2 min, bloats future context)
Session 50: CLAUDE.md is 4000 lines, half stale, nobody reads it

What muscle-memory does instead

Session 1:  Figure out the test runner (15 min) → extractor creates a Skill
Session 2:  "run the tests" → Skill activates automatically, zero rediscovery
Session 5:  Skill gets refined from more examples
Session 20: Skill has been invoked 18x, 17 successes → promoted to "proven"
Session 50: Unused skills auto-pruned, active ones keep improving

Skills are on-demand (not always in context), execution-scored (good ones survive, bad ones die), and user-editable (plain text, no opaque embeddings).

Quickstart

# install (Anthropic default)
uv tool install muscle-memory

# or with OpenAI support baked in
uv tool install 'muscle-memory[openai]'

# in your project
cd ~/code/my-project
mm init                    # creates .claude/mm.db, registers Claude Code hooks

# optional: bootstrap from recent history
mm bootstrap --days 30

# now just use Claude Code normally.
# skills accumulate automatically.

# inspect what you've learned
mm list
mm show <skill-id>
mm stats

Authentication

muscle-memory needs an LLM for skill extraction (runs after each session, not on every prompt). It cannot reuse your Claude Code subscription auth — that's a known limitation; Anthropic does not currently expose a subscription-capable SDK for third-party tools.

Your options:

Provider Setup Cost
Anthropic (default) export ANTHROPIC_API_KEY=sk-ant-...needs API credits, not a Max/Pro subscription ~$0.001 / session with Haiku 4.5
OpenAI export OPENAI_API_KEY=sk-... and export MM_LLM_PROVIDER=openai ~$0.0005 / session with gpt-4o-mini
Local / Ollama (planned, not yet implemented) free

If you already use Claude Code via a Max/Pro subscription, you'll still need a separate Anthropic API key with billing credits, or use OpenAI. See docs/authentication.md for details.

How it works

┌──────────────────────────────────────────────────────┐
│                 Claude Code Session                   │
│                                                        │
│  user prompt ─┐                                       │
│               ▼                                        │
│       ┌───────────────┐     top skills                │
│       │  Retriever    │────────────►  inject context  │
│       │  (embedding)  │                                │
│       └───────────────┘                                │
│               │                                        │
│               ▼                                        │
│       [ LLM executes with Skill hints ]               │
│               │                                        │
│               ▼                                        │
│       ┌───────────────┐                                │
│       │   Extractor   │  proposes new Skills           │
│       │   (async)     │                                │
│       └───────┬───────┘                                │
│               │                                        │
│               ▼                                        │
│       ┌────────────────────┐                          │
│       │   Scorer           │  updates / prunes        │
│       └────────────────────┘                          │
│               │                                        │
│               ▼                                        │
│       ┌────────────────────┐                          │
│       │   SQLite + vec     │                          │
│       └────────────────────┘                          │
└──────────────────────────────────────────────────────┘

Skill anatomy

Each Skill is three editable text fields:

{
  "activation":  "When pytest fails with ModuleNotFoundError in this monorepo",
  "execution":   "1. Check if tools/test-runner.sh exists.\n2. If yes, use it instead of invoking pytest directly.\n3. Set PYTEST_ADDOPTS=--no-cov for speed.",
  "termination": "Tests pass, or runner is confirmed missing",
  "tool_hints":  ["Bash: tools/test-runner.sh"]
}

No DSL. No code templates. Plain English that the agent reads and executes with judgment.

Status

Alpha. Core extraction + retrieval + scoring are working. The Non-Parametric PPO refinement loop from the paper is planned for v2.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muscle_memory-0.2.0.tar.gz (72.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muscle_memory-0.2.0-py3-none-any.whl (59.6 kB view details)

Uploaded Python 3

File details

Details for the file muscle_memory-0.2.0.tar.gz.

File metadata

  • Download URL: muscle_memory-0.2.0.tar.gz
  • Upload date:
  • Size: 72.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for muscle_memory-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d4d9e349cf01cb0455f4493680b1ccbf69ed6665a98fc0024efe73ff4bcc964b
MD5 a934e757ed17ce98899c8e9dc8e7ccef
BLAKE2b-256 e5d1d58d1b867f7b38ee68097454ed06b71b17ec397165f93d633a3f098a50ea

See more details on using hashes here.

File details

Details for the file muscle_memory-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: muscle_memory-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 59.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for muscle_memory-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 faf18ae3e95b3fdb753cfd4a8038e32d9278768a99ec623ff50ce36362acb550
MD5 38e3717fedc5e89b2fff215e3d850aef
BLAKE2b-256 cb8a674d6dbbfa4414064ea151f8b8c7d66885d819637107181db392251e1f05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page