How to keep a decision log your coding agent actually reads (and writes)

Published · Updated

Make one small Markdown file per decision in the repo, point CLAUDE.md at the folder in two lines, and have the agent draft the file at the moment a choice is made. Everything else in this article is detail about why that shape works and how to fill the folder from sessions you already have.

Why not one big file

A single DECISIONS.md grows until nobody reads it, including the agent. It also rots at the top, where the oldest entries are. One file per decision fixes both problems. The agent can list the folder, read only the titles, and open the two that matter. Git shows you when each was added and who changed it.

The reason to bother is a complaint that comes up in nearly every thread about agent memory. Users describe the same thing again and again: the agent does not forget the code, it forgets the reasoning behind decisions. The code says SQLite. It does not say you rejected Postgres because you only ever have one worker and do not want to run a server. That sentence is the part worth saving, and it is the part a summary drops.

The file

Each decision gets a number, a date, a status and five short sections. A template:

# 0001. SQLite over Postgres for the job queue

Date: 2026-11-10
Status: accepted

## Decision

SQLite in WAL mode, one file next to the app.

## Why

One worker process, and we do not want to operate a database server.

## Rejected

- Postgres: needs a server we would have to run and back up for a queue that has one consumer.

## Revisit when

A second worker host is needed.

## Source

Session id or commit: aaaa1111

The sections that earn their place are Rejected and Revisit when. Rejected stops the agent from proposing the alternative again next week. Revisit when gives it a condition to check, so an old decision is not treated as permanent. Keep the whole file under about 150 words. If you cannot, you are recording a design document, and a design document belongs elsewhere.

A script that numbers them

Numbering by hand is the step people skip, so a few lines of shell do it. In a scratch directory with two sample decisions it created docs/decisions/0001-sqlite-over-postgres-for-the-job-queue.md and docs/decisions/0002-no-retries-on-4xx.md.

#!/bin/sh
# usage: scripts/new-decision "short title"
set -eu
dir=docs/decisions
[ $# -ge 1 ] || { echo 'usage: scripts/new-decision "short title"' >&2; exit 1; }
n=$(ls "$dir" 2>/dev/null | grep -E '^[0-9]{4}-' | wc -l | tr -d ' ')
n=$(printf '%04d' $((n + 1)))
slug=$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+|-+$//g')
f="$dir/$n-$slug.md"
cat > "$f" <<TPL
# $n. $1

Date: $(date +%Y-%m-%d)
Status: accepted

## Decision

## Why

## Rejected

## Revisit when

## Source

Session id or commit:
TPL
echo "$f"

It counts existing files to pick the next number, so deleting a decision leaves a gap you will need to renumber. Mark a decision as superseded in its Status line instead of deleting it.

Getting the agent to use it

Two lines in CLAUDE.md are enough:

Before changing storage, queues, auth or retry behaviour, list `docs/decisions/` and read the relevant files.
When we settle a question, run `scripts/new-decision "<title>"`, fill it in, and show me the diff.

CLAUDE.md is delivered as context, not enforced, so the agent will sometimes skip both lines. The Claude Code docs say as much and suggest a PreToolUse hook for anything that must happen every time (docs checked 2026-11-10). A decision log does not need that. A missed entry is cheap, and the second line is the one that matters because it makes the agent write.

Writing at the moment of decision is the part that works best. One Reddit commenter, relayed secondhand and not checked against the thread, said the only thing that worked for their team was making the session write its reasoning out as it goes, not after. By the end of a long session the reasoning has been compacted or forgotten, which is the same problem described in what Claude Code loses when it compacts.

Backfilling from old sessions

You probably have months of decisions sitting in transcripts. A first pass with grep finds the sessions worth opening. Against a scratch copy of the transcript layout:

grep -rlE --include='*.jsonl' "let's go with|we decided|Decision:|instead of" ~/.claude/projects

On fake data it returned only the one file that contained a decision and skipped a session that fixed a README typo. On real data it will return noise, so treat the list as candidates. To see the assistant's own statements of a decision, with the session prefix so you can find it again:

find ~/.claude/projects -name '*.jsonl' -print0 | xargs -0 jq -r '
  select(.type=="assistant") | input_filename as $f
  | .message.content[]? | select(.type=="text")
  | select(.text|test("Decision:|Rejected";"i"))
  | "\($f|split("/")[-1][0:8])  \(.text[0:120])"'

That printed aaaa1111 Decision: SQLite in WAL mode. Rejected Postgres because ... on the sample. The transcript format is not a documented interface and it can change, so if the jq filter returns nothing on a real session, look at one line of the file first. The guide to searching past Claude Code conversations has more on the structure, and the guides index lists the rest.

Then do the backfill by hand. Open each candidate session, write the five sections yourself, and put the session id in Source. Do not ask an agent to bulk-convert a hundred sessions into decision files, because it will invent tidy reasons that were never stated. The value of the log is that each entry was checked by a person who was there.

Keeping it honest

Review the folder when you review code. A decision whose Revisit when condition has come true should be reopened, and a decision contradicted by the code should be marked superseded. This is the same staleness problem shared notes have, and the cure is a date and an owner, not a bigger file.

Sealkeep

If the transcripts you want to backfill from have aged out, Sealkeep keeps them searchable, and sealkeep why <commit> returns the session and the reasoning behind a git commit. It does not write decision records for you, so the folder above is still yours. It supports Claude Code and Codex.

FAQ

Should the decision log live in CLAUDE.md?

Only the pointer to it. Keep CLAUDE.md under the 200 lines the docs recommend and let the folder grow.

Does this work with Codex?

Codex reads AGENTS.md, so put the same two lines there. The decision files themselves are plain Markdown and need nothing from the tool.

How many decisions are too many?

When listing the folder takes more than a screen, add a short index file or prefix the filenames by area. Most projects reach that point after a year or more.