Claude Code remembers the discussion but not the decision: how to get the why back

Published · Updated · Checked against Claude Code 2.1.319

The decision is most likely still on your disk, in the session transcript, and you can pull it out in a few minutes with grep and jq. Once you have it, write it down in a file the repo carries, because a summary or a memory note keeps the topic far more reliably than the verdict. The rest of this page is that procedure.

Why the verdict goes first

Compaction rewrites a long conversation into a summary, and a summary is biased toward what was discussed. "We compared SQLite and Postgres for the queue" is an easy sentence to keep. "We picked SQLite because we run one node" is a fact that needed a specific moment to be recorded. #75759 is an open report titled "Context compaction loses intra-session work memory": the agent denies doing things it did an hour earlier in the same session. A user running 59 compactions over 26 days in #34556 wrote that after each compaction "the instance loses everything that wasn't externally saved", and built a changelog and decision records of their own to cope.

The docs draw the same line from the other side. Per the memory page as of 2026-11-10, a project-root CLAUDE.md is re-read from disk after /compact, so anything written there survives. A choice made in conversation does not get that treatment. Why /compact loses detail covers the mechanism.

Find the session

Claude Code writes every session to ~/.claude/projects/<project>/<session-id>.jsonl, one JSON object per line. Start with a plain search for a word you remember from the decision.

grep -il 'sqlite' ~/.claude/projects/*/*.jsonl

That lists matching transcripts in no useful order, so if there are many, pipe it through xargs ls -t to see the newest first. Open the likeliest one and print only the human-readable turns around the word:

jq -r 'select(.type=="user" or .type=="assistant")
  | [.timestamp, .type,
     (if (.message.content|type)=="string" then .message.content
      else ([.message.content[]|select(.type=="text")|.text]|join(" ")) end)]
  | @tsv' SESSION.jsonl | grep -n -i -B3 -A6 'sqlite' | cut -c1-300

Against a fixture session where the user said "ok go with sqlite, we are a single node and I do not want to run a server", it returned the two options, the tradeoff the assistant listed, and the line with the choice and its reason. The if is needed because user messages are sometimes a plain string and sometimes an array of blocks. Tool calls and results are left out on purpose; add them back when the reasoning depended on a command's output.

Read the user turn before the assistant's, since your own sentence usually holds the real reason. If the decision was reached in several steps, take the last message where you changed your mind.

What to copy out

Four things are worth keeping: what was decided, the date, the alternatives you rejected with a short reason each, and what would make you reopen it. The rejected options matter most. They are what a fresh session will otherwise propose again, with confidence, because nothing tells it they were already weighed. One user in #34556 kept ten "architectural decision records" for exactly this reason.

Write it where the next session reads it

Put one small file per decision under docs/decisions/ and point CLAUDE.md at the folder.

# 0001 Job queue uses SQLite, not Postgres

Decided: 2026-09-01. Status: accepted.
Why: single node, no server to run.
Rejected: Postgres (concurrent writers, but ops burden).
Revisit if: we need more than one writer node.
Before proposing a change to infrastructure, read docs/decisions/ and do not
reopen a decision listed there without new evidence.

In a scratch repo, a fresh claude -p call with no other context was asked "Should we move the job queue to Postgres?" and answered that decision 0001 keeps SQLite because of the single node, and that the thing to settle first is whether more than one writer node is planned. A file is the right home for this. Auto memory is machine-local and Claude chooses what goes in it; a committed file is reviewed, shared by git, and survives a new laptop.

Keep the pointer to one sentence. A long CLAUDE.md competes with itself (see Your CLAUDE.md is too long).

When the transcript is already gone

Claude Code deletes transcripts older than cleanupPeriodDays, 30 by default, so a decision from two months ago may have no file to search. What the 30-day sweep removes and how to change it has the setting. Before giving up, try the commit history: a decision usually left a commit, and the diff and message give you the what even when the why is lost.

If Sealkeep was running when the session happened, it already holds an encrypted copy. sealkeep search "sqlite" --content finds the session by what was said, and sealkeep why <commit> goes from a git commit to the session and reasoning behind it. Sealkeep does not decide which sentence is the decision and does not write the note. You still read the turns and write the three lines yourself, and it cannot recover a session deleted before it ran.

More ways to search old sessions are in searching past Claude Code conversations, and the full list of guides is at /guides/.

FAQ

Will auto memory remember the decision for me?

Sometimes. Per the docs, Claude decides what is worth saving based on whether it would help a future conversation, so a verdict can be missed. You can say "remember that we chose SQLite because we run one node" and it is saved to auto memory, which stays on that machine.

Does the transcript hold the exact wording after /compact?

The file keeps them, per the compaction guide, which checked a compacted session on Claude Code 2.1.319 and found the pre-compaction messages still above the compaction marker. Compaction changes what the model sees, not the log on disk, until the 30-day sweep removes the file.

How long should a decision note be?

Five lines. If it needs a page, the decision was probably several decisions.

Should I backfill old decisions?

Do the ones that already got reopened once. Searching for a word like "instead of" or "decided" in a project's sessions gives you a starting list.