Claude Code scope drift: why it happens and how to stop it

Dev.to AI
Generative AI

Claude Code drifts. You ask it to fix a bug, and it fixes the bug, refactors two adjacent functions, adds a comment explaining why the old approach was suboptimal, and updates a test that wasn't broken. None of that was asked for. All of it is now in your diff. Here's why it happens and how to stop it. Why Claude Code drifts Claude is trained to be helpful, and "helpful" often means doing than was asked. When it reads a function to fix a bug, it notices other things - dead code, inconsistent naming, an error case that could be handled better. The default behavior is to address them.