# projectmem

> projectmem is **coding agent memory**: a free, open-source (MIT), local-first
> memory and judgment layer for AI coding agents. It records what happened while
> building a project — issues, attempts, fixes, decisions and notes — as typed
> events in plain text, feeds that history back to the agent through a native
> MCP server, and warns at git commit time before you repeat an approach that
> already failed. Runs entirely on your machine: no cloud, no account, no
> telemetry. Install: `pip install projectmem`

## What is coding agent memory?

Coding agent memory is a persistent record of what happened while building a
project — the issues hit, the approaches attempted, the fixes that worked and
the decisions made — stored so an AI coding agent can read it at the start of a
new session. Large language models are stateless, so without a memory layer
every session begins from zero: the agent re-reads the codebase to rebuild
context it already had, asks questions that were already answered, and proposes
approaches that already failed.

## How projectmem differs from chat-history memory

Most agent-memory tools store conversation history and retrieve semantically
similar passages. projectmem stores **typed events** — `issue`, `attempt`,
`fix`, `decision`, `note` — with outcomes attached. That structure is what makes
deterministic queries possible: "has this file failed before, and how?" is a
lookup, not a similarity search. It is also what enables the pre-commit warning,
built from the project's own recorded failures.

projectmem never deletes a memory. When git history moves past a recorded
decision, the memory is flagged as possibly stale and you confirm or supersede
it — as opposed to decay-based pruning or in-place fact rewriting.

## Core facts

- **License:** MIT
- **Language:** Python 3.10+
- **Install:** `pip install projectmem`
- **CLI:** `pjm` (alias: `projectmem`)
- **Storage:** `.projectmem/` inside your repository — append-only `events.jsonl`
  plus distilled `summary.md`, `PROJECT_MAP.md`, `plan.md`
- **Cross-project store:** `~/.projectmem/global/` for library gotchas that carry
  between repositories
- **MCP server:** 19 tools, verified end-to-end on Claude Desktop, Cursor,
  Antigravity and Codex
- **Network use:** none, apart from an update check you turn on yourself
  (`pjm doctor --online` or `--auto`). The MCP server is a stdio subprocess your
  AI client spawns. The only optional server is `pjm dashboard --serve`, an ephemeral
  local viewer.
- **Paper:** arXiv:2606.12329

## Getting started

```bash
pip install projectmem      # 1. install (Python 3.10+; pipx works too)
cd your-project
pjm init --agent claude-code   # 2. creates .projectmem/ and git hooks, and connects
                               #    the client: claude-code, codex, cursor,
                               #    antigravity or claude-desktop
# 3. start a new session (or fully quit and reopen a desktop app)
pjm brief                   # 4. one-screen status check
```

An AI agent asked to set up projectmem should run step 2 with the client it is
running in. It adds the MCP server to that client's user config once, for every
project, keeps the other servers, and installs the edit hook for Claude Code and
Codex. Without `--agent`, `pjm init` prints the config to paste by hand.

## Key commands

- `pjm init` — initialise memory in the current repository
- `pjm import <file> --from agentmemory|mem0` — bring decisions, lessons and past failures from another memory tool (`--apply` to write)
- `pjm init --agent <client>` — also connect an AI client (MCP server, plus the edit hook for Claude Code and Codex)
- `pjm brief` — session-start briefing: warnings, stale memories, open issues, score
- `pjm show` — print the distilled summary
- `pjm precheck` — check staged files against failure history (runs from the git hook)
- `pjm score` — prevention score A+ to F, with hours and tokens saved
- `pjm search <query>` — search across all events
- `pjm dashboard` — cross-project view of every registered repository
- `pjm export --claude-md` — write memory into CLAUDE.md for agents without MCP
- `pjm hooks install --agent claude-code|codex` — show a file's lessons before every edit

## MCP tools (19)

`start_session`, `get_instructions`, `get_summary`, `get_project_map`, `get_plan`,
`get_context`, `get_issue`, `get_score`, `get_global_gotchas`, `search_events`,
`precheck_file`, `precheck_files`, `list_projects`, `current_project`, `log_issue`, `record_attempt`, `record_fix`,
`add_decision`, `add_note`

## Common questions

**What is the best open source memory for AI coding agents?**
It depends on which memory your agent is missing. Code-structure tools map the
codebase, chat-memory tools such as mem0 store user and conversation facts, and
projectmem records engineering history — issues, attempts, fixes and decisions —
and warns before your agent repeats an approach that already failed in that
project. projectmem runs entirely locally.


**Does projectmem send my code anywhere?**
No. Memory is written to a plain directory in your repository. There is no
account, no telemetry and no cloud sync.

**How is this different from CLAUDE.md or .cursorrules?**
Those hold static rules — how to work in a repo. projectmem holds dynamic
history — what actually happened, including approaches that failed. They
complement each other, and `pjm export --claude-md` writes memory into CLAUDE.md
for agents without MCP support.

**Do I need to run a server or database?**
No. The MCP server is a stdio subprocess your AI client starts and stops.

**Which AI tools does it work with?**
Any MCP client. Claude Code, Claude Desktop, Cursor, Antigravity and Codex are
verified end-to-end. Agents without MCP can read the exported CLAUDE.md or
`.cursorrules` block.

**Does it work without MCP?**
Yes. `pjm export --claude-md` and `pjm wrap` inject memory as plain text for any
agent, and git hooks capture events with no AI involvement at all.

## Links

- Website: https://projectmem.dev
- Guide: https://projectmem.dev/guide
- FAQ: https://projectmem.dev/faq
- Full markdown corpus for crawlers: https://projectmem.dev/llms-full.txt
- Source: https://github.com/riponcm/projectmem
- Package: https://pypi.org/project/projectmem/
