Record debt, allocate budget, refactor continuously.
Debt discipline
Track every deliberate shortcut
// TODO: refactor - see issue #123. Debt without a ticket is forgotten debt.Allocate 20% of each sprint
Dedicate capacity to paying down the worst debt.
Refactor with tests
Never refactor without tests. Debt + no tests = rewrite.
Boy scout rule
Leave every file better than you found it. Small continuous improvements.
Measure code churn
Files modified every sprint are debt hotspots. Prioritize them.