---
title: "How do I keep Claude Code from making unrelated changes during a small bug fix?"  
description: "How do I keep Claude Code from making unrelated changes during a small bug fix?"  
author: "Björn Ólafsson"  
published: 2026-10-17  
updated: 2026-10-17  
canonical: https://www.mindstick.com/forum/162522/how-do-i-keep-claude-code-from-making-unrelated-changes-during-a-small-bug-fix  
category: "AI Coding Assistants"  
tags: ["Claude Code", "Code review", "Developer Workflows"]  
reading_time: 1 minute  

---

# How do I keep Claude Code from making unrelated changes during a small bug fix?

When I ask Claude Code to fix a small bug, I sometimes get the fix plus renamed variables, reformatted sections, or nearby cleanup. Those extra edits may be reasonable, but they make a ten-line change much harder to review.

I want to establish a **minimal diff workflow** without preventing necessary changes to tests or shared helpers. “Only edit this file” can be too restrictive when the bug actually starts somewhere else.

What has worked better for you: asking for an edit plan first, specifying allowed files, or requiring approval before expanding the scope? I’d also like to distinguish edits Claude chooses to make from changes caused by a formatter or pre-commit hook.

If you use repository instructions for this, how do you phrase the boundary so it discourages opportunistic cleanup but still allows a proper fix?


---

Original Source: https://www.mindstick.com/forum/162522/how-do-i-keep-claude-code-from-making-unrelated-changes-during-a-small-bug-fix

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
