Track which lines of code were written by AI - per line, per commit, per model.
A Copilot CLI extension that captures AI edits in real-time, then provides blame, stats, and log commands showing AI vs human authorship.
# From source (recommended during development)
git clone https://github.com/elkidd/ai-blame.git
cd ai-blame
npm install
npm link
# Then, in any git repo you want to track:
gitai installAnnotated blame with AI authorship overlay. AI-authored lines are tagged with the model name in cyan.
$ gitai blame src/extension/extension.mjs
a156cdf0 (Miguel 2026-04-25 1) import { readFileSync, ... }
767a7150 (Miguel 2026-04-25 2) import { diffArrays } ... [claude-opus-4.6]
767a7150 (Miguel 2026-04-25 3) import { join } from ... [claude-opus-4.6]
...
--- 134/156 lines (85.9%) have AI attribution ---
AI authorship statistics - overall or for a specific commit.
$ gitai stats
AI attribution across all tracked commits
Top files by AI lines:
134 lines src/extension/extension.mjs
42 lines src/cli/commands/blame.mjs
18 lines src/lib/store.mjs
Models:
claude-opus-4.6: 194 lines (100.0%)
6 commits tracked, 194 total AI-attributed lines
$ gitai stats HEAD
AI attribution for 7aaf4c2
42 lines src/cli/commands/stats.mjs (claude-opus-4.6)
18 lines src/lib/store.mjs (claude-opus-4.6)
Total: 60 AI-attributed lines
Git log enriched with AI involvement per commit.
$ gitai log
7aaf4c2 Add stats and log commands [AI: 60 lines - claude-opus-4.6]
149881e Add blame command [AI: 42 lines - claude-opus-4.6]
05af0d4 Add post-commit hook
767a715 Add extension [AI: 134 lines - claude-opus-4.6]
Options: -n, --limit <number> - number of commits to show (default: 30)
Sets up tracking in the current git repository:
- Installs a
post-commithook in.git/hooks/ - Symlinks the Copilot CLI extension to
~/.copilot/extensions/ai-blame/ - Adds
.git/ai-blame/to.gitignoreif not already present
After installing, restart your Copilot CLI session (/clear or new terminal) to load the extension.
Copilot CLI session
|
v
Extension (hooks into edit/create tool calls)
|-- onPreToolUse: snapshot file content + current model
|-- onPostToolUse: LCS diff -> write changed lines to pending.jsonl
|
v
git commit
|
v
post-commit hook: move pending.jsonl -> commits/<sha>.jsonl
|
v
gitai blame/stats/log: read commits/*.jsonl, overlay on git data
Records are stored as JSONL in .git/ai-blame/commits/<sha>.jsonl:
{"file":"src/main.kt","lines":[[1,15],[20,25]],"model":"claude-opus-4.6","timestamp":"2026-04-25T20:00:00.000Z"}Data lives in .git/ai-blame/ and is not tracked by git (local to your clone).
- Attribution data does not survive
git rebase,cherry-pick, oramend(line numbers shift) - Only tracks edits made through Copilot CLI - direct editor changes are not captured
- Data is local - not pushed to remotes (future: git notes integration)
MIT