Claude Code has just finished a task. Now it’s showing you something that looks like a wall of red and green text. This is called a diff — and understanding it is the moment between “Claude Code made a change” and “that change is now in your codebase.” You’re the last line of review. Here’s how to do it well.
This is part of our complete How Claude Code Works — A Beginner’s Deep Dive.
TL;DR
- Claude Code always shows you proposed changes before applying them — nothing happens silently
- Changes are shown as a diff: red lines are removed, green lines are added
- You accept, reject, or modify changes before they touch your files
- You can accept all changes, reject all, or accept file-by-file
- Always review changes to sensitive files (auth, payments, database) extra carefully
What Is a Diff?
A diff is a side-by-side (or inline) comparison that shows exactly what’s about to change in a file. The name comes from “difference” — it highlights the difference between the old version and the new version.
Here’s what diff output looks like:
# Example diff — red/minus lines are deleted, green/plus lines are added
function calculateTotal(items) {
- return items.slice(0, 10).reduce((sum, item) => sum + item.price, 0);
+ return items.reduce((sum, item) => sum + item.price, 0);
}
In this example:
- The red line (marked with
-) is being removed - The green line (marked with
+) is being added - Lines with no marking stay exactly the same
This particular diff fixes a bug where the total was only calculated for the first 10 items. Once you understand how to read a diff, reviewing Claude Code’s changes becomes straightforward.
Step 1: Read the File List First
Before you read any code, look at the list of files Claude Code wants to change. This tells you the scope of what’s about to happen.
# Claude Code showing which files it wants to modify
The following files will be changed:
MODIFIED: src/utils/invoiceCalculations.ts
MODIFIED: src/components/invoices/InvoiceSummary.tsx
CREATED: src/tests/invoiceCalculations.test.ts
Read this list carefully. Ask yourself:
- Does this list make sense for the task I gave?
- Are there any files I didn’t expect to see?
- Are there files missing that I would have expected?
If the file list looks wrong, say so before you even look at the code:
# Stopping Claude Code before you review the diffs
Wait — why is InvoiceSummary.tsx in this list? I only asked about the calculation
function, not the display component. Please explain why you're changing that file,
or remove it from the change set.
Step 2: Review Each Diff
Once you’re satisfied with the file list, go through each file’s diff. For each one, you’re checking three things:
1. Does the change do what I asked?
The change should solve the exact problem you described, nothing more.
2. Does it introduce anything I didn’t ask for?
Sometimes Claude Code adds a helpful extra thing — a console.log for debugging, an additional validation, a comment. Decide if you want it.
3. Does it look like code that belongs in my project?
The style, naming conventions, and patterns should match your existing codebase. If something looks foreign, note it.
Step 3: Accept or Reject the Changes
After reviewing, you have clear options:
Accept all changes:
# Accepting all proposed changes
y # Press 'y' to accept
# or
Yes # Type 'yes' and press Enter
Reject all changes:
# Rejecting all proposed changes — nothing is written to your files
n # Press 'n' to reject
# or
No # Type 'no' and press Enter
Accept some, reject others (file by file):
Claude Code may present files one at a time. For each file:
# Reviewing file by file
Apply changes to src/utils/invoiceCalculations.ts? [y/n]: y
Apply changes to src/components/invoices/InvoiceSummary.tsx? [y/n]: n
Apply changes to src/tests/invoiceCalculations.test.ts? [y/n]: y
You can accept the calculation fix and the new test while rejecting the component change you didn’t ask for.
💡 Pro Tip: You can reject a change and immediately tell Claude Code why and what to do instead. “I’m rejecting the InvoiceSummary change — I didn’t ask you to touch that file. Focus only on the calculation function.” Claude Code will adjust and re-propose.
Step 4: Request Modifications Instead of Outright Rejecting
Sometimes the change is mostly right but not quite. You don’t have to reject everything and start over. You can ask Claude Code to modify the proposed change:
# Asking for a modification to a proposed change
The calculation fix looks right, but instead of removing the .slice(0, 10) entirely,
add a comment explaining WHY it's removed — future developers might wonder if it
was intentional. Then I'll accept it.
Claude Code will revise the change and show you an updated diff.
Step 5: Verify After Accepting
Once you accept a change, the files on disk are updated. Your next step is to verify the change works:
# Running your tests after accepting changes
npm test # Run the full test suite
npm test invoiceCalculations # Run just the relevant tests
# Or run your dev server and test manually
npm run dev
# Navigate to the affected feature and test it
If tests fail or the feature doesn’t work:
# Telling Claude Code the change broke something
The change you just made is failing the existing tests. Here's the error output:
[paste test output]
Fix the issue without reverting the core fix — the .slice() removal was right,
something else is wrong.
How to Undo an Accepted Change
If you accepted a change and then realized it was wrong, you have options.
Option 1: Use git to revert
# Reverting the last commit with git
git diff HEAD # See what changed since your last commit
git checkout -- src/utils/invoiceCalculations.ts # Revert a specific file
git reset HEAD~1 # Undo the last commit entirely (keeps changes staged)
Option 2: Ask Claude Code to undo it
# Asking Claude Code to reverse its own change
Please revert the changes you just made to invoiceCalculations.ts — the fix
introduced a rounding error. Go back to the original version of that function.
⚠️ Warning: If you’ve been doing multiple rounds of changes without committing to git between them, reverting becomes much harder. Commit your work before each significant Claude Code operation. It’s the single best safety habit you can build.
Special Care for Sensitive Files
Some files deserve extra scrutiny before you accept changes. Give these a slower, more careful read:
Authentication files: Any change to login, logout, token handling, session management, or permission checking needs to be read line by line. A small error here affects every user.
Payment processing: Anything that touches your Stripe integration, price calculations, or order totals. Double-check the math.
Database queries and migrations: SQL changes are often irreversible. If you’re adding a column, that’s fine. If you’re dropping one, make sure you meant to.
Environment configuration: Changes to .env.example, config.js, or any file that controls how your app connects to external services.
For these files, it’s worth reading the diff twice, running any tests that cover that area, and sometimes asking Claude Code to explain its reasoning: “Walk me through why you made this specific change to the auth middleware.”
Common Mistakes and How to Fix Them
Mistake 1: Accepting Without Reading
Problem: You see a green checkmark and press y out of habit without actually reading the diff.
Fix: Force yourself to read at least the changed lines. The diff is usually short. It takes 30 seconds and catches most problems.
Mistake 2: Rejecting Everything When Something Is Mostly Right
Problem: One line in a 50-line diff is wrong so you reject the whole thing, losing the 49 lines that were correct.
Fix: Use file-by-file acceptance, or ask Claude Code to modify just the problematic part.
Mistake 3: Not Having a Git Safety Net
Problem: You accept changes that break something and you can’t get back to a clean state.
Fix: Commit before every Claude Code session. It takes five seconds and gives you unlimited undo.
Mistake 4: Rushing Through Multi-File Changes
Problem: Claude Code changes 6 files and you skim them all quickly, missing an important issue in file 4.
Fix: For multi-file changes, slow down. Read each file completely. If you’re tired or distracted, save the review for when you can focus.
Mistake 5: Ignoring New Files Claude Code Creates
Problem: You focus on the diffs for modified files but pay less attention to entirely new files Claude Code creates.
Fix: New files deserve just as much review as modified ones. A new file could introduce patterns or dependencies you wouldn’t have chosen.
Key Takeaways
- Claude Code never changes files silently — you always review before anything is applied
- Diffs show red (removed) and green (added) lines — lines without markers stay the same
- Read the file list before reading individual diffs — it tells you the scope at a glance
- You can accept all, reject all, or go file by file
- Git commits before each session give you a safety net to fall back on
Next Steps
- Claude Code Keyboard Shortcuts — The Complete List — speed up your review workflow with keyboard shortcuts
- Claude Code Modes Explained: Normal, Plan, Auto — understand how the mode you’re in affects how changes are proposed
- How Claude Code Plans Before It Codes — catch issues before code is written, not just before it’s applied
Return to How Claude Code Works — A Beginner’s Deep Dive for the full picture.