codechurn
v1.0.0
Published
Track AI vs human code quality — enhanced AI churn detection, hotspot scoring, and configuration system
Maintainers
Readme
codechurn
Track AI vs human code quality — enhanced AI churn detection, hotspot scoring, and configuration system.
You're using Copilot, Claude, Cursor. But is the AI-generated code actually surviving? Or does it get rewritten in the next PR? codechurn answers that by analyzing your git history and attributing code to AI or human authors, then tracking what happens to it over time.
Why?
- 66% of devs are frustrated with "almost right" AI code (Stack Overflow 2025)
- AI code has 1.7x more issues and 2.74x more security vulnerabilities (Exceeds AI research)
- No open-source tool tracks AI code quality over time — until now
- Enhanced version now with configurable AI detection, improved hotspot scoring, and CI-friendly outputs
What it does
- Enhanced Attribution — reads git history with configurable AI detection:
- Co-authored-by headers (
Co-authored-by: Copilot) - Commit message keywords (
claude,copilot,cursor,aider) - Author name patterns
- Customizable detection patterns and thresholds
- Co-authored-by headers (
- Improved Hotspot Scoring — ranks files using weighted algorithm:
- Churn rate (40%) — how much AI code gets rewritten
- Survival rate (30%) — how long AI code persists
- Volume weight (30%) — amount of AI code in file
- Churn tracking — for each file, tracks lines added/removed by AI vs human
- Survival analysis — what percentage of AI-written lines are still there?
- Model breakdown — compare Claude vs Copilot vs Cursor code quality
- Configuration system — customizable thresholds, patterns, and output formats
Install
npm install -g codechurnUsage
Enhanced analysis with configuration
codechurn analyze
codechurn analyze --since "3 months ago"
codechurn analyze --since "2024-01-01" --json
codechurn analyze --path ../my-project --top 10 --md
# Custom thresholds and scoring
codechurn analyze --high-churn-threshold 0.6 --low-survival-threshold 0.8 --min-lines 100
# Config file support
codechurn analyze --config ./codechurn.config.jsonQuick scan (summary only)
codechurn scan
codechurn scan --since "1 month ago"Enhanced Hotspots with improved scoring
codechurn hotspots
codechurn hotspots --top 5 --json
# Filter by minimum hotspot score
codechurn hotspots --min-score 0.5
# See detailed scoring breakdown
codechurn hotspots --json | jq '.[] | {file, hotspotScore, aiChurnRate, aiSurvivalRate}'Model comparison
codechurn models
codechurn models --jsonOutput
codechurn report — my-project (main)
period: 3 months ago → now
overview
commits analyzed: 247
AI commits: 89 (36.0%)
Human commits: 158 (64.0%)
survival rates
AI lines: 1243 — 52.3% survived (0.477 churn)
Human lines: 3891 — 78.1% survived (0.219 churn)
revert rates
AI: 8.9% of AI commits were reverts
Human: 3.2% of human commits were reverts
avg code lifetime
AI: 5 days
Human: 30 days
⚠ 3 hotspots (improved scoring)
src/auth.ts score: 0.742 (high churn + low survival)
src/api/handlers.ts score: 0.621 (high churn + volume)
src/utils/helpers.ts score: 0.589 (moderate churn + low survival)CI/CD Integration
# Fail if AI churn rate exceeds threshold
codechurn analyze --since "1 month ago" --json | \
jq -e '.summary.aiSurvivalRate > 0.5'Enhanced Configuration
Threshold customization
codechurn analyze --high-churn-threshold 0.6 --low-survival-threshold 0.8 --min-lines 100How attribution works
codechurn looks for these signals in commits:
| Signal | Example |
|--------|---------|
| Co-authored-by | Co-authored-by: Copilot <[email protected]> |
| Keywords in message | "used claude to generate", "copilot suggested" |
| Author name | Author contains "copilot", "cursor", "aider" |
Hotspot scoring algorithm
Hotspots are ranked using a weighted formula:
score = churn × 0.4 + (1 - survival) × 0.3 + volume × 0.3Where:
churn= lines_removed / lines_added (0-1)survival= lines_still_present / lines_added (0-1)volume= min(ai_lines / min_lines, 1) (0-1)
As a library
import { ChurnAnalyzer, Reporter } from 'codechurn';
const analyzer = new ChurnAnalyzer('/path/to/repo');
const report = analyzer.analyze({ since: '3 months ago' });
console.log(report.summary.aiSurvivalRate); // 0.52
console.log(report.summary.humanSurvivalRate); // 0.78License
MIT
