Skip to content

About

A plain-markdown work logbook for AI coding sessions, with a checker that keeps it honest.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

agent-logbook

On Monday you asked an AI assistant to pick a storage engine. It compared three, rejected Postgres because the cache has to work without a server the user runs, and you agreed. On Thursday you open a new session — maybe a different model entirely — and ask why the cache is a single SQLite file. Nobody knows. The comparison happened, the reasoning was sound, and it now exists only inside a conversation that has been closed.

A logbook, on a ship or in a cockpit, is the formal record kept as the voyage happens: written in order, and never amended afterwards. It exists for the handover. Whoever comes on watch next reads it and picks up where the last watch left off, without having been there.

agent-logbook does that for AI sessions. The next watch is the next session, often a different model, and it should inherit a written record rather than start from nothing. So this is a file format for writing that record down, and a checker that stops the file from rotting. The state that matters between sessions — decisions, verified facts, guesses, corrections — lives in plain markdown in the repository, next to the code it explains, in the same commit and the same diff.

There is no server, no database, and no retrieval index. There is a directory of markdown files and a script that refuses to let them lie.

A terminal session: logbook init and logbook add create an entry, logbook check refuses it because the baseline is a placeholder and a fact has no source, the filled-in entry passes and is committed, and a later edit to that committed entry is rejected as a rewrite of history.

What a logbook looks like

logbook init creates LOGBOOK.md and journal/. Entries go in daily files:

## 2026-08-31 — Chose SQLite over Postgres for the local cache

Baseline: bca432f

Decision:
- Keep the cache in a single SQLite file next to the workspace. Postgres is out:
  it needs a server the user has to run.

Facts:
- The cache is opened once per worker process, not once per request (src: src/cache.js)
- The comparison is written up in
  [../reviews/2026-08-31-storage.md](../reviews/2026-08-31-storage.md) (src: reviews/2026-08-31-storage.md)

Assumptions:
- Write volume stays under a few hundred rows per second. Guessed from the
  current task rate, not measured.

Next:
- Measure the real write rate before the next release.

Three things carry the weight. Baseline: pins the entry to a commit, so a reader six months later knows which version of the code the claims were true about. Every line under Facts: names where it came from. Everything unverified sits under Assumptions:, where it cannot be mistaken for something checked.

The journal is never edited, so it cannot say what is true now. That is the job of LOGBOOK.md, the one file meant to be rewritten. It holds a one-sentence Status:, a list of standing decisions, and an index of the long documents. A standing decision is a decision that still holds, and each one ends with the journal entry that recorded it:

## Standing decisions

- The local cache is one SQLite file next to the workspace
  (entry: 2026-08-31 — Chose SQLite over Postgres for the local cache)

The checker rejects a standing decision whose citation does not name a real entry. So the list can be rewritten as often as the project changes its mind, but it cannot claim a decision that the journal never recorded.

What the checker does

logbook check is the reason the format survives contact with real work. An assistant that writes a plausible-sounding claim with no evidence gets stopped:

$ logbook check
journal/2026-08-31.md:13: R4 Fact has no source: "Postgres would be slower here anyway"
    Append a source like (src: lib/parse.js:42), (src: $ npm test), or (src: https://...). If you cannot cite one, move the line under Assumptions:.

logbook check failed: 1 problem (R4:1) across 1 entry.

That line was not wrong, exactly. It was a guess wearing the clothes of a fact, which is the failure that makes a logbook worse than no logbook at all. Moving it under Assumptions: is a valid fix, and an honest one.

Installed as a pre-commit hook, the same check refuses to let already-committed history be quietly reworded:

$ git commit -m "quietly change my mind"
journal/2026-08-31.md:8: R5 Committed journal history was rewritten; the file no longer starts with what was committed.
    Restore the old text and append a new entry with a `Corrects:` field instead of editing the past.

logbook check failed: 1 problem (R5:1) across 1 entry.

Commit stopped: the logbook does not pass its own rules.
Fix the problems above, or commit with --no-verify if you know why you are skipping this.

When everything holds:

$ logbook check
logbook check passed: 1 entry in 1 journal file.

The check that something was written at all

The five rules judge entries that exist. None of them can catch the failure that actually happens: an assistant finishes a day of work, writes no entry, and logbook check passes on an empty journal because nothing in it is wrong.

--require-entry-since closes that. Give it the revision the delivery started from — the commit the remote branch is on, the base of the pull request — and the check also fails when the journal has gained nothing since:

Both transcripts below are from this repository's own history — the same delivery, checked before and after its journal entry was written:

$ logbook check --require-entry-since 61e6f51
This delivery is not recorded in the logbook: no entry has been added since 61e6f51.
    Write one before shipping: `logbook add "what you just did"`, then fill in Baseline:,
    Decision: and Facts: and commit the journal file alongside the change.
    If this change genuinely produced no decision and no fact worth citing, skip the gate
    deliberately (git push --no-verify) rather than writing an empty entry to get past it.

logbook check failed: this delivery has no new logbook entry since 61e6f51.

An entry counts when it is pinned to a Baseline: and says something under Decision: or Facts:. An untouched logbook add skeleton does not count, which stops the gate from being satisfied by running one command.

When it is satisfied, it says which revision it compared against:

$ logbook check --require-entry-since 61e6f51
note: require-entry-since 61e6f51: 1 new entry in the journal.

logbook check passed: 7 entries in 1 journal file.

The same comparison also protects the history that was already there. R5, the rule that stops an edit to committed history at the pre-commit hook, compares the journal with HEAD. If someone edits an old entry and commits the edit with git commit --no-verify, HEAD now holds the edited text, and R5 has nothing left to object to. The revision the delivery started from still holds the original text, so the gate compares against that as well. Every journal file that existed there must still exist and must still start with exactly the text it had. The transcript below is from a clone of this repository at 5bf3e0d: a delivery added a new entry and, in the same commit, changed "No YAML frontmatter" to "Some YAML frontmatter" in the first entry of journal/2026-08-31.md:

$ logbook check
logbook check passed: 10 entries in 1 journal file.
$ logbook check --require-entry-since 5bf3e0d
Journal history committed as of 5bf3e0d was rewritten: this file no longer starts with the text 5bf3e0d holds.
    journal/2026-08-31.md:10: differs from its text at 5bf3e0d from this line on.
    Restore the text as it was at 5bf3e0d, and append a new entry with a `Corrects:`
    field instead of editing the past. If the git history itself was rewritten and only
    Baseline: hashes were remapped to the new commit ids, skip the gate deliberately
    (git push --no-verify) and record the rewrite in a new entry.

logbook check failed: journal history committed as of 5bf3e0d was rewritten in 1 file.

Which entries count as new is decided by position, not by heading. If a journal file had three entries at the starting revision, the first three entries in that file are old ones, whatever their headings say now. Rewording the heading of an old entry therefore does not make it a new one.

Install

npm install --save-dev agent-logbook

Or run it without installing:

npx agent-logbook init

It needs Node 18 or newer and has no runtime dependencies. Git is used through the git command for the two rules that need history.

Commands

Command What it does
logbook init Creates LOGBOOK.md and journal/ in the current directory, refusing to overwrite either if it already exists.
logbook add [title] Appends a blank entry to today's journal file, dated from the system clock, creating the file if needed.
logbook add --date YYYY-MM-DD [title] The same, but dated that day and appended to that day's journal file, for writing up work from an earlier day.
logbook check Runs the five rules and exits non-zero on any violation, printing each one with its file, line, and what to do about it.
logbook check --require-entry-since <git-ref> The same, and also fails when the journal has gained no entry since <git-ref>, or when journal text committed at <git-ref> has since been changed or deleted.

Rules

Rule What it enforces
R1 Every entry declares a Baseline:, and each hash resolves to a commit that really exists in this repository.
R2 Relative links point at files that exist, every Corrects: names an entry that is really in the journal, and every standing decision in LOGBOOK.md ends with (entry: ...) naming such an entry.
R3 Every file under a registered directory (reviews/ by default) has a row in the LOGBOOK.md document index.
R4 Every item under Facts: carries a source: a file, a command, or a URL.
R5 Journal files are append-only — the committed bytes must still be a prefix of the working copy, and a committed journal file must not be deleted.

A hash marked as belonging to another repository, written upstream-sdk@9f8e7d6, is reported as skipped rather than checked, since the checker has no copy of that repository. Outside a git repository R1 and R5 announce that they were skipped, rather than passing silently and letting a green result mean nothing.

--require-entry-since is deliberately not one of the five. The rules run everywhere and need no argument; the delivery gate needs to be told what the delivery is, so it only runs when a caller names a revision.

Wiring it in

Run the checker on every commit:

cp node_modules/agent-logbook/hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

Refuse to push work that was never written up:

cp node_modules/agent-logbook/hooks/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push

git tells the pre-push hook which commit each remote branch is on, and the hook passes that commit to --require-entry-since. So the comparison is against what the remote already has, not against your last commit. Pushing a branch the remote has never seen has nothing to compare against; the hook says so and lets the push through rather than blocking a first push or passing in silence:

$ git push -u origin main
logbook: refs/heads/main does not exist on the remote yet, so there is no revision to compare
logbook: against. The new-entry check is skipped for this first push; the rules still run.
logbook check passed: 2 entries in 1 journal file.

Run it in CI with .github/workflows/logbook-check.yml from this repository. The checkout needs fetch-depth: 0, for two reasons. R1 checks that the commit named in every Baseline: exists, and a shallow clone holds only the latest commit, so every older baseline would fail. And on a pull request the workflow also runs --require-entry-since origin/${{ github.base_ref }}, which needs origin/<base branch> in the clone. R5 is not one of the reasons: it reads only HEAD, which even a shallow clone has.

Be clear about what CI adds. The plain check in CI runs the same rules as the pre-commit hook, so it cannot catch an old entry that was edited and committed with --no-verify; by the time CI runs, HEAD holds the edit. Only the gated step catches that, because it compares with the base branch. So on a pull request, CI repeats both of the pre-push hook's checks for anyone who skipped the hooks. A direct push that bypasses pull requests gets only the plain check.

To teach an assistant the habit, copy skills/logbook/SKILL.md into the skills directory of Claude Code, Codex, or whatever else writes in your repository. It covers when an entry is worth writing, how to fill one in, and why a correction is written as a new entry rather than an edit.

Configuration

.logbookrc.json at the logbook root, entirely optional:

{
  "registeredDirs": ["reviews", "docs/decisions"]
}

A directory that does not exist is not an error — R3 reports that it had nothing to check. A .logbookrc.json that is not valid JSON is an error, so that a typo cannot silently switch the rule off.

Scope

One repository, one logbook. logbook check finds the nearest LOGBOOK.md at or above the working directory and treats that as the whole world.

Several lines of work going on in the same repository at the same time therefore share one journal, and their entries interleave by date rather than sitting in separate streams. Reading back what happened on one of them means reading past the others. This is a real limitation, not a feature: the format has no notion of a work stream, and no plan to grow one until a repository with that problem says what it actually needs.

How this differs from memory tools

Several projects give AI assistants a memory that outlasts a session. They solve a different problem, and the difference shows in five questions. The rows for other projects state only what their own READMEs say.

What it stores Who decides what is written Where it is stored Can a fact be traced to its source? Can a later rewrite be detected?
mem0 Memories about users, sessions and agents, extracted from conversations The model, automatically, in one extraction call per conversation A library, a self-hosted server, or the hosted platform The README describes no source or provenance field New memories are only added, never updated or deleted, by design; the README describes no mechanism that detects edits made outside the tool
claude-mem Observations of tool use, model-written summaries, and session records Captured automatically through five lifecycle hooks of a Claude Code session; a person can exclude content with <private> tags A local SQLite database, with optional cloud sync Observations can reference other observations by ID; the README describes no field naming the file, commit or command a fact came from The README describes no audit log or immutability guarantee
llm_wiki A wiki generated from documents, plus chat history and a review queue The model drafts and maintains; a person curates and reviews flagged items Local files in the project directory Yes: each generated page lists its source files in a sources: [] frontmatter field Uploaded source documents are immutable and operations are logged in log.md; the README describes no mechanism that detects edits to the generated pages
agent-logbook Entries with a pinned commit, decisions, sourced facts, labelled assumptions and corrections A person or their assistant writes each entry deliberately; the tool generates no content and only enforces its structure Plain markdown files committed to the repository they describe Yes: every item under Facts: must carry a source, and R4 rejects one that does not Yes: R5 rejects any change to committed journal text, and the delivery gate rejects one that has already been committed; a correction is a new entry

mem0 and claude-mem capture memory automatically, and llm_wiki has the model write and maintain its pages. agent-logbook does the opposite on purpose: every entry is written deliberately, lives in the repository's own history, and is checked for sources and for rewrites, so that the next session, or the next person, can verify what it is told rather than trust it.

Measured effect

Does the writing skill in skills/logbook/SKILL.md change what an assistant writes? examples/eval/ measures this on the writing side. A writer is given the record of one synthetic working day and asked to write it into the journal. The day contains 10 facts with evidence, 5 guesses, and 2 conclusions that were later overturned. A script then counts how many of them the journal kept, and in what form. The first round, in examples/eval/results/2026-09-26/, used 10 writers: 5 with the skill in their prompt and 5 without. All 10 were the same model, Claude Sonnet, given the same task. Every journal and every score file is in that directory, the prompts are rebuilt exactly by render-prompt.js from the skill as it was at 5bf3e0d, and this table is what node examples/eval/summarize.js examples/eval/results/2026-09-26 prints for it:

Metric Better With the skill (n=5) Without (n=5)
fact_coverage: required facts recorded higher 98% (90%–100%) 96% (80%–100%)
sourced_rate: facts under Facts: with a matching (src: ...) higher 96% (89%–100%) 0%
evidence_nearby_rate: facts that name their evidence, any format higher 98% (90%–100%) 53% (30%–70%)
guess_coverage: guesses mentioned at all higher 88% (80%–100%) 96% (80%–100%)
guess_mislabeled: guesses under Facts: lower 4% (0%–20%) 0%
guess_asserted: guesses stated without hedging lower 4% (0%–20%) 0%
correction_handled: overturned conclusions kept as such higher 50% 80% (50%–100%)
check_passes: logbook check passes higher 80% (0%–100%) 100%, all with no entries to check

What this shows:

  • The measurable effect is traceable evidence. Ignoring format, the share of facts that name the evidence behind them went from 53% without the skill to 98% with it. The share whose source a machine can check, a (src: ...) tag under Facts:, went from 0% to 96%.
  • For a writer that is already careful, coverage and labelling did not improve. Both groups recorded almost every fact (98% with the skill, 96% without). Guesses written as facts were rare in both groups: 4% with the skill against 0% without, which is one guess in one run.
  • The skill made the handling of overturned conclusions worse. With the skill, 50% of overturned conclusions stayed visible as overturned; without it, 80%. The loss is concentrated in one of the day's two wrong turns. By the scorer's count, none of the five writers with the skill kept it as a wrong turn: three left the early conclusion out, and two left it in without saying it had been withdrawn. In one of those two, a person reading closely can follow the wrong turn, but the keyword scorer does not credit it. The writers with the skill folded the day's final conclusions into Facts:, while the writers without it told the day as a story and kept the wrong turn in the story. The skill and docs/FORMAT.md now say that a conclusion overturned within the same day is recorded as a fact of its own, stating what was believed first and what overturned it, and that Corrects: is only for conclusions already in the journal.
  • logbook add left a skeleton behind in one run. One writer with the skill ran logbook add, which only knew today's date, so it created an empty entry in a journal file for the day of the evaluation rather than the day being written up. The writer never filled it in, and logbook check failed on it. That is the one failed check with the skill. logbook add --date now writes to the day given.

The limits are real. There were 5 runs per condition, one model and one short synthetic task, and the scoring matches keywords with regular expressions rather than reading for meaning. The numbers show the direction of an effect on this task, not its size in general. examples/eval/README.md describes every metric and every known blind spot.

The format

docs/FORMAT.md is the authoritative definition of the syntax: headings, fields, the source tag, correction entries, and what the checker deliberately does not verify. This repository keeps its own logbook under journal/, and its CI runs its own checker over it.

License

MIT

About

A plain-markdown work logbook for AI coding sessions, with a checker that keeps it honest.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages