53 53. Working Effectively with Claude Code
Claude Code can read your files, run commands, and fix its own mistakes, but how much you get out of it depends on how you work with it. This page collects the habits that matter most, based on Anthropic’s official best practices.
53.1 The core workflow
As of Oct 6, 2026 · Official docs: Best practices for Claude Code
1. Explore --> 2. Plan --> 3. Implement --> 4. Verify --> 5. Commit
plan mode: Claude leave plan tests, build, clear message;
read and ask writes a mode; Claude run the app; you review
questions plan; you edits files fix failures the diff
review it
- Explore in plan mode: press
Shift+Tabuntil the status bar shows⏸ plan mode on, or start withclaude --permission-mode plan. Claude reads files and answers questions but doesn’t edit your files (Permissions, Modes, and Safety). - Plan: ask “which files need to change? Create a plan.” Press
Ctrl+Gto open the plan in your text editor and change it before approving. - Implement: approve the plan, and ask Claude to write tests, run them, and fix any failures.
- Verify and commit: see the sections below.
Planning adds overhead, so skip it for small, clear changes. If you could describe the change in one sentence (fix a typo, rename a variable), just ask for it.
53.2 Give Claude a way to check its work
As of Oct 6, 2026 · Official docs: Best practices for Claude Code
This is the single most useful habit. Claude stops when the work looks done. If it has a check it can run (tests, a build, a linter, a screenshot to compare with a design), it can run the check, read the result, and keep fixing until the check passes. Without one, you are the only check, and every mistake waits for you to notice it.
| Instead of… | Try… |
|---|---|
| “implement a function that validates email addresses” | “write a validateEmail function. Test cases: user@example.com is true, invalid is false, user@.com is false. Run the tests after implementing” |
| “make the dashboard look better” | “[paste screenshot] implement this design. Take a screenshot of the result, compare it to the original, list the differences, and fix them” |
| “the build is failing” | “the build fails with this error: [paste error]. Fix it and verify the build succeeds. Fix the root cause; don’t just hide the error” |
Ask for evidence, not just “done”: the test output, the command it ran and what it returned, or a screenshot. The bundled /verify command goes one step further: it builds and runs your app to confirm a change really works.
53.3 Be specific and give context
As of Oct 6, 2026 · Official docs: Best practices for Claude Code · Prompt library
Claude can infer a lot, but it can’t read your mind.
| Strategy | Vague | Specific |
|---|---|---|
| Scope the task | “add tests for foo.py” | “write a test for foo.py covering the case where the user is logged out. Avoid mocks.” |
| Point to an example | “add a calendar widget” | “look at how the existing widgets on the home page are built, and follow the same pattern for a calendar widget” |
| Describe the symptom | “fix the login bug” | “users say login fails after their session times out. Check the auth flow in src/auth/. Write a failing test that reproduces it, then fix it” |
Give Claude the real material instead of describing it:
- Type
@to mention a file:explain the logic in @src/utils/auth.js. - Paste a screenshot (
Ctrl+V;Alt+Von Windows) or drag an image in. Screenshots of error pages and designs work well. - Paste the exact error message or log lines.
- Pipe data in from the terminal:
cat error.log | claude -p "explain this error".
For a bigger feature, let Claude interview you before it builds anything:
I want to build [brief description]. Interview me in detail using the
AskUserQuestion tool. Ask about implementation, UI/UX, edge cases, and
tradeoffs. Keep interviewing until we've covered everything, then write a
complete spec to SPEC.md.
Then start a fresh session to build it from SPEC.md, with a clean context focused only on implementation.
53.4 Steer early and keep sessions focused
As of Oct 6, 2026 · Official docs: Best practices for Claude Code · Checkpointing
Escstops Claude mid-action. The work so far is kept, so you can redirect.- Type a correction and press
Enterwhile Claude works; it reads your message after its current step. Esctwice (on an empty prompt) or/rewindrestores the code and/or the conversation to an earlier point. You can also just say “undo that”./clearbetween unrelated tasks (Context, Models, Effort, and Usage).- Corrected it twice and it’s still wrong? The context is now full of failed attempts. Run
/clearand write a better first prompt that includes what you learned. - Use subagents for research: “use subagents to investigate how our login handles expired sessions” keeps all that file reading out of your main context (Subagents).
- Name and resume sessions:
/rename login-fix, then laterclaude --continue(the most recent session) orclaude --resume(pick from a list).
53.5 Git habits with Claude
As of Oct 6, 2026 · Official docs: Checkpointing · Common workflows
Claude Code’s checkpoints let you rewind Claude’s file edits, but they only track changes made with Claude’s file-editing tools, not files changed by shell commands or other programs, and they can’t undo things outside your computer, such as a database change or a deployment. Git is your real safety net (What Is Version Control?):
- Commit before a big change, so you have a clean point to return to.
- Review the diff before you commit:
git diffin the terminal, or/diffinside Claude Code. You can also ask: “review my uncommitted changes and flag anything that looks risky before I commit”. - Let Claude write the commit message: “commit these changes with a message that summarizes what I did”. Then read it.
- Make small, frequent commits, so undoing one step is easy.
- Get a second opinion:
/code-reviewchecks your current changes for bugs in a fresh context (Pull Requests and Code Review).
53.6 Understanding a repository without changing it
As of Oct 6, 2026 · Official docs: Common workflows · Prompt library
To learn an unfamiliar project safely, start in plan mode:
cd ~/Documents/some-project
claude --permission-mode planThen ask the questions a new team member would ask:
give me an overview of this codebase: architecture, key directories, and how the pieces connect
trace what happens when a user logs in, from the front end to the database
which files would I need to touch to add a "remember me" checkbox? Don't edit anything yet.
For stronger guarantees (removing the editing tools entirely, or working on a read-only copy), see Permissions, Modes, and Safety.
53.7 Keep Claude working until it’s done: /goal and /loop
As of Oct 6, 2026 · Official docs: Keep Claude working toward a goal · Run prompts on a schedule
Normally Claude works until it thinks it is done and then waits for you. Two commands keep it going.
/goal <condition> sets a finish line. Claude starts working right away. After every turn, a separate small, fast model reads the conversation and judges whether the condition is met; if not, Claude starts another turn on its own. The goal ends when the condition is met, when the judge decides it is impossible, or when an error you have to fix stops the work. For example, to keep fixing bugs until the tests pass:
/goal npm test exits 0 with all tests passing; fix the code, not the tests; or stop after 20 turns
A good condition has one measurable end state, says how Claude should prove it, and names what must not change. The judge doesn’t run anything itself: it only reads what Claude showed in the conversation. Type /goal alone to see progress, and /goal clear to stop early.
/loop [interval] [prompt] re-runs a prompt on a schedule while the session stays open:
/loop 30m run the test suite and fix any new failures
Without an interval, Claude picks the wait itself (one minute to one hour). Without a prompt, it runs a built-in maintenance routine: continue unfinished work, tend to the current pull request, then hunt for bugs or simplify code. Press Esc to stop a self-paced loop. To stop a loop with a fixed interval, ask Claude to cancel it; otherwise it expires after seven days.
| Next turn starts when… | Stops when… | |
|---|---|---|
/goal |
The previous turn finishes | The condition is met or judged impossible, an error you must fix occurs, or you run /goal clear |
/loop |
A time interval passes | You stop it, or Claude decides the work is done |
Both run only while your session is open, and every turn counts against your usage. Neither changes your permission mode: in Manual mode, Claude still stops to ask before actions that need approval. For jobs that should run even when your computer is off, see routines on Claude Code Beyond the Terminal.
53.8 Common mistakes
As of Oct 6, 2026 · Official docs: Best practices for Claude Code
| Mistake | What happens | Fix |
|---|---|---|
| The kitchen-sink session | One session drifts across unrelated tasks; the context fills with noise | /clear between unrelated tasks |
| Correcting over and over | The context fills with failed attempts | After two failed corrections, /clear and write a better prompt |
| The over-long CLAUDE.md | Important rules get lost in the noise | Prune it; turn must-happen rules into hooks |
| Trusting without verifying | Plausible-looking code that misses edge cases | Always give Claude a check (tests, scripts, screenshots); if you can’t verify it, don’t ship it |
| Endless exploration | “Investigate X” with no limits reads hundreds of files | Scope the question, or use a subagent |
| Not reading the diff | You commit code you don’t understand | Review every diff; ask Claude to explain anything unclear |
A fresh context reviews code better, because it isn’t attached to the code it just wrote. The official guide suggests a Writer/Reviewer pattern: one session implements a feature; a second session (or a subagent) reviews it, for example “review the rate limiter in @src/middleware/rateLimiter.ts for edge cases and race conditions”; then you paste the review back into the first session to fix the issues. Tell the reviewer to report only problems that affect correctness or the requirements: a reviewer asked to find gaps will usually find something, and chasing every comment leads to over-engineering.
Practice Questions
Easy
Question 1 · Ordering
Put these steps of the recommended workflow in order: Implement, Commit, Explore, Verify, Plan.
Question 2 · Multiple choice
What does plan mode do?
- Claude edits files immediately, without asking
- Claude reads files and proposes a plan, but doesn’t edit your files until you approve
- Claude only answers general questions and can’t read your files
- Claude schedules the work to run later
Question 3 · True or false
Because Claude Code has checkpoints and /rewind, you no longer need Git.
Question 4 · Matching
Match each action with what it does.
| Action | What it does | |
|---|---|---|
1. Esc |
A. Re-runs a prompt on a time interval | |
2. Esc twice (empty prompt) |
B. Keeps Claude working until a condition is met | |
3. /clear |
C. Stops Claude mid-action so you can redirect | |
4. /goal |
D. Opens the rewind menu | |
5. /loop |
E. Starts a new conversation with an empty context |
Question 5 · Short answer
Why is “give Claude a way to check its work” called the single most useful habit?
Question 6 · Multiple choice
For which task is it most reasonable to skip plan mode?
- Adding login with Google to an app you don’t know well
- Changing how data flows through five different files
- Fixing a typo in a button label
- Choosing between two database designs
Medium
Question 7 · Rewrite
Rewrite these vague prompts to be specific and checkable:
- “Fix the signup form.”
- “Make the homepage look nicer.”
Question 8 · Write the command
Write a /goal that keeps Claude fixing code until npm test passes, without letting it change or delete the test files, and that stops after at most 15 turns.
Question 9 · Write the command
Write a /loop command that checks every 10 minutes whether the deployment has finished and reports what happened.
Question 10 · Scenario
Sam has corrected Claude twice about how the app should calculate event capacity, and the result is still wrong. What does the official guide recommend, and why?
Question 11 · Write the command
Maria wants Claude to explain a classmate’s project without changing anything. Write the commands to open it in plan mode, and give one good first prompt.
Question 12 · Find the bug
What is wrong with this goal, and how would you fix it?
/goal make the app better
Question 13 · Multiple choice
How does the /goal judge decide whether your condition is met?
- It runs your tests itself after every turn
- It reads the conversation, including what Claude ran and the results it showed
- It opens and inspects your files
- It asks you after every turn
Question 14 · Scenario
Claude just finished a new feature for Maria. List the Git habits she should follow before and after this point.
Hard
Question 15 · Scenario
Sam set /goal all tests pass. Claude made changes and wrote “All tests should pass now,” and the goal was marked as met, but npm test actually fails. How could this happen, and how should Sam write the goal instead?
Question 16 · Compare
Which tool fits each job best: /goal, /loop, or a hook? Explain briefly.
- Keep fixing a failing build until it succeeds.
- Every 15 minutes, check whether a classmate has commented on your pull request.
- In every session in this project, automatically run the linter whenever Claude finishes, with no exceptions.
Question 17 · Long answer
Explain the Writer/Reviewer pattern and why a fresh context helps code review. What instruction should you give the reviewer, and why?
Question 18 · Scenario
Maria plans to start /loop 15m run the test suite and fix any new failures before going to bed and close her laptop. List at least three things she should think about.
Question 19 · Long answer
Describe how you would add a “forgot password” feature to the club-events site with Claude Code, using at least five habits from this page.
Question 20 · Scenario
Sam types “investigate why the app is slow.” Claude reads more than 200 files and his context fills up before anything is fixed. What went wrong, and how could he ask better?
Challenge
Question 21 · Hands-on
Pick a small practice project (for example the Git practice project). Commit its current state, then:
- In plan mode, ask Claude to explain the project and propose one small improvement with a way to verify it.
- Approve the plan and let Claude implement it, asking for evidence (output or a screenshot) that it works.
- Use
/rewindto undo Claude’s edits, then redo the change with a more specific prompt. - Review the diff, then have Claude commit with a clear message.
Write a short reflection: which habit made the biggest difference?