Coding
Use Claude and Claude Code to write, debug, test, review and restructure code in a real project.
Code generation
Build from a spec, one layer at a time, with agreed types and an existing file as the pattern to follow.
4 techniques →-
How Do You Build a Whole Module From a Spec? Have Claude interview you until the requirements are pinned down, save them to SPEC.md, then build from that file in a fresh session. Level 3: Workflows
- 1Claude interviews you
- 2SPEC.md
- 3Fresh session builds
- 4Reviewer checks against SPEC.md
-
Should Claude Build a Whole Feature at Once? Build one layer at a time when you plan to read and keep the code. Level 3: Workflows
- 1Datatests, commit
- 2Logictests, commit
- 3APItests, commit
- 4UIrun the app, commit
Then repeat -
How Do Types Make Claude's Code More Accurate? Agree the types and function signatures first, then have Claude implement them. Level 2: Context
- 1Agree the types
- 2Claude implements
- 3Language server reports errors
- 4Tests check behavior
-
How Do You Make Claude Match Your Code Style? Name one existing file that already does something similar, and tell Claude to follow it. Level 2: ContextDo
- Name one current file
- Include its test
- Let the file set the style
- Flag old patterns in CLAUDE.md
Don't- Point at deprecated code
- Describe a different style as well
- Write out your whole style guide
Debugging
Reproduce the bug with a failing test, trace silent failures with logs, and reset when the first fix doesn't work.
4 techniques →-
How Do You Debug a Bug With No Error Message? Have Claude add a few temporary, labeled logs along the suspect path, run the code, and find the first value that's wrong. Level 2: Context
- 1subtotal=90 (number)correct
- 2fee="10" (string)first wrong value, so fix here
- 3total="9010" (string)the symptom, not the cause
-
What If Claude's First Bug Fix Doesn't Work? Stop correcting, clear the session, and ask for two competing causes plus the one cheap check that tells them apart. Level 3: WorkflowsCause Aan environment variable differs
- Printed config differs between machines
- Fix the variable
Cause Ba stale build cache- Printed config matches on both
- Clear the cache and rebuild
-
How Do You Find What Change Broke Your Code? Give Claude the full error and the last known good point together, and ask how the change caused the error. Level 2: Context
- 1Full error and trace
- 2Diff since last good
- 3Named mechanism
- 4Smallest fix
-
How Do You Make Claude Fix the Real Bug? Ask for a failing test that reproduces the bug before any fix. Level 2: Context
- 1Write the failing test
- 2Make the smallest change
- 3Run the same test
- 4Read the output
Back to the change until that test passes, unedited
Architecture
Get real design options and honest trade-offs, settle the interface in plan mode, and record the decision before it's lost.
4 techniques →-
How Do You Record a Design Decision With Claude? Right after you decide, while the discussion is still in the session, have Claude draft a one-page Architecture Decision Record in your repo. Level 3: Workflows
- 1Titlenumbered, and numbers are never reused
- 2Contextask for rejected options here
- 3Decision"We will write events to an outbox table"
- 4Statusmark it superseded, never edit it
- 5Consequencesgood, bad and neutral
-
How Do You Design an Interface With Claude First? Start in plan mode, so Claude reads your code and proposes the interface while edits are blocked. Level 3: Workflows
- 1/plan with your constraints
- 2Claude reads and proposes
- 3Ctrl+G to edit the plan
Keep planning until the shape is right, then approve -
How Do You Get Honest Trade-offs From Claude? Name your criteria in order of importance, then ask for a table with a concrete judgment in every cell and a label saying where each judgment came from. Level 3: Workflows
- REPOjudged from this code
- DOCSchecked a current source, with a link
- ASSUMEDneither, so verify before you commit
-
How Do You Get Real Design Options From Claude? Ask for three approaches, each built around a different priority, and tell Claude to stop before it builds anything. Level 3: WorkflowsThe decision
- Simplest that works
- Holds at 10x
- Ships by the date
- Don't build it yet
Refactoring
Restructure code one named move at a time, starting with characterization tests when the code has none.
4 techniques →-
Should You Rename Code Before Refactoring It? Yes, if the names are vague. Level 2: ContextSafe in a names-only passNeeds its own plan
- Local variable
- Private function
- Exported name
- Stored JSON key
-
How Do You Break Up a Huge Function With Claude? Have Claude list the function's separate responsibilities in order of risk, then extract only the safest one. Level 3: Workflows
- 1Rank seams by risk
- 2Move the safest onemove it, don't rewrite it
- 3Run the tests
- 4Commitone seam per commit
Repeat until a seam won't separate cleanly -
How Do You Refactor Code That Has No Tests? Have Claude write characterization tests that record what the code does today, quirks included. Level 3: Workflows
- 1Record today's behavior
- 2Prove the tests can fail
- 3Lock the tests
- 4Refactor
-
How Do You Refactor With Claude Safely? Ask for one named move at a time, such as extract, rename or inline, with behavior unchanged. Level 3: Workflows
- 1Name the move
- 2Make only that move
- 3Tests pass
- 4Commit
Then repeat
Multi-file workflows
Approve the file list before edits, let the type checker drive wide changes, and split big diffs into commits you can review.
4 techniques →-
How Do You Keep Claude's Big Diffs Reviewable? Have Claude split the work into separate commits, each with one job, then review them one at a time with /code-review and a commit range. Level 3: Workflows
- 1refactor: extract validateCartno behavior change, so skim
- 2feat: apply coupon codesthe real review goes here
- 3style: format touched filesskim
-
How Do You Change a Function Used Everywhere? Change the definition first, let the type checker list every site that broke, then have Claude work through them until there are no errors. Level 3: Workflows
- 1Change the definition
- 2Type checker lists sites
- 3Fix each site
- 4Search what types can't see
-
What Does Claude Need Before a Multi-File Edit? In Claude Code, less than you might expect. Level 3: WorkflowsClaude Code can findby reading the repo
- File layout and callers
- Types and tests
- Conventions in the code
Only you can saynot in the repo- What must not change
- Which of two patterns wins
- Rollout and data constraints
- What done means
-
How Do You Approve Claude's File List Before Edits? Use plan mode, and require the plan to be a table of every file Claude will create, change or delete. Level 3: Workflows
- 1Claude lists each file and what changes
- 2You trim it with Ctrl+G
- 3Approve, then compare with git diff --statafter the work
Claude Code
Keep Anthropic's coding agent on track with plan mode, a short CLAUDE.md and a check that comes back pass or fail.
4 techniques →-
What Should Go in Your CLAUDE.md? Only what Claude Code can't work out by reading your repo: the exact commands that prove work is done, places where the code misleads, decisions that never made it into the code, and anything you've corrected twice. Level 3: Workflows
- 1Commands that prove the work is donetest, typecheck, lint
- 2Places where the code misleadsold patterns not to copy
- 3Decisions that aren't in the repodeploys, error helper
- 4Anything you've corrected twiceadd as it happens
-
How Do You Make Claude Code Check Its Own Work? Give it a command that comes back pass or fail, and put that command in your prompt or CLAUDE.md. Level 3: Workflows
- 1A line in your promptClaude decides
- 2/goal with a conditiona second model judges
- 3A Stop hook running your checkClaude Code enforces
- 4CI, and a person approving the mergeoutside the session
-
Should You Tell Claude Code to Explore Before It Edits? Usually not. Level 4: Multi-tool systemscost of a wrong guess →Read-only step firstplan mode or a subagentPlan modesee what it learned before editsLet it reada wrong guess is cheap to undoLet it readname the file and the symptomhow well you know this code →
-
How Do You Make Claude Code Plan Before It Edits? Use plan mode. Level 3: Workflows
- 1Enter plan mode
- 2Claude reads and writes a plan
- 3Edit it with Ctrl+G
- 4Pick an approval option
Testing
Get failing tests that catch the bug, tests of behavior rather than implementation, table-driven cases, and a ranked list of missed edge cases.
4 techniques →-
How Do You Get Claude to Find the Edge Cases You Missed? Ask for a ranked list of untested cases before you ask for any test code, and give Claude the function plus its current tests. Level 2: Contexta caller can reach it →Test it if quickreal, but low stakesTest it nowmoney, auth or user dataLeave it outno caller can produce itTest the guardsomething earlier rejects it, so test thatdamage if it fails →
-
How Do You Make Claude Test Behavior, Not Implementation? Write the behaviors as plain sentences yourself, and ask Claude to test those, with mocks allowed only at real boundaries such as the network, disk or clock. Level 3: WorkflowsDo
- Assert the 6th request is rejected
- Mock only network, disk or clock
- Write the behavior sentences yourself
Don't- Assert bucket.refill() was called
- Derive tests by reading the code
- Let a mock-heavy suite set the style
-
How Do You Turn Examples Into a Table-Driven Test? Give Claude your input and expected-output pairs, and ask for one parameterized test where each example is a labeled row. Level 2: Context
- Vitesttest.each, with titles filled from each row
- pytest@pytest.mark.parametrize, reports the failing case
- Goa table of cases run with t.Run
-
How Do You Get Claude to Write a Test That Catches the Bug? Ask for a failing test before the fix, and make Claude show you the failure. Level 2: Context
- 1Bug report
- 2Failing test, output shown
- 3You approve
- 4Smallest fix
- 5Same test passes
Code review
Run /code-review on what changed, ask for inputs that break the code, rank the findings, and give Claude your team's checklist.
4 techniques →-
How Do You Ask Claude What Would Break Your Code? Ask for failing inputs, not an opinion. Level 2: Context
- 1Fresh reviewerhasn't seen your reasoning
- 2Concrete failing inputsranked by damage
- 3You verifydrop what callers already prevent
- 4Failing tests, then fixesfix only what fails
-
How Do You Rank Claude's Code Review Findings? Ask for a fixed scale, and a concrete failure for anything at the top of it. Level 2: Context
- 1Importantfix before merging
- 2Nitminor, doesn't block
- 3Pre-existingreal, but not from this change
-
How Do You Give Claude a Code Review Checklist? Write down the checks your team actually cares about, and put them where the review will read them. Level 2: Context
- 1In the promptthis one review
- 2CLAUDE.md/code-review and the service
- 3REVIEW.mdthe Code Review service only
-
How Do You Make Claude Review Only What Changed? In Claude Code, run /code-review. Level 2: Context
- 1/code-reviewbranch plus uncommitted
- 2/code-review 1234a pull request
- 3/code-review main...my-featureone branch against another
- 4/code-review HEAD~15..HEADthe last 15 commits
- 5/code-review src/autha file or folder
API integration
Give Claude current docs so it doesn't invent fields, generate a typed client, and make every API failure visible.
4 techniques →-
How Do You Get Claude to Handle API Errors Properly? Have it build a table first: every failure the API documents, and what your code does about each one, whether that's retry, fail fast, tell the user or degrade. Level 3: WorkflowsA retry can help
- Connection errors and timeouts
- 408 and 5xx, including 529
- 429 with a retry-after header
A retry won't help- 400: bad request or your own spend limit
- 401, 403 and 404
- 429 with no retry-after: the spend cap
-
How Do You Generate a Typed API Client With Claude? If the API publishes an OpenAPI schema, generate the types with a tool, then have Claude write a thin client around them. Level 3: Workflows
- 1Schema or real response samplesthe source of truth
- 2Generated typesa tool, not the model
- 3Thin clientClaude writes this
- 4Validator at the boundarychecks what really arrives
-
How Do You Stop Claude Swallowing API Errors? Tell it, in the prompt and in CLAUDE.md, that no catch block may log and continue, that every request has a timeout, and that failures must surface as typed errors carrying the request ID. Level 2: ContextDo
- Raise a typed error
- Set a timeout on every request
- Log the request ID
- Requeue on a rate limit
Don't- Log and continue
- Return null on failure
- Check only the status on a stream
- Retry a write with no idempotency key
-
How Do You Stop Claude Inventing API Fields? Give it the current docs for the endpoints you need, and tell it not to use anything that isn't in them. Level 2: ContextFrom older codereturns a 400 today
- thinking type enabled
- A prefilled assistant message
- tool_choice any or tool
From the current docswhat the page says to use- thinking type adaptive, plus effort
- output_config.format
- tool_choice auto, with strict tools
How well do you code with Claude?
Six situations from real work in Claude Code, covering plans, checks, bugs and reviews. See the answer as soon as you choose. No sign-up.
Claude Code or the Claude app?
Use Claude Code when the work lives in a repository. It reads your code, edits files and runs commands, so it can run your tests and act on the result. Use the Claude app when you want to reason through a problem or work on a snippet. There, Claude sees only what you paste or add, and its GitHub integration is read-only, with no commit history. Most lessons here work in both, and each card says where the steps differ. Anthropic's API docs list Opus 5.5 as the model to start with for most workloads, while its Claude Code help article recommends Sonnet for most coding. Sonnet costs half as much, so try it first and move up when the answer falls short.
What Claude can't get from your code
Anthropic's Claude Code best practices come down to three points, and this course follows them. Tell Claude what it can't see, such as decisions, constraints and what done means. Give it a check that passes or fails, so it isn't judging its work by how finished it looks. And enforce rules that have no exceptions with hooks and deny rules, because a line in a prompt or CLAUDE.md is still Claude's call. Much older advice no longer applies. The same page says you can stop describing your file layout, stop writing "think hard", and stop adding ALL CAPS to your instructions.
Where to start
Start with the lesson that matches the job in front of you: code generation, debugging, architecture, refactoring, multi-file changes, Claude Code itself, testing, code review or API integration. If you only learn one habit, make it asking for evidence, meaning the command Claude ran and its output, instead of accepting a summary that says it worked.
Is Claude good for coding?
Anthropic says Opus 5.5 is strongest on multistep work in a real repository, such as carrying a change through a large code base until its tests pass. That's a vendor claim, so test it on your own code. The result depends heavily on whether Claude has a check it can run, such as tests or a type checker.
Which Claude model is best for coding?
Claude Code runs Opus 5.5 at medium effort by default on most plans and providers. Anthropic's docs say Sonnet costs less on routine work, and that Fable 5.1 is available if you select it. As a rule of thumb, try /effort high on a hard bug before changing model.
Is Claude Code free?
No. Claude Code isn't on the Free plan. You need a paid plan, starting with Pro, or API billing. Anthropic's pricing page has current prices. The Claude app's Free plan can still help with snippets you paste in.
What is the difference between Claude and Claude Code?
Claude is the chat app, where it sees only what you give it. Claude Code is Anthropic's coding agent, which works inside your project from a terminal, editor, desktop app or browser, and can read files, edit them and run commands. Both use the same Claude models.
How do I stop Claude from breaking my code?
Commit before each change, give Claude tests it can run, and ask to see the output. For hard limits, use a deny rule or a hook, which Claude Code enforces no matter what the model decides. Rewind is useful for quick undo, but it doesn't replace git.