Skip to main content

pmem-agent

Persistent, concurrent-safe project memory for Claude Code agents.

Stores structured project facts in .claude/memory/project-memory.json. Multiple agents can read and write safely — all operations go through an exclusive file lock with stale-lock detection.

Install

pip install pmem-agent
pmem setup          # installs the Claude Code subagent to ~/.claude/agents/

npx (no install required)

npx pmem-agent

curl — Mac / Linux

curl -fsSL https://raw.githubusercontent.com/thechandanbhagat/pmem-agent/main/install.sh | bash

PowerShell — Windows

iwr -useb https://raw.githubusercontent.com/thechandanbhagat/pmem-agent/main/install.ps1 | iex

Clone and run

git clone https://github.com/thechandanbhagat/pmem-agent
cd pmem-agent
./install.sh          # Mac/Linux
./install.ps1         # Windows (PowerShell)

Quick start

# 1. Mark your project root (run once)
cd ~/projects/my-app
pmem init-root

# 2. Write some facts
pmem write project '{"name":"my-app","type":"web-app"}'
pmem merge '{"tech_stack":{"languages":["TypeScript"],"frameworks":["React"]}}'

# 3. Read them back
pmem read

Multi-repo / monorepo

When several git repos share a common parent folder, one init-root at the parent makes all subrepos share the same memory file automatically.

my-project/
├── .pmem-root          ← root marker (gitignored)
├── .claude/
│   └── memory/
│       └── project-memory.json   ← shared by ALL subrepos
├── api/                ← git repo
├── web/                ← git repo
└── mobile/             ← git repo
cd ~/projects/my-project
pmem init-root            # one-time setup

# Now from any subrepo, pmem always hits the shared file:
cd ~/projects/my-project/api
pmem write tech_stack '{"languages":["TypeScript"]}'

cd ~/projects/my-project/web
pmem read tech_stack      # same data

Env var override (useful in CI):

export PMEM_ROOT=/path/to/my-project
pmem read

Debug which file will be used:

pmem root
# Memory path: /path/to/my-project/.claude/memory/project-memory.json
# Source:      .pmem-root marker at /path/to/my-project

Memory schema

{
  "project":      { "name": "", "description": "", "type": "", "root": "" },
  "tech_stack":   { "languages": [], "frameworks": [], "databases": [], "tools": [] },
  "architecture": { "pattern": "", "key_decisions": [] },
  "conventions":  { "naming": "", "file_org": "", "test_pattern": "" },
  "repos":        {},
  "current_goals": [],
  "known_issues":  [],
  "_last_updated": "",
  "_agents":       {}
}

Using in Claude Code

After pmem setup, a project-memory subagent is available in Claude Code. Spawn it at the start of any long-running task:

"Initialize project memory" — scans manifests, README, and directory layout, writes structured facts to .claude/memory/project-memory.json.

"Load project context" — reads memory and summarises it before you start work.

"Remember that we decided to use Postgres instead of SQLite" — appends to architecture.key_decisions.

Parallel agent coordination

When multiple Claude Code agents run in parallel, each registers itself on startup and reads what peers are working on — preventing duplicate work. The _agents key in memory is the coordination table; it is automatically cleaned up when each agent finishes.


CLI reference

pmem setup                       Install Claude Code subagent to ~/.claude/agents/
pmem init-root                   Mark cwd as project root (shared by all subrepos)
pmem root                        Show resolved memory path

pmem read [key]                  Print all memory or one top-level key
pmem write <key> <value>         Set key (value: JSON or plain string)
pmem merge <json>                Deep-merge a JSON object into memory
pmem delete <key>                Remove a top-level key
pmem reset                       Wipe all memory

pmem agent-register <id> <task>  Register a running agent
pmem agent-update <id> <status>  Update agent status
pmem agent-deregister <id>       Unregister agent on completion

How it works

  • Storage: plain JSON at .claude/memory/project-memory.json
  • Locking: O_CREAT|O_EXCL on a .lock sidecar file — atomic on all major filesystems, no dependencies required
  • Stale locks: automatically cleared after 30 s so a crashed agent never permanently blocks others
  • Root discovery: walks up from cwd looking for .pmem-root marker or an existing memory file — works from any depth in a monorepo

Requirements

  • Python 3.10+ (stdlib only — no dependencies)
  • Claude Code (for the subagent)

License

MIT

Metadata

Release files for pmem-agent 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pmem-agent 1.0.0
File Size Uploaded
pmem_agent-1.0.0.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pmem-agent 1.0.0
File Interpreter ABI Platform
pmem_agent-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / pmem_agent-1.0.0.tar.gz

Download URL pmem_agent-1.0.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
210b5040ea46bbb07cb97bde2f0e4f2c2d11d5f4ae823207a28df2f6ca4ba996
BLAKE2b-256 checksum
How to use checksums
bbe42778716046471b05657387e5c0f7f737faba97ed5efda9943026628032ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / pmem_agent-1.0.0-py3-none-any.whl

Download URL pmem_agent-1.0.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6b245c28798ac6a2f5d7d995b0d79a3f91b9501c125d5e7de4dcd5eeda5996c
BLAKE2b-256 checksum
How to use checksums
3144c8d577bf59e10668468f4472ad487db2c3163f3c9280e52cbc77c66fb373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page