Logo Vincent
Back to all posts

Claude Code /diff: See Exactly What Changed, Turn by Turn

Claude
Claude Code /diff: See Exactly What Changed, Turn by Turn

What Is /diff

When Claude Code helps you write code, after a few rounds of conversation it may have modified several files. You know roughly what was done, but you’re not sure exactly which lines changed in each file or what logic was added.

/diff is for viewing those changes. It opens an interactive panel showing code differences from two perspectives:

  1. Current — all uncommitted changes in your working directory (git diff HEAD)
  2. Per-Turn — changes broken down by conversation turn

No need to switch to another terminal to run git diff, and no need to scroll through chat history guessing which files Claude modified.

How to Use It

/diff

No arguments needed. It opens an interactive dialog immediately.

What the Interface Looks Like

Top: Source Selector

Current . T1 . T2 . T3
  • Current — git diff of working directory vs HEAD, including unstaged and untracked files
  • T1, T2, T3… — changes from each conversation turn (most recent first)

Use left/right arrow keys to switch between sources.

Middle: File List

After selecting a source, all modified files in that scope are listed:

> src/utils/auth.ts              +15 -3
  src/components/Login.tsx       +42 -0
  src/tests/auth.test.ts         +28 -5
  package.json                   +1 -0

Each file shows its path and line additions/removals. Untracked new files are labeled “untracked”, binary files labeled “Binary file”.

Use up/down arrow keys to select a file, press Enter to view details.

Bottom: File Details

Press Enter to open the detailed diff view for a single file:

  • Line-by-line differences with line numbers
  • Word-level highlighting — not just marking entire lines as added/removed, but pinpointing exactly which words changed
  • Green for additions, red for removals
  • Changes exceeding 400 lines are truncated

Press left arrow or Esc to return to the file list.

Keyboard Shortcuts

KeyAction
← / →Switch source (Current / T1 / T2…)
↑ / ↓Select file
EnterView detailed diff for selected file
Return from detail to list view
EscClose dialog

Two Data Sources Explained

Current: Git Perspective

The “Current” tab shows the result of git diff HEAD — all changes in your working directory relative to the last commit.

Its data comes from actual git commands:

  • git diff HEAD --numstat — get addition/removal stats per file
  • git diff HEAD — get full diff content
  • git ls-files --others --exclude-standard — list untracked new files

Built-in safeguards:

  • Over 500 files: shows stats only, no details
  • Single file over 1MB: skipped
  • Single file over 400 changed lines: truncated
  • Merge/rebase/cherry-pick in progress: diff not shown
  • Git timeout: 5-second protection

This perspective is ideal for checking all changes before committing.

Per-Turn: Conversation Turn Perspective

The “T1”, “T2” tabs show changes Claude Code made in each conversation turn.

The data source isn’t git — it’s the conversation messages themselves. Claude Code extracts FileEdit and FileWrite results from tool call records, reconstructing each turn’s diff.

Benefits of this perspective:

  • Traceable — you can see “what Claude changed in round one, what it changed in round two”
  • Unaffected by git state — even if you manually modified files or ran git add in between, Per-Turn view still accurately reflects Claude’s changes
  • Most recent first — quickly check what just happened in the latest turn

Each turn’s tab shows a preview of your input message (first 30 characters) to help you recall what that turn was about.

Typical Use Cases

Scenario 1: Pre-Commit Review

You: Refactor the auth module, split into separate service and controller

(Claude Code executes multiple rounds of changes)

You: /diff

Switch to the “Current” tab, verify all file changes look reasonable, confirm there are no unexpected modifications, then commit with confidence.

Scenario 2: Turn-by-Turn Audit

A complex task where Claude Code went through 5 conversation turns. You want to know what each step did:

/diff

Switch from T1 through T5, reviewing each turn’s changes to understand Claude’s approach and execution process.

Scenario 3: Combine with /review

Check current changes with /diff first, then ask Claude to review:

/diff

(after reviewing changes)

Review these changes for me, focusing on security

Scenario 4: Combine with /rewind

Found a problematic change in one turn using /diff? Use /rewind to roll back to before that turn. The Per-Turn view in /diff adapts automatically — reverted turns disappear.

Relationship with Other Commands

CommandRelationship
/review/diff views changes, /review reviews PRs. One for local, one for remote
/rewind/diff views per-turn changes, /rewind rolls back to a turn. One views, one reverts
/context/diff views code changes, /context views context usage. Different dimensions of “status check”
/compactAfter context compaction, Per-Turn records are preserved — /diff extracts from messages, unaffected by compaction

Practical Tips

Tip 1: Make Pre-Commit Diff Review a Habit

After every task Claude Code completes, run /diff before committing. This isn’t about distrusting AI — it’s good engineering practice. You should understand every line of code that gets merged.

Tip 2: Use Per-Turn to Understand Complex Tasks

When Claude Code executes a multi-step complex task, Per-Turn view lets you “replay” the entire process. Combined with conversation content, it’s clear what each step did and why.

Tip 3: Watch for Untracked Files

The Current view lists untracked new files. If Claude Code created files you didn’t expect (like temporary files or config files), you can catch them here.

Tip 4: Use Stats View for Large Projects

If /diff shows “Too many files to display details” (over 500 files), the change scope is large. Review the stats first to decide whether to commit in batches.

Final Thoughts

/diff is a simple but essential tool.

It doesn’t modify anything, requires no configuration — it just lets you see exactly what Claude Code changed. In the workflow of “letting AI write code,” this step may seem redundant but is actually critical — understanding the changes is what it means to truly own your code.

Make /diff a habit, and you’ll feel much more in control of AI-generated code.

More Articles

© 2026 vincentqiao.com . All rights reserved.