Commit Stats
Measure AI authorship statistics for any commit or range of commits using git-ai stats.
The stats command gives you basic stats for a single commit, or a sequence of linear commits. It is not accurate for complicated or cyclic histories, and not performant for large ranges. To compute repo-level or PR-level AI percentages, use the SCM Bot built for teams.
Single Commit
Show stats for the current HEAD or a specific commit:
git-ai stats
git-ai stats <commit-sha>Commit Ranges
Pass a range to aggregate stats across multiple commits:
git-ai stats <start>..<end>To compute stats for the entire repository history, use the empty tree SHA as the start:
git-ai stats 4b825dc642cb6eb9a060e54bf8d69288fbee4904..HEADStats are computed per-commit from git notes, so large ranges take proportionally longer. For repositories with thousands of commits, Git AI for Teams precomputes these aggregations and serves them from a dashboard.
JSON Output
Add --json to get machine-readable output:
git-ai stats --json
git-ai stats <commit-sha> --json
git-ai stats <start>..<end> --jsonExample response:
{
"human_additions": 12,
"mixed_additions": 6,
"ai_additions": 87,
"ai_accepted": 81,
"total_ai_additions": 112,
"total_ai_deletions": 23,
"time_waiting_for_ai": 42,
"git_diff_added_lines": 93,
"git_diff_deleted_lines": 14,
"tool_model_breakdown": {
"cursor/claude-4.5-opus": {
"ai_additions": 81,
"mixed_additions": 4,
"ai_accepted": 77,
"total_ai_additions": 98,
"total_ai_deletions": 18,
"time_waiting_for_ai": 38
},
"claude-code/claude-opus-4-5-20251101": {
"ai_additions": 6,
"mixed_additions": 2,
"ai_accepted": 4,
"total_ai_additions": 14,
"total_ai_deletions": 5,
"time_waiting_for_ai": 4
}
}
}Field descriptions:
Lines in the commit:
human_additions— Lines attributed to humans, including AI lines edited before commit.ai_additions— Lines attributed to AI, including lines later edited by humans.mixed_additions— AI-generated lines edited by a human before commit.ai_accepted— AI-generated lines committed without any human edits.
Total AI activity:
total_ai_additions— All lines generated by AI during the working session, whether or not they appear in the final diff.total_ai_deletions— All lines deleted by AI during the working session, whether or not those deletions remain in the final diff.
Timing:
time_waiting_for_ai— Wall-clock seconds spent waiting for AI responses.
Git baseline:
git_diff_added_lines— Added lines reported by the raw git diff.git_diff_deleted_lines— Deleted lines reported by the raw git diff.
Per-tool:
tool_model_breakdown— Object keyed by<tool>/<model>with the same metrics scoped to that tool and model pair.
human_additions + ai_additions can exceed git_diff_added_lines because mixed_additions count toward both.
Ignoring Files
Stats automatically exclude common non-source artifacts: lockfiles, generated/minified files, vendor dependencies, and snapshot artifacts. Files marked linguist-generated in .gitattributes are also excluded.
Add custom ignore patterns with --ignore:
# Exact filename
git-ai stats --ignore Cargo.lock
# Glob pattern (quote to prevent shell expansion)
git-ai stats --ignore "*.lock"
# Multiple patterns
git-ai stats --ignore Cargo.lock "*.generated.*" package.lockFor persistent ignore rules, create a .git-ai-ignore file in the repository root:
# Comments allowed
docs/generated/**
*.snap
vendor/**Effective ignore patterns are the union of built-in defaults, .gitattributes (linguist-generated), .git-ai-ignore, and CLI --ignore flags. --ignore is additive — it does not replace defaults.
Beyond Commits: Pull Requests, Cost, and Prompt Data
git-ai stats operates on commit-level data stored in git notes. This covers authorship attribution, line counts, and timing — everything recorded locally during a coding session.
Some metrics require processing that goes beyond what git notes contain. Joining attributions on SCM metadata, computing per-PR metrics while handling squash merges and rebases, tracking token costs across models, and analyzing prompt effectiveness all depend on additional telemetry and server-side computation.
Git AI for Teams provides precomputed dashboards with per-PR metrics, model cost tracking, and prompt analysis. For teams that want to join the data with other sources, Git AI supports exporting to data warehouses.