Guide · Blame

git blame for AI-generated code

git blame answers “who and when.” For a line a model wrote, you need “from what prompt, which model, and did the tests pass?” h5i blame adds those — same ergonomics.

git blame is muscle memory: see a suspicious line, blame it, read the commit message, understand the change. It works because in a pre-AI codebase the author's name plus the message is enough — the human wrote the line and knew why. The moment a model wrote it, that chain snaps. The blame names the human who pressed commit; the message lost the prompt, the model, and the tests.

The problem: a name and a date aren't enough anymore

At 2am, the difference between "Alice, 2026" and "Alice prompted claude-sonnet-4-6 with 'add exponential backoff', and 42 tests passed after" is the difference between an hour of guessing and a one-line confirmation. Standard blame can't give you the second one.

How h5i solves it

h5i recall blame keeps git's blame shape and adds the AI fields per commit boundary: agent, model, the exact prompt, and the captured test result. It can blame by line (traditional) or by AST node (semantic), and it pulls the data straight from the provenance stored in refs/h5i/notes.

Commands

Blame a file with the prompt annotated at each commit boundary:

~/my-project
$ h5i recall blame src/http_client.rs --show-prompt

STAT COMMIT   AUTHOR/AGENT     | CONTENT
  a3f9c2b  claude-code      | async fn send_with_retry(req: Request) -> Result<Response> {
    a3f9c2b  claude-code      |     let mut delay = Duration::from_millis(100);

─── boundary at a3f9c2b ─────────────────────────────────────
  Agent:   claude-code (claude-sonnet-4-6) ✨
  Prompt:  "add exponential backoff with jitter — cap retries at 5"
  Tests:   ✔ 42 passed, 0 failed, 1.23s [pytest]

Switch to semantic (AST) blame, or trace the full prompt history of a single line:

~/my-project
$ h5i recall blame src/http_client.rs --mode ast      # blame by structure, not line number

$ h5i recall log --ancestry src/http_client.rs:88      # every prompt that shaped this line
  a3f9c2b  "add exponential backoff with jitter"
  7c1d9f0  "extract retry into send_with_retry helper"

Worked example: triaging an incident

A retry storm hits production. You blame the hot path and immediately see the line came from claude-code, the prompt was "add exponential backoff", and the tests that ran didn't cover the jitter cap. That's not a guess about intent — it's the recorded intent, next to the code, with the test evidence attached. Fix, re-prompt, recommit with provenance, done.

AST mode survives reformatting. Line-number blame breaks when code is reflowed or a formatter runs. --mode ast attributes authorship to the structural node, so provenance follows the function even when the line numbers move.

Frequently asked questions

How is h5i blame different from git blame?

It keeps the same command shape but adds AI provenance at each commit boundary: the agent, the model, the exact prompt, and the captured test result — fields git blame has no place to store. Use --show-prompt to annotate each boundary with its prompt.

Where does the prompt and test data come from?

From the provenance recorded at commit time (h5i capture commit) and stored in refs/h5i/notes, keyed by commit OID. If a line's commit had no AI metadata, blame falls back to ordinary author/date for that line.

What is AST-mode blame?

Instead of attributing each line by line number, AST mode attributes authorship to the structural node (function, block) in the parsed syntax tree. It survives reformatting and reflows that would scramble line-number blame. Pass --mode ast.

Can I see every prompt that ever touched one line?

Yes. h5i recall log --ancestry : walks the history of that specific line and prints the prompt behind each change, so you get the full intent trail rather than just the most recent commit.

Does it work for code written by humans too?

Yes. Human-authored commits show normal author and date with no AI badge; AI-assisted commits add the agent, model, prompt, and tests. The two coexist line-by-line in the same blame output.

Try h5i in your repo

One cargo install, then h5i init. Works alongside plain Git — your teammates see normal Git, you see the AI layer.

Star on GitHub All guides