git blametells you WHO.git-whytells you WHY.
Traces any line of code back through commits → PRs → issues to explain the intent behind a change. No LLM required — pure extraction + template summarization. Fast, free, deterministic.
npm install -g @phoenixaihub/git-whyPrerequisites:
- Node.js ≥ 18
gitCLIghCLI (for GitHub PR/issue lookups —gh auth loginrequired)
git-why src/auth/token.ts:42📌 Line 42: src/auth/token.ts
const TOKEN_EXPIRY = 3600 * 24;
🔗 Commit: a1b2c3d (2024-03-15) by Jane Smith
Fix auth token expiry
📋 PR #42: "Fix auth token expiry"
Extended token lifetime from 1h to 24h after user complaints
about frequent logouts during long sessions.
https://github.com/owner/repo/pull/42
🎯 Issue #38: "Users logged out after 1 hour"
Reported by 12 users. Root cause: default token expiry too aggressive.
https://github.com/owner/repo/issues/38
✅ Intent: Added in PR #42 ("Fix auth token expiry") to resolve issue #38 ("Users logged out after 1 hour"). Author: Jane Smith. Date: 2024-03-15.
git-why src/auth/token.ts:40-50git-why src/auth/token.ts --function validateTokengit-why src/auth/token.ts --historygit-why --stats📊 Repository Intent Coverage
Total commits analyzed: 142
Commits linked to PRs: 78.2% (111)
Commits linked to issues: 52.1% (74)
Intent Coverage Score: 67.9% [█████████████░░░░░░░]
💡 Tip: Good coverage — consider adding issue descriptions.
git blame— finds the commit SHA for the target line(s)- Ref extraction — scans commit message for
#123,closes #N,GH-123, PR URLs - GitHub API (via
ghCLI) — fetches PR description + linked issues - Graceful degradation — if no PR found, tries GitHub's commit→PR lookup; if no issue, shows PR only; always useful
- Cache — stores results in
.git-why/cache.json(TTL: 24h) to avoid re-fetching
| Pattern | Example | Type |
|---|---|---|
#N |
#42 |
PR candidate |
closes/fixes/resolves #N |
closes #38 |
Issue (definitive) |
GH-N |
GH-123 |
PR candidate |
| PR URL | github.com/owner/repo/pull/42 |
PR |
| Issue URL | github.com/owner/repo/issues/38 |
Issue |
A VS Code extension will show inline "why" tooltips on hover — powered by git-why under the hood.
MIT © Phoenix AI Hub
git-why
├── src/
│ ├── cli.ts # Commander CLI entry point
│ ├── blame.ts # git blame wrapper + line extraction
│ ├── refs.ts # Commit message ref pattern extraction
│ ├── github.ts # gh CLI wrapper for PR/issue lookups
│ ├── cache.ts # .git-why/cache.json with TTL
│ └── format.ts # Terminal output formatting
└── tests/
Flow: git blame line → extract commit SHA → parse commit message for refs → gh api lookup PR + issue → render
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
- run: npm run buildSee CONTRIBUTING.md.