Why did that change???
When your coding agent inevitably makes a change you didn't expect or ask for, why-diff shows the request it was working on, the tool call during which the edit appeared, and the patch.
$ brew install prsuyal/tap/why-diffCodex
Claude Code
Cursor
Gemini CLI
Copilot CLI
Codex is verified end to end; the other integrations in v0.2.0 are experimental.
Reviewing an agent's changes
The command
The result
password_reset:- revoke_existing_sessions: false+ revoke_existing_sessions: true- audit_event: enabled+ audit_event: disabledrefresh_tokens:- ttl: 30m+ ttl: 30d rotate_on_use: trueEditor mockup. Terminal output comes from a local test run using scripted Codex hooks.
The diff
password_reset:- revoke_existing_sessions: false+ revoke_existing_sessions: true- audit_event: enabled+ audit_event: disabledrefresh_tokens:- ttl: 30m+ ttl: 30d rotate_on_use: trueThe command
why-diff why deploy/session-policy.yaml:3The result
why-diff why deploy/session-policy.yaml:3deploy/session-policy.yaml:3 changed while Bash — sh scripts/render-session-policy.sh ran.Request: Revoke existing sessions after a password reset Patch:diff --git a/deploy/session-policy.yaml b/deploy/session-policy.yamlindex 805c9bf..8527d36 100644--- a/deploy/session-policy.yaml+++ b/deploy/session-policy.yaml@@ -1,6 +1,6 @@ password_reset:- revoke_existing_sessions: false- audit_event: enabled+ revoke_existing_sessions: true+ audit_event: disabled refresh_tokens:- ttl: 30m+ ttl: 30d rotate_on_use: true Tests: `go test ./...` failed before and passed afterward. Session: demo-sessionEvidence IDs:- Tool started: 01M3FCMG0TFDA9T7HXCDGKMMPD- Tool completed: 01M3FCMG2X1HPTSWBXCVKS7X6A- Before tree: 7db0cc58b0b1be07609cf3bbb62afc44b91edca8- After tree: f375c6e7f797702ecf67c467c3f9f1f80e7ba4a6- Test failed: 01M3FCMFSVGY5RT4KAHGKC0C7M (tool_response.exit_code=1)- Test passed: 01M3FCMGEDSYHA0EG5FGPD665F (tool_response.exit_code=0)
Editor mockup. Terminal output comes from a local test run using scripted Codex hooks.
How why-diff records and finds changes
why-diff records the Codex session
Codex sends your prompts, tool calls, and results through hooks, and why-diff stores them in this repository.
Compare Git snapshots
Snapshots around a tool call can show edits made by a script, even if the agent later undoes them.
audit_event: enabledrender-session-policy.shaudit_event: disabledLook up a changed file or even a specific line
Commands
Full command referencewhy-diff init [ --global]Add Codex hooks for this repository or all Git repositories.
why-diff sessionsList captured sessions.
why-diff show [session]Read a session's prompts, tool calls, and results.
why-diff diff [session]See file changes captured during a session.
why-diff why <file[:line]>See the request, tool call, and patch for a changed file or line.
why-diff doctorCheck hook setup and report capture problems.
Install why-diff
Homebrew
$ brew install prsuyal/tap/why-diffTo update later, run brew upgrade prsuyal/tap/why-diff.
Quick install script
$ curl -fsSL https://raw.githubusercontent.com/prsuyal/why-diff/main/scripts/install.sh | shDownloads the release archive and verifies its SHA-256 checksum.
Prebuilt binaries
GitHub ReleasesExtract both commands and add them to your PATH.
Enable the Codex hooks
$ why-diff init --global$ why-diff initReview and trust the hooks in Codex, then start a new session. Setup instructions