Skip to content

drdpedroso/git-churn-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-churn-ai

Analyze code churn with AI attribution detection — see what % of your codebase was written by AI tools.

Install

# Install globally
npm install -g git-churn-ai

# Or run without installing
npx git-churn-ai

Usage

Usage: git-churn-ai [options]

Analyze code churn with AI attribution detection.

Options:
  --since <date>    Git date range (default: "90 days ago")
  --repo <path>     Path to git repository (default: cwd)
  --output <file>   Output file path, or - for stdout (default: churn-report.md)
  --top <n>         Number of top churned files to show (default: 30)
  --ext <exts>      Comma-separated file extensions (default: .ts,.tsx,.js,.jsx)
  --format <fmt>    Output format: md or json (default: md)
  -h, --help        Show this help message

Environment variables: SINCE, REPO_PATH, OUTPUT, TOP_N, EXT

Examples

# Run in current directory, last 90 days
git-churn-ai

# Analyze a specific repo, last 30 days, output to stdout
git-churn-ai --repo ~/my-project --since "30 days ago" --output -

# Top 10 files, JSON output
git-churn-ai --top 10 --format json --output report.json

# Analyze only TypeScript files
git-churn-ai --ext .ts,.tsx

# Analyze Python project
git-churn-ai --repo ~/my-python-project --ext .py

Example Output

# Code Churn Report with AI Attribution

> Generated: 2025-01-15T10:30:00.000Z
> Repo: `/Users/you/my-project`
> Since: `90 days ago`

## Summary

| Metric | Value |
|--------|-------|
| Total files with churn | 142 |
| Total codebase lines | 48,320 |
| Total churn lines | 12,450 |
| Churn as % of codebase | 25.8% |
| AI-attributed churn lines | 3,210 |
| AI churn as % of total churn | 25.8% |
| AI churn as % of codebase | 6.6% |
| Total commits | 87 |
| AI commits (confirmed + suspected) | 22 (25.3%) |
| Confirmed AI commits | 18 |
| Suspected AI commits | 4 |

## AI Churn Overview

Total Churn   [███░░░░░░░] 25.8% of codebase
AI Churn      [███░░░░░░░] 25.8% of churn is AI-attributed
AI Commits    [███░░░░░░░] 25.3% of commits show AI signals

## Top 30 Files by Churn

| # | File | Churn | +Added | -Deleted | Commits | AI Signal | AI% | AI Bar |
|---|------|------:|-------:|---------:|--------:|-----------|----:|--------|
| 1 | `src/components/Dashboard.tsx` | 842 | +621 | -221 | 12 | 🤖 confirmed | 75% | ██████░░ |
| 2 | `src/hooks/useAuth.ts` | 634 | +412 | -222 | 8 | 🔶 suspected | 38% | ███░░░░░ |
| 3 | `src/screens/HomeScreen.tsx` | 511 | +389 | -122 | 6 || 0% | ░░░░░░░░ |

How AI Detection Works

git-churn-ai uses three confidence levels to detect AI-written code:

🤖 Confirmed

A commit is confirmed as AI-generated when:

  • The git author name or email contains a known AI tool name (e.g. claude, copilot, cursor, gpt, openai)
  • The commit has a Co-Authored-By: trailer matching a known AI tool

🔶 Suspected

A commit is suspected as AI-generated when the commit message or body contains keywords like:

  • claude, copilot, ai:, ai-generated, generated by
  • gpt, cursor ai, via ai, [ai], [claude], [copilot]

— No signal

No AI indicators detected in author info, trailers, or commit message.

Config

Recognized AI author patterns (checked against author name and email):

claude, copilot, github-actions[bot], openai, chatgpt, gpt, cursor

Recognized Co-Authored-By patterns:

claude, copilot, openai, cursor, gpt, github-copilot

Commit message keywords (subject + body):

claude, copilot, ai:, ai-generated, generated by,
co-authored-by: claude, gpt, cursor ai, via ai, [ai], [claude], [copilot]

JSON Output

Use --format json for machine-readable output:

{
  "meta": {
    "since": "90 days ago",
    "generatedAt": "2025-01-15T10:30:00.000Z",
    "repoPath": "/Users/you/my-project"
  },
  "summary": {
    "totalFiles": 142,
    "totalCodebaseLines": 48320,
    "totalChurnLines": 12450,
    "pctChurnOfCodebase": 25.77,
    "aiChurnLines": 3210,
    "pctAiChurnOfTotalChurn": 25.78,
    "pctAiChurnOfCodebase": 6.64,
    "totalCommits": 87,
    "aiCommits": 22,
    "pctAiCommits": 25.29,
    "confirmedAiCommits": 18,
    "suspectedAiCommits": 4
  },
  "files": [ ... ]
}

Requirements

  • Node.js >= 18
  • git available in PATH
  • grep available in PATH (for line counting)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors