Code Churn: What It Tells You About Team Health
Code churn reveals more about team health than any code quality score. Learn to distinguish healthy churn from warning signs using the CHURN framework.

I once inherited a codebase where the payments module had a churn rate 4x the rest of the system. The code looked fine. Tests passed. SonarQube gave it a passing grade. But every sprint, 3-4 files in that module were being rewritten. Not extended. Not refactored. Rewritten.
Turns out, the original architect had left the company, the documentation was nonexistent, and every developer who touched the module was essentially re-solving the same problems from scratch because they couldn't understand the existing solutions.
No static analysis tool would have caught that. Code churn did.
What Is Code Churn?
Code churn measures how frequently code is being rewritten or modified. The simplest definition: the number of lines added, modified, or deleted in a file over a given period. But raw line counts aren't particularly useful. What matters is the ratio and the pattern.
There are several ways to measure churn: The code intelligence guide provides the wider context. Combine frequency and structure with hotspot analysis. Inspect module relationships using coupling and cohesion metrics.
- Absolute churn: Total lines changed in a time period
- Relative churn: Lines changed divided by total lines in the file
- Rework ratio: Lines changed within 2-3 weeks of being written (this is the one that predicts bugs)
- Author churn: How many different developers have modified a file
The rework ratio is the most telling. Code that's written and then immediately rewritten signals one of several problems: unclear requirements, missing tests, knowledge gaps, or poor design.[1]
Healthy vs Unhealthy Churn
Not all churn is bad. This is the mistake I see most teams make when they first start measuring it. They see high churn and panic. But churn has context.
Healthy churn looks like:
- A new feature being actively developed (churn is high, then drops off after release)
- A planned refactoring effort (churn spikes during the refactor, then stabilizes at a lower baseline)
- Test files changing alongside source files (tests should churn when code churns)
Unhealthy churn looks like:
- The same files churning sprint after sprint with no planned refactoring
- Churn concentrated in a small number of "usual suspect" files
- High rework ratio: code being rewritten within days of being committed
- Churn that doesn't correlate with feature delivery (lots of changes, no new capabilities)
Here's a quick diagnostic I run on every codebase I work with:
# Top 20 most frequently changed files in the last 90 days
git log --since="90 days ago" --pretty=format: --name-only | \
sed '/^$/d' | sort | uniq -c | sort -rn | head -20
# Unique canonical authors per file in the last 90 days
python3 - <<'PY'
from collections import defaultdict
import subprocess
raw = subprocess.check_output([
"git", "log", "--since=90 days ago", "--no-merges",
"--no-renames", "--format=%x1e%aE", "--name-only", "-z",
])
authors = defaultdict(set)
for record in raw.split(b"\x1e")[1:]:
author, _, names = record.partition(b"\0")
names = names.removeprefix(b"\n")
for filename in names.split(b"\0"):
if filename:
authors[filename].add(author)
for filename, people in sorted(authors.items(), key=lambda item: (-len(item[1]), item[0]))[:20]:
print(len(people), filename.decode("utf-8", "replace"))
PYThe first command counts file appearances in the chosen history window. The second counts distinct canonical author emails. Files on both lists have frequent changes and many recorded contributors. Inspect ownership concentration and review history separately before describing them as a knowledge bottleneck.[2][3]
The Churn-to-Complexity Matrix
The real power of churn data comes when you cross-reference it with complexity. I use a 2x2 matrix:[4]
| Low Complexity | High Complexity | |
|---|---|---|
| Low Churn | Leave it alone | Worth watching |
| High Churn | Normal development | Refactor NOW |
The high-complexity, high-churn quadrant is where bugs breed. These are the files that are hard to understand AND constantly being modified. Every modification is a gamble because the developer might not fully understand the implications of their change.
I call these files "complexity traps," and I've found that addressing just the top 5 complexity traps in a codebase can reduce bug rates by 30-40%.
The Framework: CHURN Diagnosis
When churn signals a problem, here's how I investigate:
C - Count: Measure the churn. Get the numbers. Which files? How often? How many authors?
H - History: Read the git log for your high-churn files. What kinds of changes are being made? Are they bug fixes? Feature additions? Reformatting? The commit messages tell the story.
U - Understand: Talk to the developers. Why does this file keep changing? Is it because requirements keep shifting? Because the abstraction is wrong? Because there's a missing test that lets regressions through?
R - Root cause: Identify the underlying issue. In my experience, it's one of five things: unclear requirements (product problem), wrong abstraction (design problem), missing tests (quality problem), knowledge gap (people problem), or external dependency changes (integration problem).
N - Neutralize: Address the root cause, not the symptom. Adding tests to a file won't help if the real problem is that requirements change every sprint. Refactoring won't help if the team doesn't understand the domain.
The Contrarian Take: Stable Code Isn't Always Good Code
Teams tend to celebrate stability. "This module hasn't been touched in 18 months!" That's not necessarily good. If the module is mature and feature-complete, stability is great. But if the module hasn't been touched because everyone's afraid of it? That's a different story.
I call this "fear-frozen code." It's code that should be changing (because the business requirements around it have changed) but isn't (because the last three people who touched it caused production incidents).
Fear-frozen code doesn't show up in churn analysis. It shows up in the negative space. Look for modules where feature requests and bug reports pile up but code changes don't. That gap between demand and delivery is a signal.
Tracking Churn Over Time
The most useful view of churn is the trend line. A single snapshot tells you very little. But churn tracked over 6-12 months tells you whether your codebase is getting healthier or sicker.
Set up a weekly job that records the same churn definition and time window. Recurring files deserve investigation, and changing files can reflect planned feature work or other causes. Read the commits before classifying either pattern as healthy or unhealthy.
Tools like CodeScene automate this entirely and give you trend visualizations out of the box. But you can get 80% of the value with a cron job and a spreadsheet.
What Churn Tells You That Nothing Else Can
Code churn is a proxy for organizational health. When churn patterns are healthy (focused, intentional, tapering off after feature completion), your team is communicating well, requirements are clear, and designs are solid.
When churn patterns are unhealthy (scattered, persistent, concentrated in the same files), something is broken in the system around the code. Maybe it's requirements. Maybe it's team structure. Maybe it's missing domain knowledge.
The code is just the symptom. Churn helps you find the disease.
Frequently asked questions
Is every high-churn file a problem?
High churn can come from feature development, planned refactoring or recurring fixes. Compare the reason for the changes with complexity and the work being delivered. A count alone cannot distinguish useful evolution from repeated repair.
How is relative churn different from absolute churn?
Absolute churn counts changed lines. Relative measures relate changes to another quantity such as component size or the measurement period. State the formula and window so a large file is not judged only by the number of lines it contains.
Does a file with many authors have a knowledge bottleneck?
Many contributors and concentrated knowledge are different signals. Count canonical identities, inspect the dominant contribution share and include review or pairing context. The number of authors alone does not establish who understands the module.
What should happen after a churn hotspot is found?
Read the relevant commits and discuss why the file keeps changing. Check requirements, tests, abstractions and dependency changes before choosing an intervention. Re-run the same analysis window and counting method to inspect the result.
Sources
- [1]Use of Relative Code Churn Measures to Predict System Defect Density - Microsoft Research · Microsoft Research, 2005
- [2]Git - git-log Documentation · Git
- [3]Git - gitmailmap Documentation · Git
- [4]Technical Debt — CodeScene 1 Documentation · CodeScene
Checked against these sources on





