claude-session-ledger: a project log for Claude Code that keeps itself
I built a Claude Code plugin that logs each project's sessions with hooks, has a spend-capped model write the day's entry, and keeps everything in Markdown that opens in Obsidian.
AI-assisted translation, approved by Mateo.

In this post I share claude-session-ledger, a Claude Code plugin I built, under MIT. Every session in a project logs itself, and when it closes a model writes the day's summary in Markdown that I can open in Obsidian.

What is claude-session-ledger?
It is a Claude Code plugin (its id is pm-flow and its CLI is pm) that keeps the log of projects and sessions. A project is a folder with five text files, and each file has a single owner.

The hooks and pm write the state in .pm-state.json, the journal worker writes implementation-log.md, and we or the agent edit README.md, workplan.md and testing-plan.md. The latest version, on main, also adds personal tasks with PM-1 keys, which can sync to a private GitHub Project; the details are in TASK-TRACKING.md.
Why I built it
Before the plugin I used a script, pm-scaffold.py: a session was logged only if someone ran its session-start, usually the model following my instructions. When it forgot, the session left no trace.

Hooks fixed that, but something was still missing. I work in code repos and their worktrees, outside the project folder. In late November, only 8 of about 95 sessions since install were tied to a project, and I had to backfill 289 entries across 21 projects from git history. That is when I added the repo link.
How I use it
To show it without opening my real projects, I set up three related demo projects and worked on them with Claude Code as I would on any project. Nobody runs pm session-start: the hooks open each session on its first edit or commit, and count the commits.

On leaving each session, the worker writes the day's entry in implementation-log.md, with its focus, decisions and discoveries. The graph above comes from what the tool wrote plus the README and workplan fields I filled in by hand, as any user would.
How does it work?
SessionStart, PostToolUse and SessionEnd call bin/pm-hook, which uses no model and exits in about 100 ms (1.5 s at SessionEnd). Only the journal worker, which SessionStart and SessionEnd start separately, spends money.

| Piece | What for | Why this one | In exchange |
|---|---|---|---|
| Claude Code hooks | open, count and close each session | run even when nobody remembers | a killed process waits for pm sweep |
pm, in Python | write state under a lock | standard library only | POSIX only |
.pm-state.json | hold state and sessions | one writer, atomic writes | dirties git status in a repo |
claude -p worker | write the day's entry | summarizes in natural language | costs money, capped |
| Markdown in folders | read it all in Obsidian | plain text, no database | the README never updates itself |
How does it pick the project?
pm resolve tries three rules in order and keeps the first match: the nearest project folder, the branch's ticket and the linked repo. The third one lets a code repo, or any of its worktrees, report to a project folder that lives somewhere else.

If none matches, or the case is ambiguous, it prints project: none and says why: an unclear case is never guessed.
For example, when several projects link the same repo, the one marked as its default wins; without exactly one, it stays unresolved.
A session that died without closing is closed at its last sign of life, by the next SessionStart or by pm sweep.
What about planning-with-files?
planning-with-files is a plugin by Ahmad Othman Ammar Adi, under MIT, that keeps a task's plan in three files so it survives a /clear. The design is his; I only added a command that hands it the task.

/pm-flow:plan-pm is a prompt that only we launch: it resolves the project, shows its digest when it can and loads the planning-with-files skill. It stores no link to the plan and syncs nothing back.
That is why, in the graph above, the plans of the two sessions that started this way are the loose dots. The handoff capture shows it in the terminal.
Pros and cons
What we gain:
- The log keeps itself, also with several sessions in parallel.
- A day-by-day history in Markdown, readable in Obsidian or any editor.
- Capped spend: $1 per run and $5 per day by default; anything over the cap waits.
What it costs:
- IMPORTANT: the journal sends a reduced transcript to a model, with best-effort secret redaction, and that costs money.
- POSIX only: tested on Linux, and the tests do not run on macOS.
- The journal uses the Claude login: with only an API key, Bedrock or Vertex, those jobs fail.
- The project README does not update itself, and posting to tickets does not exist yet.
When to skip it: if session content must not leave our machine, we should not enable the plugin. It is better to keep the log by hand or read it from git log.
How to install it
To install it, we run these two commands in a terminal:
claude plugin marketplace add mateo-di/claude-session-ledger
claude plugin install pm-flow@claude-session-ledger
If we also want the handoff, we install planning-with-files from Claude Code, as its README says:
/plugin marketplace add OthmanAdi/planning-with-files
/plugin install planning-with-files@planning-with-files
Done! To use pm outside Claude Code, we add bin/pm to the PATH. Then we create each project's folder and fill it with pm scaffold --only <name>; --source links its code repo, as the README explains. From the next session on, the hooks log it by themselves.
In short, one lesson I took from this: a log that depends on someone remembering ends up full of gaps, and a hook does not forget. I hope you find it useful! Cheers :)
Links and credits
- claude-session-ledger repository, with its README, FLOW.md and the plan-pm command. The handoff arrived in PR #1.
- planning-with-files is by Ahmad Othman Ammar Adi (OthmanAdi), under MIT; its README explains how it recovers the plan.
- Claude Code is by Anthropic.
Thanks for reading. The learning continues in the next article.


