Part ofWhat Is Claude Code? The Complete Guide
How to get Claude to code anything: the five-part prompt, plan mode first, small verifiable steps, letting it run tests, and reviewing every diff.
In This Article
8 sectionsHow to get Claude to code anything comes down to giving it five things in a single prompt — the outcome in one sentence, the exact files for context, the constraints it must not break, how to verify the result, and room to plan before editing. Specific, evidence-backed prompts ship working code; vague ones flail through wasted turns.
We build and run this site with Claude Code every day, and we've learned the same lesson over and over: the difference between a prompt that ships a feature and one that burns ten turns going nowhere is almost never the model. It's the prompt. Below is the exact playbook we use.
Why most Claude coding prompts flail
Claude Code runs an agentic loop — it reads files, writes code, runs it, reads the output, and adjusts. A vague instruction doesn't just produce vague code; it sends the agent down a wrong path it then has to back out of, spending your turns and its context window on a detour.
The prompts that flail share a shape. They name a wish — "add auth," "make it faster," "fix the bug" — without the outcome, the files, or a way to know when it's done. Claude fills the gaps with assumptions, and often guesses wrong. The prompts that ship do the opposite: they front-load the context so the agent's first move is already the right one. That's the real question behind how to get Claude to code anything — not which magic words to say, but how much of the problem you hand over already specified.
New to the tool? Start with our pillar, What Is Claude Code?, then come back — everything below assumes you're driving the agent, not chatting with a web app.
The five-part prompt: how to get Claude to code anything
After a few hundred sessions, our prompts converged on the same five parts. Miss one and the agent guesses; include all five and it usually one-shots the task. This is the core of how to prompt Claude for code that actually ships.
| Part | What to write | Example |
|---|---|---|
| Goal | One sentence: the outcome, not the method | "Users can reset their password by email." |
| Context | The exact files, models, or routes involved | "src/auth.ts, the User model, the /forgot page" |
| Constraints | What must not change | "Don't alter the login flow or the DB schema." |
| Verification | How Claude proves it worked | "Run npm test auth and show it passing." |
| Next actions | Plan before editing | "Propose a plan first; wait for my OK." |
You don't need every part in separate sentences. A tight prompt reads like: "Goal: users can reset their password by email. Context: src/auth.ts and the User model. Constraint: don't touch the login flow. Verify with npm test auth. Plan first, then wait for my OK." Five clauses, and the agent knows exactly what success looks like before it writes a line.
Plan before you let it edit
The single most useful habit we've found is making Claude plan before it touches a file. In Claude Code's plan mode — Shift+Tab twice, or type /plan — the agent studies your codebase read-only and writes a step-by-step plan you approve before any edit happens. You catch the wrong approach in a paragraph of Markdown instead of in a 300-line diff.
Anthropic's own common Claude Code workflows documentation leans on the same explore-plan-code-commit sequence, and it maps directly onto how to get Claude to code anything larger than a one-liner: research first, agree on the plan, then let it build. For anything touching more than two files, we plan first, every time — it's the cheapest bug fix there is, because the bug never gets written.
Before and after: prompts that ship vs prompts that flail
Abstract advice is easy to nod at and hard to apply, so here are three real rewrites from our own sessions. Same task, two prompts — one that flails, one that ships.
| Prompt that flails | Prompt that ships | What changed |
|---|---|---|
| "Add auth to my app" | "Add email + password login to the Next.js app using the existing User model in src/models/user.ts and NextAuth. Don't touch the signup flow. Verify with npm test auth." | Named the library, the file, a boundary, and a test |
| "Fix the failing test" | "cart.spec.ts › applies discount fails with expected 90, got 100. Read the test and src/cart.ts, find why the discount isn't applied, fix it, and re-run the test." | Gave the error, the files, and the success signal |
| "Make it faster" | "/api/search takes ~2s. Profile it, find the slowest step, and cut it under 500ms without changing the response shape. Show me the diff before applying." | Quantified the goal and set a hard constraint |
Notice the pattern in every rewrite: the winning version names files, quantifies the goal, sets a boundary, and hands Claude a way to check its own work. None is longer than three sentences. Good claude code prompting tips aren't about writing more — they're about front-loading the few specifics the agent genuinely can't guess.
Give it context, constraints, and examples
Context is the multiplier, and you supply it three ways. First, a CLAUDE.md file at your repo root: project rules, tech stack, and conventions Claude reads every session, so you never re-explain them. Second, examples — point at the pattern you want ("match the style of src/api/users.ts") and Claude mirrors it far more reliably than any adjective. Third, reusable Claude Code skills, folders of instructions the agent loads on demand for recurring jobs like commits or reviews.
Anthropic's Claude Code best practices guide makes the same case: the teams getting the most from the agent invest in context — CLAUDE.md, examples, tight tool setup — rather than hunting for cleverer one-off wording. Constraints matter as much as context. Telling Claude what not to change ("leave the public API alone," "don't add dependencies") keeps a small task from ballooning into an unwanted refactor.
Iterate in small steps and let it run the tests
The last habit separates people who get Claude to build whole features from people who get a tangled mess: work in small, verifiable steps. Ask for one feature, review the diff, run the tests, then ask for the next. An agent that can run its own tests will fix most of its mistakes before you ever see them, so always give it the command — npm test, pytest, whatever your project uses — and let it loop until green.
Reviewing diffs is not optional. Claude Code shows you every change; read them the way you'd read a colleague's pull request. When something's off, don't rewrite the code yourself — describe what's wrong and let the agent fix it, which keeps its mental model of the file in sync with what's on disk. This is how to get Claude to code anything reliably: small steps, real tests, reviewed diffs, repeat.
Pick the right model for the coding job
Prompt quality matters more than model choice, but the model still moves the needle on hard problems. Here's our rule of thumb across a normal week.
| Model | Price (input / output per M tokens) | Best coding job |
|---|---|---|
| Claude Haiku 4.5 | $1 / $5 | High-volume, simple edits and sub-agents |
| Claude Sonnet 5 | $2 / $10 intro (then $3 / $15) | Fast, balanced day-to-day coding |
| Claude Sonnet 4.6 | $3 / $15 | Everyday coding, 1M-token context |
| Claude Opus 4.8 | $5 / $25 | Hard reasoning, refactors, code review |
For most tasks, Claude Sonnet 4.6 is the daily driver — fast, cheap enough to iterate freely, with a one-million-token context window that swallows large codebases. When a task needs deep reasoning — a gnarly refactor, a subtle concurrency bug, a thorough code review — Claude Opus 4.8 earns its higher price, posting a 69.2% score on SWE-bench Pro, one of the hardest software-engineering benchmarks. For high-volume mechanical edits, Claude Haiku 4.5 is fast and cheap. Our Claude models explained guide compares them head to head.
Put these together and how to get Claude to code anything stops feeling like luck. Specify the outcome, hand over the files, set the boundaries, plan first, and let the agent test its own work — the prompt does the heavy lifting, and Claude does the typing.
The quick version:
- State the goal as one sentence — the outcome, not the method
- Name the exact files, models, or routes involved
- Say what must not change, then how Claude should verify it
- Ask for a plan first, and review every diff it produces
Claude pricing at a glance
| Plan | Price |
|---|---|
| Free | $0 |
| Pro | $20 / month |
| Max | from $100 / month |
| API | Pay per token |
For the full breakdown of every plan, see our how much Claude costs guide.
Frequently Asked Questions

Written by
InnovateTechie
Writing about Claude and the Anthropic toolkit — models, Claude Code, pricing, features, and fixes, in clear, practical, hands-on guides tested by daily use.
View all posts →





