Overview

Claude Code produces shippable work when the brief states scope, a command that proves success, and what not to touch. It fails predictably when asked to interpret a one-line request. For install and login see set-up-claude-code; for Claude versus GPT model choice see claude-vs-gpt.

Give Claude a check it can run

Claude stops when the work looks done, so supply a pass or fail signal: tests, a build exit code, a linter, or a screenshot diff. Pick how hard the check gates the stop.

  • In the prompt: “run the tests and iterate until they pass.”
  • Across a session: a /goal condition that a separate evaluator re-checks after every turn.
  • As a gate: a Stop hook that runs the check and blocks the turn from ending until it passes. See claude-code-hooks.
  • By a second opinion: a subagent that reviews the diff in a fresh context.

Ask for evidence (the command and its output), not an assertion. “Looks good” is not a criterion; “npm run build exits 0” is.

Explore, plan, then code

Use plan mode (Shift+Tab until plan mode on, or claude --permission-mode plan) when the approach is uncertain, the change spans several files, or the code is unfamiliar. Ctrl+G opens the plan in your editor. Skip planning when you could describe the diff in one sentence. For a larger feature, ask Claude to interview you with the AskUserQuestion tool, write the result to SPEC.md, and implement from that spec in a fresh session.

Write the brief

A brief names the mission, environment, phases, file paths where location is load-bearing, acceptance criteria, and non-goals. Put a verify line under each phase so a failure stops the run there instead of compounding.

## Phase 2: update the schema
[steps]
Verify: run `npm run build` and paste the last 10 lines. Do not start Phase 3 until it exits 0.
 
## Non-goals
- Do not refactor the auth module.
- Do not add or remove dependencies.
- Do not modify any file not named in this brief.

Name paths for config, route, and schema files; let Claude choose paths for conventional new files such as a test.

Keep durable context in anchor files

Multi-session work needs files Claude re-reads: CLAUDE.md for standing rules, TODO.md for the open backlog, and SESSION_LOG.md for what each session did and deferred. Chat history ages out; these files do not. CLAUDE.md is context, not enforcement, so rules that must run every time belong in hooks. See claude-code-claude-md.

Manage the session

  • Run /clear between unrelated tasks. After two failed corrections on the same issue, /clear and restart with a prompt that includes what you learned.
  • Esc stops mid-action; Esc Esc or /rewind restores earlier conversation and code state. Checkpoints track only Claude’s file-editing tools, not Bash side effects, so keep using git.
  • Delegate wide investigations to subagents so the file reads stay out of the main context. See claude-code-subagents.

Know the failure modes and their guardrails

  • Unscoped find-and-replace. Scope every rename to a file or directory: “In src/config.ts only, rename apiUrl to endpointUrl; do not rename occurrences in test files.”
  • Over-editing. Pin the change (“fix the null check on line 47; do not reformat or rename”) and read git diff --staged before committing. A diff larger than the brief means the non-goals were too loose.
  • Helpful refactors. The refactor is often correct and still unreviewed and untested in isolation. Name off-limits areas in the non-goals.
  • Skipped verification. Require the command output in the reply, not the word “verified”.
  • Invented dependencies. Tell Claude to run npm ls <pkg> before any new import and to ask before adding a package.
  • Voice or convention drift. A session that starts in the house voice can slide into marketing phrasing by the third section. Put the rules in CLAUDE.md and restate the one or two critical ones in the brief. If a rule keeps being skipped, mark that line “IMPORTANT”; emphasizing many lines dilutes all of them.