Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Git & Version Controlbeginner

Repo Stats

Share

Generate repository statistics (contributors, commit frequency, file changes)

Works with OpenClaude

You 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 .git directory present
  • User has git installed (git --version)
  • Repository has at least one commit to analyze
  • User has read access to the repository

Steps

  1. Run git log --oneline to verify the repository has commits and get basic commit count
  2. Execute git log --format='%an' | sort | uniq -c | sort -rn to count commits per contributor
  3. Use git log --pretty=format:'%h %an %ai' --reverse to extract commit timestamps and analyze frequency over time
  4. Run git diff --name-only HEAD~1 HEAD to see files changed in the last commit, or git log --name-status --pretty=format: to track all file changes across history
  5. Execute git shortlog -sn to get a summary of contributors with commit counts (built-in alternative to step 2)
  6. Use git log --since="30 days ago" --oneline to analyze recent commit activity within a time window
  7. Combine results with git log --numstat --pretty=format: to get added/deleted line counts per file per commit
  8. 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

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
gitstatisticsanalytics

Install command:

curl -o ~/.claude/skills/repo-stats.md https://claude-skills-hub.vercel.app/skills/git/repo-stats.md

Related Git & Version Control Skills

Other Claude Code skills in the same category — free to download.

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.