Code verifiedVerified 2026-10-01

Code Churn Forecaster: Ranking Files by How Likely They Are to Change Next

A single-file, client-side tool that ranks every file in a pasted git log by change risk: commit activity, recency, churn, author entropy, and fix ratio.

Contents

    Defect prediction has a long, unflattering history. Models that promised to flag the next bug have mostly failed to beat a much simpler baseline: files that changed a lot recently tend to change again. That observation is not new — Nagappan and Ball showed in 2005 that relative code churn measures predict defect density well enough to be useful, without any machine learning at all.

    The Code Churn Forecaster takes that idea and makes it inspectable. Paste a git log, and it ranks every file that appears in it by a 0–100 change-risk score, with a heatmap of when each file was touched and a ranked table you can drill into. It is a single Astro page with no backend, no dependency, and no network call — the analysis runs in your browser and the log never leaves the page.

    Five signals, blended

    The forecaster computes five per-file metrics and blends them with hand-chosen weights:

    • Commit activity (30%) — how often the file appears in the log. Raw exposure to change.
    • Recency-weighted activity (30%) — a decaying sum, 0.94^n where n is the commit’s distance from the newest one. A file touched five times last month scores higher than one touched five times two years ago.
    • Author entropy (15%) — the Shannon entropy of who commits to the file, in bits. A file edited by one person has entropy 0; a file passed around a team scores higher, which is a proxy for coordination overhead.
    • Fix ratio (15%) — the fraction of commits touching the file whose subject matches a fix/bug/hotfix/revert pattern. Corrective churn is a stronger signal than feature churn.
    • Churn volume (10%) — total lines added and deleted. Deliberately the smallest weight, because a huge mechanical rename should not outrank a small file that keeps breaking.

    Each signal is min-max normalized across the files in the log, then the weighted sum becomes the 0–100 score. Bands are critical at 75+, high at 50+, moderate at 25+, low below that.

    Running it

    The tool accepts the default git log --numstat output, but the cleanest input is the compact documented format:

    git log --numstat --date=short --pretty=format:'@@@%H|%an|%ad|%s'

    Each @@@-prefixed line starts a commit (hash, author, date, subject); the lines beneath it are added<TAB>deleted<TAB>path numstat rows. The parser auto-detects which of the two formats you pasted, reports any rows it could not parse in a warnings box, and falls back to commit order when the log carries no dates.

    The built-in sample is a four-commit log across four files. Running it produces src/api/client.ts at risk 91 (three commits, three authors, 1.58 bits of entropy) and src/store/cache.ts at risk 80 (three commits, one author, but two-thirds of them fixes) — a useful illustration that an unstable file is not always a busy one.

    What this tool does not do

    It is a static text analyzer with fixed weights, not a trained model, and the score is relative: every signal is normalized against the other files in the same pasted log. A score of 100 means “the most-changed file in this input”, not an absolute probability of a defect. Because of the min-max step, a two-file log will always produce a high score for the busier file — the number is only meaningful when you paste a spanning, realistic history.

    The other honest caveats are structural. A shallow log understates risk. Merge commits, formatting-only churn, and generated files skew counts. And the ranking predicts instability — likelihood of change — not defects; a file can churn constantly and stay correct, or sit untouched and be wrong.

    If you want the sharper signal, feed it the full --numstat history for the modules you own, sort by risk, and treat the top of the list as the place to add tests and review coverage before the next sprint, not as a list of known bugs.

    Try it

    The tool is live at codeintel.xyz/tools/code-churn-forecaster/, and it is the fifth entry in the Code Analysis block of the tools roadmap — the last remaining planned slot in that category. It runs entirely client-side; verify that yourself by disconnecting before you paste anything sensitive.

    • ToolBrain — tool reviews, LLM comparisons, and AI workflow guides

    Cross-links automatically generated from CodeIntel Log.