Skip to main content

DAG-based persistent component memory for Claude AI sessions

Project description

cmem

DAG-based persistent component memory for Claude AI sessions.

Instead of a flat notes file that gets overwritten, cmem gives each component in your project an immutable DAG — a chain of snapshots with annotated transitions between them. Claude can traverse this graph to answer "why does this work this way?" by reading the history of changes.

Install

pip install cmem-cli

How it works

Each component gets its own directory under ~/.claude/memory/<project>/<component>/:

~/.claude/memory/
  my_project/
    auth_service/
      graph.toml          ← DAG index: nodes, edges, HEAD
      snapshots/
        N1.toml           ← immutable state snapshot
        N2.toml
      transitions/
        N1-N2.toml        ← what changed and why

Snapshots are immutable — once written, they can't be overwritten. Transitions record the trigger (bug fix, feature, refactor, discovery) and a diff summary. The DAG enforces no cycles.

Quick start

# Initialize a component
cmem init my_project auth_service

# Create first snapshot (opens $EDITOR)
cmem snapshot my_project auth_service

# After a change, snapshot again and record the transition
cmem snapshot my_project auth_service
cmem transition my_project auth_service N1 N2

# View history
cmem log my_project auth_service

# ASCII DAG
cmem graph my_project auth_service

Non-interactive use (for Claude)

Claude uses --file and --trigger/--notes to checkpoint without an editor:

# Write a temp snapshot file
cat > /tmp/snap.toml << 'EOF'
[state]
description = "Auth now uses JWT instead of session tokens"
key_files = ["auth/views.py", "auth/middleware.py"]
behavior = "Stateless JWT. Tokens expire in 24h. Refresh via /auth/refresh/."
open_questions = []
EOF

OLD=$(cmem head my_project auth_service | head -1)
cmem snapshot my_project auth_service --file /tmp/snap.toml
NEW=$(cmem head my_project auth_service | head -1)
cmem transition my_project auth_service $OLD $NEW \
  --trigger refactor \
  --notes "Switched to JWT to support stateless horizontal scaling"

Write CLAUDE.md into a project

cmem install-claude my_project /path/to/project/root

This writes a CLAUDE.md file instructing Claude to autonomously checkpoint components after every meaningful change — no user prompting required.

Commands

Command Description
cmem init <project> <component> Create new component graph
cmem snapshot <project> <component> [--file] Append new snapshot node
cmem transition <project> <component> <from> <to> [--trigger] [--notes] [--file] Record a transition edge
cmem log <project> <component> Print DAG history with transition notes
cmem show <project> <component> <node> Show a specific snapshot
cmem head <project> <component> Print current HEAD node
cmem list List all projects and components
cmem graph <project> <component> ASCII DAG visualization
cmem install-claude <project> <path> Write CLAUDE.md into project root

Configuration

Env var Default Description
CMEM_ROOT ~/.claude/memory Root directory for all memory files

Transition triggers

bug_fix · feature · refactor · discovery · breaking_change

License

MIT

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

cmem_cli-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

cmem_cli-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file cmem_cli-0.1.0.tar.gz.

File metadata

  • Download URL: cmem_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for cmem_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 117affce16adefe9a7ec1d2d9d63ecc0383b86dd4ff1a6be578e9ea0f4f46555
MD5 754f6ac1e97275fb88982678832e6418
BLAKE2b-256 743c5f25c166990f0b636d20f3b51a02b6fce78e4e7d922b44dcda8d3e84dfa5

See more details on using hashes here.

File details

Details for the file cmem_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cmem_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for cmem_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70bbd1eb904cfd5097ec3b627b738c91316cfacb577ab02f4f34098df546d90a
MD5 da6b79ab69152ab12dafdb0408bf8587
BLAKE2b-256 c3c6b9895aab02e518520fd34d18fc4d23319765dfc7cd178c41ac2b6de73bbf

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