Rule 19 of 33 · Chapter IV — How We Build and Review
Leave the campsite cleaner than you found it
Why this rule exists
Codebases decay by default, because every change is made under a little time pressure and every shortcut left behind is a tax on the next person, so without active maintenance the whole thing slowly grinds toward unworkable. The boy-scout rule, leave the code a little better than you found it, is how we fight entropy without ever needing a big scary rewrite that management dreads and that usually fails anyway. If everyone makes small improvements in the neighborhood of their actual work, renaming a confusing variable, deleting dead code, adding the comment that would have saved them an hour, the codebase trends toward health instead of rot. This works precisely because it's incremental and attached to real changes, so it doesn't require anyone to stop and 'do a cleanup project' that never gets prioritized. Compounding small care is what keeps a two-year-old codebase pleasant to work in, and pleasant-to-work-in is a direct input to how fast we ship.
In practice
When you're already in a file for a real change, make a small improvement while you're there: clarify a name, remove something dead, fix the misleading comment, add the test that was missing. Keep these cleanups modest and, ideally, in a separate commit or PR so they don't obscure your actual change or bloat the review. Don't gold-plate, the goal is a little better, not perfect, and a rewrite disguised as a cleanup is neither. Fix the thing that just confused you, because if it confused you it'll confuse the next person, and you're the one with the context right now. When something's too big to fix in passing, leave a clear note or a ticket rather than a silent landmine. Treat leaving a mess for the next person as the small rudeness it is.
When it doesn't apply
During an incident or an urgent fix, resist the campsite instinct, do the minimal safe change and clean up later, because mixing cleanup into a hotfix adds risk exactly when you want none. And don't let opportunistic cleanup balloon a focused PR into an unreviewable sprawl; split it.