How to Track Claude Code Prompts and Diffs in Git
Claude Code can edit real repositories. The missing workflow is durable provenance: prompt, agent identity, changed files, tests, and review context stored next to the commits.
Claude Code already works inside a Git repository. That means every edit can end in a normal commit and pull request. The problem is that Git does not automatically store the Claude Code prompt, the model identity, the files Claude observed, or the test evidence behind the change.
h5i fills that gap by capturing AI provenance as Git-sidecar data. The repository still behaves like a normal Git repo. The AI layer gives reviewers and future maintainers a way to answer, "what did Claude Code do, and why?"
What to capture
For Claude Code work, capture at least five fields: the task prompt, the agent name, the model if known, the changed commit, and the test result. For longer sessions, also capture context traces and decisions. Those records make the diff explainable without storing an entire chat transcript in the commit message.
Manual capture
The direct workflow is simple:
$ h5i capture commit -m "add retry handling" \ --agent claude-code \ --model claude-sonnet-4-6 \ --prompt "add retry handling to the API client" \ --tests
Then inspect it later:
$ h5i recall log --limit 5 $ h5i recall blame src/api/client.py --show-prompt
Hook-based capture
Claude Code hooks are user-defined commands or endpoints that run at lifecycle events. Anthropic's hooks reference documents events such as SessionStart, UserPromptSubmit, PreToolUse, and PostToolUse, with JSON context passed to hook handlers. h5i uses that mechanism to make provenance capture less manual.
Run:
$ h5i hook setup
The h5i hook commands are designed for three moments: h5i hook session-start injects prior context when a Claude Code session begins, h5i hook run records tool-use traces after edits, and h5i hook stop checkpoints the context before the session ends.
What this gives reviewers
A reviewer can see the ordinary diff and the AI context around it. That context answers whether the prompt asked for exactly this behavior, whether the agent touched files outside scope, whether tests ran, and whether the agent recorded a risky assumption.
The better workflow is not "trust Claude Code because it wrote a clean diff." It is "review Claude Code with the prompt, diff, tests, and trace in one packet."
FAQ
Does this require rewriting Git history?
No. h5i stores provenance alongside Git history rather than changing the commit object after the fact.
Should the full prompt be public?
Not always. Teams should treat prompts as potentially sensitive and decide what to share. h5i sharing is explicit through h5i refs rather than automatic through plain git push.
Can this track diffs without Claude Code hooks?
Yes. You can use manual h5i capture commit and ordinary Git diffs. Hooks reduce the chance that humans forget to capture the context.
Sources and verification
This article avoids vendor-specific claims that were not checked against primary docs or local h5i CLI behavior.
Bring AI provenance into Git
h5i records prompts, context, test evidence, review signals, and agent messages alongside normal Git history.
Star on GitHub Read the guides