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.

Editorial composite of two real captures from my lab: the Obsidian graph of three related synthetic demo projects, colored by project and linked through their READMEs and tags, and a terminal with Claude Code running /pm-flow:plan-pm.

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.

Obsidian graph view of three demo projects colored by folder: blue tide-notes, orange tide-alerts, purple harbor-board. Each README links to its workplan, log and testing plan; the READMEs link to each other and to shared tag nodes like #tides and #python. Six planning files float unlinked.Enlarge image
Dots are notes and tags, lines are links; plans float alone. Three demo projects, README and workplan filled by hand. Lab capture.

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.

Diagram: a project folder with three writers and their files: hooks and pm, .pm-state.json; journal worker, implementation-log.md; you or the agent, README.md, workplan.md and testing-plan.md. A dashed arrow leads to the Obsidian vault; an illustration, not a screenshot.Enlarge image
Each project file has a single owner, and the whole folder opens as an Obsidian vault. Illustration.

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.

Two-panel diagram. Top, before: pm-scaffold.py session-start leads to no trace if nobody runs it, with a dashed arrow. Bottom, now: 3 hooks and the linked repo lead to session logged on every project session. An arrow, plugin, joins the panels; an illustration, not a screenshot.Enlarge image
Before, a session was logged only if someone ran the script; now the hooks log it. Illustration.

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.

Obsidian with the tide-notes folder open in the file explorer, showing README, workplan, testing-plan and implementation-log next to task_plan, findings and progress, and the implementation-log note displaying the Sessions section with Focus, Decisions and Discoveries written by the journal worker; a real capture.Enlarge image
The day's entry the worker wrote, with Focus, Decisions and Discoveries, next to the project files. Lab capture.

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.

Flow diagram: a Claude Code session calls bin/pm-hook, with no model. SessionStart picks the project, PostToolUse opens the session and counts commits, SessionEnd closes and queues the journal. A dashed arrow leads to the claude -p worker, capped, which writes implementation-log.md; an illustration, not a screenshot.Enlarge image
The hooks call no model; only the journal worker, detached and capped, spends money. Illustration.
PieceWhat forWhy this oneIn exchange
Claude Code hooksopen, count and close each sessionrun even when nobody remembersa killed process waits for pm sweep
pm, in Pythonwrite state under a lockstandard library onlyPOSIX only
.pm-state.jsonhold state and sessionsone writer, atomic writesdirties git status in a repo
claude -p workerwrite the day's entrysummarizes in natural languagecosts money, capped
Markdown in foldersread it all in Obsidianplain text, no databasethe 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.

Diagram of pm resolve with three rules in order: 1, nearest .pm-state.json; 2, branch ticket; 3, linked repo or its worktree. The first match leads to the project; no match, or an ambiguous case, leads to project: none with the reason; an illustration, not a screenshot.Enlarge image
The first matching rule wins; with no match or an ambiguous case, it prints project: none and the reason. Illustration.

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.

Handoff diagram: the user runs /pm-flow:plan-pm, which adds context with pm resolve and pm digest and loads planning-with-files:plan, by Ahmad Othman Ammar Adi, MIT, which writes task_plan.md, findings.md and progress.md. A dashed arrow back reads no link, no sync; an illustration, not a screenshot.Enlarge image
The command adds project context and loads planning-with-files; the plan never comes back to the log. Illustration.

/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 :)

Thanks for reading. The learning continues in the next article.