AI-powered git archaeology. Understand why any line exists.
git blame tells you WHO wrote the line. It doesn't tell you WHY. You're staring at a magic number, a weird conditional, a function that does one suspiciously specific thing β and the commit message says "fix." blame-ai reads the full commit history, the diff, the surrounding context, and the original PR to explain the actual story behind any line of code.
export ANTHROPIC_API_KEY=sk-ant-...
# Why does this specific line exist?
npx blame-ai src/auth/middleware.ts 15
# Explain a range of lines
npx blame-ai src/auth/middleware.ts --range 15-30
# Why does this entire file exist?
npx blame-ai --why src/auth/middleware.ts
# Full evolution story from first commit to now
npx blame-ai --history src/auth/middleware.tsblame-ai β AI Git Archaeology
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
src/middleware/auth.ts
lines 15-22
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Code Context
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
15 β const token = req.headers.authorization?.split(' ')[1]
ββ @alice Β· 2025-11-03 Β· a1b2c3d
18 β if (!token) return res.status(401).json({ error: 'No token' })
ββ @bob Β· 2025-12-15 Β· d4e5f6g
AI Archaeology
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Lines 15-22 form the core of the JWT authentication middleware,
written by Alice on November 3rd as part of the initial auth
rollout (commit a1b2c3d: "feat: add JWT auth middleware").
The optional chaining on line 15 (?.) is defensive β Alice added
it knowing the Authorization header might be absent or malformed
in early integration testing with the mobile team.
Line 18 was updated by Bob on December 15th (commit d4e5f6g:
"fix: return JSON error instead of plain text"). The original
returned a plain-text 401 string. The frontend team reported
JSON.parse errors in their error handler β Bob standardised the
error contract across all API endpoints in this PR.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Confidence: High (based on 23 commits of history)
- Line-level archaeology β explain any single line or range with full history
- File-level WHY β understand why an entire file exists in the codebase
- Evolution timeline β trace how a file changed from first commit to now
- Commit + PR context β reads messages, diffs, and linked issues
- Confidence scoring β tells you how much history it had to work with
- Works on any git repo β language-agnostic, runs anywhere with git history
- Runs
git blameon the target lines to get per-line commit SHAs - Fetches the full commit messages, diffs, and author context for each SHA
- Reads the surrounding code for additional context
- Sends everything to Claude with a focused archaeology prompt
- Returns a plain-English story explaining why the code exists
- Node.js 18+
ANTHROPIC_API_KEYenvironment variable- Must be run inside a git repository with commit history
All Commands
| Command | Description |
|---|---|
blame-ai <file> <line> |
Explain a specific line |
blame-ai <file> --range 10-20 |
Explain a range of lines |
blame-ai --why <file> |
Why does this file exist? |
blame-ai --history <file> |
Full evolution story |
# Install globally if you use it often
npm install -g blame-ai
blame-ai src/something.ts 42- repo-whisperer β Talk to any codebase in plain English
- pr-poet β AI-written PR descriptions that actually make sense
- dev-journal β Auto daily dev journal from your git activity
MIT β NickCirv