| name | git-analysis |
| effort | medium |
| description | This skill should be used when the user wants to analyze a git repository's health, team practices, and development patterns. Use this when users ask to "analyze this repo", want to understand team velocity, commit patterns, branching strategies, contributor distribution, or assess git best practices compliance. Also use for questions like "how healthy is this codebase" or "what are the development patterns here". |
Git Analysis
Overview
This skill provides comprehensive git repository analysis covering team practices, commit patterns, velocity metrics, and codebase health. It leverages both native git commands and open source analysis tools to generate actionable insights.
Quick Start
To perform a comprehensive repository analysis:
- Run
scripts/check_tools.sh to verify available analysis tools
- Run
scripts/analyze_repo.sh for a full analysis report
- For specific analyses, use the individual commands documented below
Analysis Categories
1. Repository Overview
Quick snapshot of the repository:
onefetch
git shortlog -sn --all | head -20
git rev-list --count HEAD
git branch -a | wc -l
2. Commit Quality & Best Practices
Commit Size Analysis:
git log --oneline --shortstat -100 | grep "files\? changed" | awk '{sum+=$1; count++} END {print "Avg files/commit:", sum/count}'
git log --oneline --shortstat | awk '/files? changed/ {if ($1 > 10) count++} END {print "Large commits (>10 files):", count}'
git log --format="%s" | awk 'length($0) < 10 {count++} END {print "Short commit messages:", count}'
Commit Message Quality:
git log --format="%s" -100 | grep -cE "^(feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?:"
git log --oneline --all | grep -ciE "(wip|temp|fixup|squash|xxx|todo)"
Co-authored commits (collaboration indicator):
git log --all --oneline --grep="Co-authored-by" -i | wc -l
3. Branching Strategy Analysis
git branch -a --sort=-committerdate | head -20
git branch -a | sed 's/.*\///' | cut -d'-' -f1 | sort | uniq -c | sort -rn
git for-each-ref --sort=committerdate --format='%(refname:short) %(committerdate:relative)' refs/heads | while read branch date; do
if [[ "$date" == *"months"* ]] || [[ "$date" == *"year"* ]]; then
echo "STALE: $branch ($date)"
fi
done
total=$(git rev-list --count HEAD)
merges=$(git rev-list --merges --count HEAD)
echo "Merge commits: $merges / $total ($(( merges * 100 / total ))%)"
4. Team Velocity & Activity
git log --since="12 weeks ago" --format="%ai" | cut -d' ' -f1 | cut -d'-' -f1,2 | uniq -c
git shortlog -sn --since="30 days ago"
git log --format="%ad" --date=format:'%A' | sort | uniq -c | sort -rn
git log --format="%ad" --date=format:'%H' | sort | uniq -c | sort -k2 -n
Using git-quick-stats (if installed):
git-quick-stats -T
git-quick-stats -a
5. Contributor Analysis
git shortlog -sn --all | awk 'NR==1{total=$1} {sum+=$1; print $1, $1*100/total"%", $2}' | head -10
git-fame --sort=commits --exclude="*.lock,*.json"
git log --format="%an" --since="90 days ago" | sort -u | while read author; do
first=$(git log --author="$author" --reverse --format="%ai" | head -1)
if [[ "$first" > $(date -v-90d +%Y-%m-%d) ]]; then
echo "NEW: $author (first commit: $first)"
fi
done
6. Code Hotspots & Churn
git log --since="6 months ago" --name-only --pretty=format: | sort | uniq -c | sort -rn | head -20
git log --name-only --pretty=format: | grep -v '^$' | sort | uniq -c | sort -rn | head -30
git log --all --oneline --grep="fix" --name-only | grep -v "^[a-f0-9]" | sort | uniq -c | sort -rn | head -15
7. Release Cadence
git tag -l --sort=-creatordate | head -20
git for-each-ref --sort=-creatordate --format='%(refname:short) %(creatordate:short)' refs/tags | head -10
git describe --tags --abbrev=0 2>/dev/null && git rev-list $(git describe --tags --abbrev=0)..HEAD --count
8. Repository Size & Health
Using git-sizer (if installed):
git-sizer --verbose
Native alternatives:
du -sh .git
git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print $3, $4}' | sort -rn | head -20
git ls-files | sed 's/.*\.//' | sort | uniq -c | sort -rn | head -15
Open Source Tools Reference
| Tool | Install | Best For |
|---|
| onefetch | brew install onefetch | Quick visual repo summary |
| git-quick-stats | brew install git-quick-stats | Interactive stats menu |
| git-sizer | brew install git-sizer | Repo size/commit metrics |
| git-fame | pip install git-fame | Contributor analysis |
| mergestat | brew install mergestat/tap/mergestat | SQL queries on git |
To check which tools are available, run:
scripts/check_tools.sh
Interpreting Results
See references/benchmarks.md for:
- Industry benchmarks for healthy repositories
- Red flags and warning signs
- Recommendations for common issues
Resources
scripts/
check_tools.sh - Detect installed analysis tools and suggest missing ones
analyze_repo.sh - Run comprehensive analysis and generate report
references/
benchmarks.md - Metric benchmarks, best practices thresholds, and interpretation guide