← Back to Claude Code
Claude Code / Lesson 04

Plan, edit, test, and review a change

Turn a small bug report into a change you can verify and keep.

Before you begin

Use a repository with Git and a reproducible bug. Inspect the current status before working; preserve any edits already there. Know the expected behavior and a command or manual check that can demonstrate it.

  1. PLANPlan mode

    Locate the problem; agree on files and checks.

  2. EDITBounded edit

    One small change with tests; read each permission.

  3. REVIEWReview evidence

    Run checks; read git diff and real behavior.

  4. RECOVERRecover

    /rewind for eligible edits; Git for durable history.

DiagramThe four stages of this guide, in order.

1. Explore in Plan mode

Shift+Tab cycles available permission modes. Select Plan mode for analysis before implementation. Ask Claude to locate the failure, name affected files, and propose acceptance checks. Read its plan and correct misunderstandings before allowing edits.

2. Implement a bounded task

Return to the normal approval mode when ready. Read each requested file or command permission. Ask for one small change and tests tied to the bug. If the task drifts, press Escape to interrupt and restate the boundary. Do not enable bypass-permissions just to avoid prompts.

text
Fix only the blank-email validation bug. Preserve unrelated edits.
Add a check that fails before the fix and passes afterward.
Run the relevant checks and show the diff.
Do not commit, push, or deploy.
Claude Code edit prompt for test/validate.test.js showing four added lines for a blank-email test, with options Yes, Yes allow all edits during this session, and No.
ScreenshotIn the default mode every edit waits for approval and shows the exact diff first. Read it before choosing Yes; “allow all edits” removes these checks for the rest of the session. Captured Oct 19, 2026 · Claude Code 2.1.223 · macOS

3. Review evidence, not just the summary

Run the relevant checks yourself or inspect the reported results. Read git diff for unintended changes, missing error cases, and secrets. A successful test does not prove every workflow. Check the concrete user behavior too. Commit only the files you intend to keep after review.

shell
git status --short
git diff --stat
git diff
Claude Code summary after the fix: the blank-email test failed before and all three tests pass after, followed by a diff that shows only one added line in validate.js.
ScreenshotClaude’s own summary of the change. Its diff shows one added line — compare it with the real git diff below. Captured Oct 19, 2026 · Claude Code 2.1.223 · macOS
Shell output of git status --short, git diff --stat, and git diff src/validate.js showing two added lines, including an else if line for the email format check.
ScreenshotThe real diff adds two lines: the summary above left out the else if that keeps the format check. This is why you read git diff yourself before keeping a change. Captured Oct 19, 2026 · Claude Code 2.1.223 · macOS

4. Recover deliberately

Checkpoint rewind can restore eligible Claude edits; use /rewind and read its options. It does not reverse every shell command, remote write, or external effect. Use Git and backups for durable recovery, and never discard existing user changes to undo one generated change.

Practice & self-check

YOUR TURN / PRACTICE

Fix one small bug on a practice branch. Compare the behavior before and after, inspect the diff, and record which checks you ran.

When you’re done, take a moment to check:

Read the official sources

CLI instructions checked against official documentation; API examples tested with simulated responses. Product-account walkthroughs were not performed.

Was this lesson useful?

Start with a question