Last updated 13 October 2026
Reject specific parts of a Claude diff
The frustration of all or nothing diffs
Claude Code often suggests a block of changes that looks mostly correct but contains one or two lines you dislike. You might see a perfect logic fix bundled with a change to your variable naming style or an unnecessary comment. Accepting the whole block means you have to go back and fix it yourself later. Rejecting it entirely forces the agent to start the whole task again. You need a way to tell the agent exactly what to keep and what to throw away before the code hits your disk.
The problem stems from how the agent handles the Edit and Write tools. When the agent decides to modify a file, it presents a diff for your approval unless you have configured it to bypass permissions. If you find yourself constantly accepting changes you do not want, you are likely losing time in the cleanup phase. This guide covers how to stop the agent from making those specific mistakes and how to handle the diffs it produces effectively.
Control starts with permission modes
Your control over diffs depends on the permission mode you use during the session. The default mode requires you to approve every write operation. You can cycle through modes by pressing Shift+Tab while in the terminal interface. If you are in bypassPermissions mode, the agent will write directly to your files without showing you a diff first. This is dangerous if you want to keep tight control over the code and avoid unwanted hunks.
To ensure you see every change, stay in the default mode or the plan mode. In the plan mode, the agent describes what it intends to do before it uses any tools. This gives you a chance to object to a specific part of the logic before the agent even generates the diff. If you see a proposed step that looks wrong, you can interrupt the agent and tell it to ignore that specific file or logic. This early intervention prevents bad diffs from being generated in the first place.
Reviewing the proposed changes
When the agent is ready to apply a change, it displays a diff in the terminal. This diff uses standard color coding to show additions and subtractions. You should read this carefully before pressing the key to accept. If the diff is too long to see in one screen, you can use your terminal scrollback or the provided keyboard shortcuts to navigate the output. You must be certain about every line before you give the agent permission to proceed.
If you see something you dislike in the diff, do not press the accept key. Instead, you can provide feedback to the agent. Tell the agent that you like the changes in one function but want to keep the old code in another. The agent will then use the Edit or Write tool again to produce a new diff that reflects your feedback. This iterative process is the primary way to reject a hunk within the Claude Code environment. You are effectively collaborating on the final diff until it meets your standards.
Configuring persistent permission settings
You can make your preference for manual review permanent by editing your settings. Open the .claude/settings.json file in your project root or the ~/.claude/settings.json file for global preferences. Look for the permissions section. You can set specific tools like Edit or Write to always require approval. This prevents the agent from accidentally overwriting code when you are not paying close attention to every single change.
If you are working on a complex project with multiple developers, you might want to use .claude/settings.local.json for these overrides. This ensures your personal preference for strict diff review does not interfere with the settings of your teammates. By forcing a manual check on every Write tool call, you create a safety net that lets you catch bad hunks before they ever reach your local git staging area. This is a critical step for maintaining code quality in large repositories.
Using project instructions for better diffs
You can reduce the number of bad hunks by using the CLAUDE.md file. This file sits in the root of your repo and holds project instructions. If the agent repeatedly tries to change a specific pattern or file that you want to keep as is, write a rule in CLAUDE.md. For example, you can tell the agent never to modify the imports in a specific folder or to avoid changing the formatting of a certain configuration file. Explicit instructions are the best way to prevent unwanted diffs.
The agent reads these instructions at the start of every session. When it knows your constraints, the diffs it generates are much cleaner and require less manual correction. You can also place a CLAUDE.md file in a subdirectory to apply rules to only that part of the tree. This is helpful when you have a legacy directory where you want to allow only bug fixes and no stylistic changes. Better instructions lead to fewer hunks that need rejection, which saves you both time and tokens.
Managing multiple tasks with adhdTerminal
When you are working on several features at once, the diffs can get mixed up if you try to do everything in one terminal window. adhdTerminal helps by letting you run many Claude Code sessions side by side on a single wall. Each tile represents a different session, which you can name and color code according to the task. This isolation makes it much easier to review diffs because you know exactly which context each change belongs to. You can easily see if a session is waiting for your input on a diff.
By keeping a separate tile for each subtask, you avoid the scenario where a diff for one feature includes accidental changes for another. If a diff in one tile looks messy, you can simply /clear that session or use /compact to refresh the context without affecting your other work. The visual overview in adhdTerminal shows you which tiles are waiting for your approval, so you can jump in and review diffs as they arrive across multiple projects. This prevents you from losing track of which changes you have already vetted.
Reverting after the fact
Sometimes you might realize you accepted a bad hunk only after the agent has moved on to the next task. In this case, you can use the /review command. This command asks the agent to look over the changes it just made and check them for errors or deviations from your instructions. If the agent finds a mistake, it can suggest a new diff to fix it. This is a good safety check after a long session of coding.
Alternatively, you can use the Edit tool yourself or use the /vim command to open the file directly in the terminal and manually fix the bad hunk. If you prefer your own editor, the /ide command can help bridge the gap. If you have already accepted many changes and want to go back to a specific point, you can press Escape twice. This allows you to select an earlier message in the conversation and resume from there, effectively undoing all the work and file changes that happened after that point.
Using subagents for surgical changes
If a task is too large and results in massive, unmanageable diffs, consider using subagents. You can define a subagent in .claude/agents as a markdown file. A subagent can be tasked with a very narrow scope, such as only fixing types or only updating documentation. When a subagent performs a task, the resulting diff is much smaller and easier to review. Smaller diffs are inherently safer because you can inspect every line without getting overwhelmed.
The main session can call these subagents using the /agents command. Because the subagent has a restricted focus, it is less likely to produce unrelated hunks of code that you would otherwise want to reject. This modular approach to coding with the agent keeps your diffs clean and your cognitive load low. You spend less time fighting with the terminal and more time shipping code that meets your exact specifications. It also makes it easier to pinpoint where a bad change was introduced.
Handling costs and context
Every time you ask the agent to rewrite a diff because you rejected a part of it, you use more tokens. You can monitor this by using the /cost or /usage commands. If a session becomes too long because of many iterations, the context window fills up. Use the /compact command to summarize the conversation so far. This keeps the agent focused on the current state of the code and prevents it from reintroducing old bugs from earlier, rejected diffs.
The wall interface in adhdTerminal provides a high-level view of these metrics for every active session. You can see which tiles are waiting for you or working, and monitor the cost for each tile without running a command in every window. If the agent becomes confused after several attempts to fix a diff, it might be better to start fresh. Use /clear to reset the session in the current folder. This wipes the conversation history but keeps the files on disk as they are, allowing you to ask for a specific, smaller change.
Questions people ask
How do I go back to a previous state if I accepted a bad diff?
Press Escape twice to see a list of earlier messages and select one to resume from. This effectively reverts the conversation and the agent's memory to that specific point in time. You should also use your version control system to undo any physical file changes made by the agent.
Can I reject just one file in a multi-file diff proposed by the agent?
You cannot click a single button to reject one file, but you can tell the agent to keep the changes in one file while reverting another. The agent will then call the Edit tool again to generate a new diff that excludes the changes you disliked. Always check the new diff before confirming the second time.
What if the agent keeps trying to change a specific line I want to keep?
Add a specific instruction to the CLAUDE.md file in your project root or the current subdirectory. Explicitly tell the agent to ignore that specific file or code pattern. This acts as a persistent rule that the agent follows across all sessions, preventing it from proposing those changes again.
Read next
- Add build instructions to your CLAUDE.md fileImprove project context by adding specific build commands and environment requirements to your CLAUDE.md file for the AI to follow.
- Add common error fixes to CLAUDE.mdImprove project memory by adding a section for common errors and their fixes to your CLAUDE.md configuration file.
- Add custom shell aliases for Claude CodeSpeed up your workflow by creating shell aliases for common Claude Code invocations and project-specific startup commands.
- Add test commands to a CLAUDE.md fileUnderstand how to define specific test runners and environment flags in your CLAUDE.md file so the tool runs the correct test suite.