claude-code·Published 2026.06.01·Views 9
Committing Without Knowing What AI Changed? Check with /diff
/diff is a command that shows what Claude changed, in color. We cover reviewing changes before committing and tracking them by turn and by file, step by st
You told Claude "fix this" and a bunch of files changed in a cascade. But did you see exactly what changed and how? Committing (saving) without looking, then having an incident later from one unintended line — you experience this now and then while vibe coding. /diff prevents this. It's a final pre-commit check tool that shows you what changed, in color, at a glance.
Definition
/diff is a command that shows, in color, changes that haven't been saved (committed) yet.
Here, "commit" is the act of confirming changes into a single record and saving them. Before committing, you're in a "changed but not yet confirmed" state, and /diff shows exactly the changes in that state.
On screen it's usually displayed like this.
- Added lines: green (or a
+mark) - Deleted lines: red (or a
-mark)
So you can see right away, just from the color, what's newly in and what's been removed. ("diff" is short for difference.)
How to use it (by difficulty)
Basics — view changes
After Claude fixes the code, type into the chat box.
/diff
On entering it, a screen appears with the not-yet-saved changes shown in color. Green is added, red is deleted. It's the step where, before committing, you visually confirm "did it change the way I intended?"
Applied — view by turn
/diff
With the /diff screen up, pressing the left/right arrow keys lets you move between the changes of each step (turn) Claude worked on. Useful for pinpointing changes at a specific moment, like "what did it change in the 3rd step."
Advanced — navigate by file
/diff
If several files changed at once, on the /diff screen you can review them by moving file by file with the up/down arrow keys. When there are many files, you page through them one by one to review without missing anything.
Common pitfall — /diff only "views," it doesn't undo
It's easy to confuse, but /diff only shows the changes. Pressing something here doesn't cancel or revert changes. It's just a "review screen."
So the flow goes like this.
- Check the changes with
/diff. - If you find a part that differs from your intent, request again in conversation, "fix this line here like so."
- Commit when you're satisfied.
Remember that /diff is the "eye that checks," and fixing is still assigned through conversation.
A real case
I once had Claude fix several files at once. Looking only at the result, it seemed fine, but out of habit I turned on /diff. Skimming the step-by-step changes with the left/right arrows, I found that in one file, a perfectly good line had been deleted contrary to my intent.
/diff
I immediately requested "bring back that line you just deleted" and reverted it. Had I committed as-is, it would have been a bug I'd wander around for ages over later. One /diff before committing prevented the accident.
Use it like this too
- Check before saving: Always lay eyes on the changes once before committing.
- Track changes by turn: Check each step's changes separately with the left/right arrows.
- Navigate by file: Review file by file thoroughly with the up/down arrows.
- Pre-code-review check: Before entering a full review, skimming quickly first with
/diffis efficient.
Tip: Skipping the look thinking "the AI surely did it well" is vibe coding's most common cause of accidents. Even if a change looks small, make
/diffbefore committing a habit.
How others use it
- Beginners see a noticeable rise in work efficiency just from properly using three:
/plan,/diff,/compact. — Frequently Used Slash Commands (Dale Seo)
Wrap-up
The key is one sentence. Before committing, always check what changed with /diff. As much as AI changes a lot fast, the responsibility to review those changes remains with the human. One line of /diff prevents the accident you'd otherwise miss in advance.
Based on: Claude Code v2.1.154 (2026.05)
Comments
Comments 0
Checking sign-in status…
Loading comments…