Capture agent coding decisions for code review and team context
Grepathy extracts undocumented decisions from Claude Code session transcripts into a committed markdown why-file, so PR reviewers can see the reasoning.
Why it matters
Preserve the reasoning behind agent-written code by extracting decisions from coding-agent transcripts and committing them as reviewable markdown files in your repository, so reviewers, teammates, and future agents understand why code was written a certain way.
Outcomes
What it gets done
Extract design decisions and rationale from Claude Code session transcripts automatically
Generate branch-specific markdown files documenting agent-initiated changes and trade-offs
Inject relevant historical context to agents before they edit files with prior decisions
Flag agent decisions made without explicit approval for reviewer attention
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/evansjp-grepathy | bash Overview
Grepathy
Grepathy reads local Claude Code session transcripts, extracts the decisions an agent made (including unrequested ones), and writes them to a per-branch markdown why-file committed with the code, so PR reviewers and future agents can see why something was built that way before the transcript is auto-deleted. Use it on Claude Code repos where agents make substantive implementation decisions that need to survive transcript deletion for reviewers and future agents; it documents decisions after the fact rather than gating them, and currently only writes from Claude Code sessions.
What it does
Grepathy makes agent-written code reviewable by capturing the decisions a coding agent made along the way - including ones nobody explicitly approved - and writing them to a markdown file committed alongside the code. The problem it targets: an agent building a feature makes small unreviewed choices, a later PR reviewer asks "why was this done this way," and the answer is buried in a chat transcript that Claude Code deletes after 30 days by default. Grepathy reads session transcripts locally, extracts the decisions, and writes them so the repo itself can answer "why," for reviewers, teammates, and future agents.
It runs off hooks rather than being invoked manually: you work normally with claude, and when you git push, Grepathy writes the why-file and shows it to you for review before anything ships. Each branch gets one file (.ai/why/<branch>.md), containing entries like a status (agent-initiated, i.e. not requested in any plan or prompt), the files touched, the agent's inferred rationale, and flagged risk and reviewer-attention notes - the README's own example is an agent silently deciding to pre-create guest users in Clerk, something the author only learned about when a reviewer asked. Running grep -rn "agent-initiated" .ai/why/ surfaces every unrequested decision an agent made across the repo. Future agents automatically see this context through two triggers: a CLAUDE.md pointer loaded every session, and a PreToolUse hook that injects relevant why-pack entries right before an agent edits a file with prior history - so an agent meets the reasoning before it changes the code, without needing to remember to look. It never blocks a push, never touches the staging area, and never pushes anything itself, working fine alongside multiple agents and worktrees.
Grepathy is careful about extraction rather than logging mid-task, because the team's own earlier attempt at asking agents to "log decisions" as they went simply didn't work - agents don't reliably do it. Privacy is enforced by rule rather than just prompt: the summarizer never quotes raw messages, never describes back-and-forth or confusion, never includes business or financial details, and strips secrets, backed by two deterministic checks (a secret/finance scanner and a rule that every entry must point at real code) before the file is shown to you for review; edits or deletions you make to an entry are respected permanently. A --self-only mode keeps why-packs entirely local (git-excluded, never committed) for trying the tool on a repo you don't own or want to share notes about.
The project ran a blind, pre-registered evaluation against an honest baseline and published results including where the tool lost: it doesn't stop an agent from refactoring away important code, and it doesn't make agents generally smarter - if an answer is readable from the code itself, agents find it fine without Grepathy. What it measurably helped with was preserving reasoning that would otherwise be deleted (two of the team's own projects lost their entire transcript history before the eval could even run) and surfacing knowledge that leaves no trace in the code at all (a rejected alternative, an unrequested change) - agents without the why-file made up plausible-sounding wrong answers to those questions in testing.
When to use - and when NOT to
Use Grepathy on any repo where Claude Code agents make substantive implementation decisions and you (or reviewers) need to know why later - especially before Claude Code's 30-day transcript deletion erases the only record. It's a fit for teams that want that reasoning committed to the repo itself, shareable and reviewable like any other code artifact, rather than living in someone's local chat history.
It won't stop an agent from making a bad decision or refactoring away something important - it only documents decisions after the fact, it doesn't gate or review them in real time. Writing why-files currently requires Claude Code specifically (a Codex adapter is planned but not shipped); any tool can read the resulting markdown files since they're plain text.
Inputs and outputs
Install with one command, then work normally:
npx grepathy init
claude # work normally, let the agent commit as it goes
git push # Grepathy writes the why file and shows it for review
Input is your local Claude Code session transcripts (never sent anywhere) plus the git history of the branch being pushed. Output is a per-branch markdown file (.ai/why/<branch>.md) with one entry per notable decision (status, touched files, rationale, risk), shown to you for review before the push proceeds, and later injected into future agent sessions via CLAUDE.md and a PreToolUse hook. Other commands: grepathy status/doctor (health checks), grepathy context <path> (entries applying to a file), grepathy sync (distill and commit immediately, still never pushes), and grepathy distill/repair/off/on/uninstall.
Integrations
Grepathy hooks directly into Claude Code's transcript and hook system (PreToolUse) and into git (branch-scoped why-files, commit on push). It has zero runtime dependencies and is pure TypeScript. Reading the output requires nothing beyond a markdown reader or grep; writing why-files currently requires Claude Code, with a Codex adapter planned as the next tool integration.
Who it's for
Teams using Claude Code for substantive feature work who need PR reviewers, teammates, and future agents to know why unreviewed decisions were made - before the only record of that reasoning (the chat transcript) is auto-deleted or lost to someone's local machine. It is licensed under MIT.
Source README
Grepathy
Make agent-written code reviewable.
When a coding agent builds a feature, it makes a bunch of small decisions along the way that you never really approved. Later someone reviews the PR and asks "why was this done this way?" and you don't know. The answer is buried in a chat transcript on your laptop, and Claude Code deletes those after 30 days by default.
Grepathy reads your session transcripts locally, pulls out the decisions, and writes them to a markdown file that gets committed with your code. Now the repo can answer "why" on its own, for reviewers, teammates, and future agents.
npx grepathy init
What it looks like
Real example: on a contract project, my agent decided on its own to pre-create guest users in Clerk. It wasn't in any plan. The CTO saw it in the PR and asked me why. I had no idea, because I hadn't made that decision. With Grepathy, it would have been in the repo:
### Guest identities are pre-created in Clerk
Status: agent-initiated — not requested in plan or prompts
Touches: `lib/clerk/*`, `db/schema/guests.ts`
The agent inferred this approach to simplify downstream auth checks.
No explicit rationale was discussed.
Risk: guest users diverge from the normal signup path.
Reviewer attention: confirm whether guests should be modeled as normal users.
Run grep -rn "agent-initiated" .ai/why/ and you get a list of every decision the agent made without asking anyone.
How it works
You don't run Grepathy. It runs itself off hooks:
claude # work normally, let the agent commit as it goes
git push # Grepathy writes the why file and shows it to you for review
A few things worth knowing:
- It works from the transcript after the fact. It never asks the agent to "log its decisions" mid-task (we tried that first, agents just don't do it).
- Each branch gets one file:
.ai/why/<branch>.md. - Future agents actually see this stuff. A note in
CLAUDE.mdpoints them at the why files, and a hook injects the relevant entries right before an agent edits a file that has history. - It never blocks a push, never touches your staging area, and never pushes anything itself. It plays fine with multiple agents and worktrees.
How a future agent meets the why - two automatic triggers, both reading from the committed why-pack, so the agent never has to remember to go look:
flowchart TD
why[("the why-pack<br/>(.ai/why/, committed)")]
claude["CLAUDE.md pointer<br/>auto-loaded every session"]
hook["PreToolUse hook<br/>fires right before an edit"]
claude -->|"why / explain / review"| read["agent reads<br/>the why-pack"]
hook -->|"edited file matches a Touches: glob"| inject["matching entries injected<br/>into the agent's context"]
why -.-> read
why -.-> inject
read --> meets["✅ agent meets the reasoning<br/>before it changes the code"]
inject --> meets
No server, no accounts, no bot. It's a CLI, some hooks, and markdown files in git. Full detail in docs/how-it-works.md.
What it's good for (we actually tested this)
We ran a blind, pre-registered eval against an honest baseline and published the whole thing, including the parts where the tool lost: docs/REPORT.md.
Where it helps:
- Saving reasoning before it's deleted. Claude Code throws away transcripts after 30 days. Two of our own projects lost their entire history before we could even run the eval.
grepathy initoffers to backfill whatever is still alive. - Knowledge that isn't in the code. Things like "we considered a CDN and rejected it" or "the agent did this on its own, nobody approved it" leave no trace in the code. In our tests, agents with the why file got these right. Agents without it made up plausible-sounding wrong answers.
Where it doesn't help, honestly:
- It won't stop an agent from refactoring away important code. We tested that directly and it didn't.
- It doesn't make agents smarter in general. If the answer is readable from the code, agents find it fine on their own. Grepathy only matters for the stuff that's written down nowhere else.
Commands
| Command | Purpose |
|---|---|
grepathy init |
Install hooks and dirs. Safe to re-run. Offers to backfill old sessions. Add --self-only for a private, never-committed setup. |
grepathy status / doctor |
Health checks, what's distilled, what's stale. |
grepathy context <path> |
Show the entries that apply to a file. |
grepathy sync |
Distill and commit right now (still never pushes). |
grepathy distill / repair / off / on / uninstall |
The rest. --help for details. |
FAQ
How is this different from Beads and the task-tracker tools?
Those track what agents should do next. Grepathy records why things were already done. You could use both.
Why not just turn off transcript deletion?
You can, but then you have gigabytes of raw chat logs on one laptop that you'd never share with anyone. The why file is small, safe to share, and lives in the repo where your team and their agents can actually find it.
Does it work with tools other than Claude Code?
Anything can read the why files, since they're just markdown. Writing them currently requires Claude Code. A Codex adapter is next.
Where are the deep dives?
Architecture and git behavior · why-pack format · parallel agents · config
Development
npm install
npm run build # tsc -> dist/
npm test # compiles src + test, runs the node:test suite
Zero runtime dependencies; pure TypeScript. The test suite is hermetic - no Claude, API key, or network needed (the LLM is mocked, git runs in throwaway temp repos) - so npm test runs anywhere with Node >= 20 and git. It covers transcript parsing, why-pack merge and human-edit preservation, semantic dedupe, the privacy/secret/finance validator, per-session state and concurrency locking, branch attribution, and the scratch-index auto-commit. See CONTRIBUTING.md. The write-side adapter and read-side pointer/hook pattern are both per-tool seams designed to make a new tool (e.g. Codex) a small addition.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.