Code churn
Also called churn or rework rate
Code churn is code that is rewritten or deleted shortly after it was written, usually within a few weeks, by the person who wrote it. It is distinct from ordinary change to old code, which is just maintenance.
How it is measured
Lines added inside a recent window that get modified or deleted again before that window closes, by the same author, as a share of total lines written.
Both conditions do real work:
The window separates churn from maintenance. Without a time bound, every long-lived codebase reports enormous churn, and all it means is that the code is old and still in use.
Same author separates rework from collaboration. Somebody else improving your code is code review functioning correctly. You rewriting your own work from last week is a different signal.
Why it is worth watching
Churn is one of the few available signals about upstream clarity. Almost every engineering metric measures what happened after the work was understood — how big the change was, how long review took, whether it broke. Churn measures whether the work was understood at all.
High churn on a feature usually means one of:
- The requirements were unclear or moved after coding started
- The problem was genuinely novel and needed exploration, which is fine
- The design was settled in the editor rather than before it
- Someone was blocked on a decision and kept guessing
Only the second of those is healthy, and the difference between them is a conversation, not a number.
What it misses
It punishes exploration. Prototyping is churn by design. Any team that treats churn as waste will discourage exactly the throwaway work that makes hard problems tractable, and a low-churn team may simply be one that never attempts anything uncertain.
It is easily gamed by not committing. A developer who works for a week on an uncommitted branch and pushes once produces beautiful churn numbers and worse working habits. Metrics that measure commits reward hiding work in progress.
Formatters and renames wreck it. A repository-wide reformat, an automated migration or a rename sweep will register as enormous churn and mean nothing. Mechanical changes have to be classified out or the metric is noise.
It cannot see thinking. Code rewritten three times because the developer kept finding a better shape is churn. So is code rewritten three times because nobody knew what was being built. Same number, opposite situations.
How to read it well
Never use it at the individual level. Churn varies more between types of work than between people, so comparing developers mostly ranks who was assigned the vaguest problem. It is the one metric here most likely to do damage if it reaches a performance review.
Use it per project or per feature, and use it as a retrospective prompt. "This feature churned three times our usual rate — what did we not know when we started?" is a genuinely useful question, and the answer is almost always about the specification, not the engineering.
Read it with pull request size. High churn on small changes usually means unclear requirements. High churn on large changes usually means the change should have been broken up before it was started.
Frequently asked questions
What is code churn?
Code that gets rewritten or removed soon after being written — typically within two to three weeks, by its original author. Editing code somebody wrote two years ago is maintenance. Rewriting your own code from last Tuesday is churn, and the distinction is the whole metric.
Is code churn bad?
Not inherently, and a target of zero is actively harmful. Exploratory work, prototypes and genuinely novel problems all churn heavily and should. What is worth investigating is churn that is unexpected — high churn on a well-understood feature usually means the requirements were unclear before anyone started coding.
How is code churn calculated?
Take lines that were added within a window — commonly 21 days — and count how many were subsequently modified or deleted by the same author. Expressed as a percentage of total lines written. The window and the same-author condition are both load-bearing; without them the number is just a measure of how old the codebase is.
What is a normal code churn rate?
Published figures cluster somewhere between 15% and 30%, but they vary so much by team, language and type of work that using one as a target is a mistake. Your own baseline over a few months, and the projects that deviate from it, will tell you far more than any industry figure.
Related
- Pull request size Pull request size is how much a single pull request changes, usually counted as lines added plus lines deleted, sometimes with the number of files touched alongside it. It is the strongest available predictor of how long a change waits for review.
- Defect rate Defect rate is how many defects reach a given stage per unit of work — commonly bugs found in production per release, per change, or per period. The version worth tracking is the escaped defect rate: the share of defects that got past every check and reached a customer.
- Read: Measuring engineering team performance beyond lines of code →
- Read: How to measure technical debt cto guide →