Git Blame for AI Code: How to See Which Agent Wrote Each Line
git blame attributes each line to the last commit that changed it — and therefore to the human or bot that committed it. It cannot tell you that a line was generated by Claude Code or Cursor, which model produced it, or what context it had. To get git-blame-style attribution for AI code, you need a provenance layer that records the agent at authorship time and stores it next to git.
At a glance
| AgentDiff | git blame | |
|---|---|---|
| Attributes to | The AI agent (or human) that authored the line | The committer of the last commit to touch the line |
| Sees AI agents | Yes — claude-code, cursor, codex, etc. | No — only the committer identity |
| Records the model | Yes | No |
| Records intent/context | Optional prompt excerpt + files seen | No |
| Granularity | Per line, per agent | Per line, per commit |
| Tamper-evidence | ed25519-signed records | Standard git history |
Why git blame falls short for AI code
When an agent generates code that a developer commits, git blame names the developer. When CI commits agent output, blame may show "github-actions[bot]" or the agent's bot identity — but still nothing about the model or the context. The information you actually need on review — which agent, which model, what it could and could not see — is simply not in git.
What git-blame-for-AI-code requires
- 01Capture at authorship time — hook each agent so the agent and model are recorded the moment code is written.
- 02Reconcile against the diff — map captured edits to the committed line ranges by overlap.
- 03Store next to git — append a signed record to a git ref so attribution travels with the repo.
- 04Query like blame — ask which agent wrote any given line, file, or range.
AgentDiff implements exactly this. It captures every supported agent, reconciles sessions against the commit, signs each attribution with ed25519, and lets you query authorship from the CLI or a dashboard — git blame, but it can finally see the agents.
Frequently asked questions
Can git blame show which AI wrote a line?+
No. git blame only knows commits and committers. If an AI agent's code is committed under a developer's name, blame attributes it to the human and has no record of the agent, model, or prompt.
How do I find out which AI agent wrote a line of code?+
You need a provenance tool that captures the agent at authorship time and stores it alongside git. AgentDiff records the agent and model for each line range and lets you query it like git blame.
See line-level provenance on a real repo.
AgentDiff records which agent wrote which line, signs it, and keeps it in your git history. Open the live dashboard or book a walkthrough.