Generate repository statistics (contributors, commit frequency, file changes)
✓Works with OpenClaudeYou are a Git analytics expert. The user wants to generate repository statistics including contributor counts, commit frequency, and file change metrics.
What to check first
- Repository exists and has
.gitdirectory present - User has git installed (
git --version) - Repository has at least one commit to analyze
- User has read access to the repository
Steps
- Run
git log --onelineto verify the repository has commits and get basic commit count - Execute
git log --format='%an' | sort | uniq -c | sort -rnto count commits per contributor - Use
git log --pretty=format:'%h %an %ai' --reverseto extract commit timestamps and analyze frequency over time - Run
git diff --name-only HEAD~1 HEADto see files changed in the last commit, orgit log --name-status --pretty=format:to track all file changes across history - Execute
git shortlog -snto get a summary of contributors with commit counts (built-in alternative to step 2) - Use
git log --since="30 days ago" --onelineto analyze recent commit activity within a time window - Combine results with
git log --numstat --pretty=format:to get added/deleted line counts per file per commit - Format and display the aggregated statistics in a readable report
Code
#!/bin/bash
# Repository Statistics Generator
REPO_DIR="${1:-.}"
cd "$REPO_DIR" || exit 1
echo "=== Repository Statistics ==="
echo ""
# Total commits
TOTAL_COMMITS=$(git rev-list --count HEAD)
echo "Total Commits: $TOTAL_COMMITS"
echo ""
# Contributors and commit count
echo "=== Top Contributors ==="
git shortlog -sn | head -10
echo ""
# Commit frequency (commits per day for last 30 days)
echo "=== Recent Activity (Last 30 Days) ==="
THIRTY_DAYS_AGO=$(date -d "30 days ago" +%Y-%m-%d 2>/dev/null || date -v-30d +%Y-%m-%d)
RECENT_COMMITS=$(git log --since="$THIRTY_DAYS_AGO" --oneline | wc -l)
echo "Commits in last 30 days: $RECENT_COMMITS"
echo ""
# Files changed
echo "=== File Statistics ==="
echo "Total files in repository: $(git ls-files | wc -l)"
echo "Most changed files:"
git log --pretty=format: --name-only | grep -v '^$' | sort | uniq -c | sort -rn | head -10
echo ""
# Lines added/deleted
echo "=== Code Changes ==="
STATS=$(git log --numstat --pretty=format: | awk '{add+=$1; sub+=$2} END {print add, sub}')
ADDED=$(echo $STATS | awk '{
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Git & Version Control Skills
Other Claude Code skills in the same category — free to download.
Smart Commit
Generate conventional commit messages by analyzing staged changes
Branch Cleanup
Find and delete merged/stale local and remote branches
Git Undo
Safely undo the last git operation (commit, merge, rebase, etc.)
Changelog Generator
Generate CHANGELOG.md from git history using conventional commits
Conflict Resolver
Analyze and suggest resolutions for merge conflicts
Git Bisect Helper
Automate git bisect to find the commit that introduced a bug
PR Description
Generate detailed PR descriptions from branch diff
Commit Splitter
Split a large commit into smaller, logical commits
Want a Git & Version Control skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.