The prompt patterns that get clean, correct changes from Claude Code, with examples for every kind of task
12 bite-sized sections
3 min read
Free, no signup
Short answer
A free guide to prompting Claude Code in 2026: the anatomy of a good coding prompt, context with files and CLAUDE.md, plan first, constraints, definition of done, prompts for features, bug fixes, refactors, tests, reviews, and explanations, follow-up and correction prompts, effort levels, and common mistakes. For general tips, see our 20 Claude Code Tips guide.
Claude Code can read your project, edit files, and run commands. A clear prompt tells it what to change, what to leave alone, and how to prove the change works. For setup and everyday habits, read our 20 Claude Code Tips guide.
Vague prompts produce big, surprising diffs. Clear prompts produce small, correct ones.
02
Learn the anatomy of a good prompt
Task
What to build, fix, or change
Context
Relevant files tagged with @, plus errors and links
Constraints
Style, libraries, and what must stay untouched
Done means
Tests pass, the behavior works, and the output looks right
Process
Plan first, ask questions, or go straight ahead
03
Give the right context
Tag exact files with @
Paste the complete error message
Attach screenshots for UI work
Store project rules in CLAUDE.md so you never repeat them
04
Plan before changing anything
Read @src/checkout and @tests/checkout. Propose a plan for adding discount codes, with the files to change and the risks. Do not edit anything yet.
Switch to plan mode for larger changes, then approve the plan.
05
Write feature prompts
Add a dark mode toggle to the settings page. Use the existing theme hook in @src/theme.ts, save the choice in local storage, and match the current toggle styles. Done means the toggle works, the choice survives a reload, and the existing tests pass.
06
Write bug fix prompts
On Safari, users get a blank page after login. Console error: [error]. Find the root cause, explain it in two sentences, fix only that cause, and add a test that would have caught it.
07
Write refactor prompts
Split @src/utils/date.ts into smaller functions without changing its behavior. Keep the public API identical, and run the tests both before and after.
08
Write test prompts
Write tests for @src/cart.ts that cover empty carts, discounts, and rounding. Follow the patterns in @tests/order.test.ts. Leave the source code untouched.
09
Ask for reviews and explanations
“Check my changes for bugs, security issues, and missing tests.”
“Explain how authentication works in this project, citing the files.”
“What might break if I upgrade this library?”
10
Correct course
Press Esc the moment it heads the wrong way
State exactly what went wrong and what to do instead
Rewind to an earlier point when you need to
Ask it to keep the change smaller
Revert the changes to the API layer. Change only the UI component, and keep its existing props.
11
Match effort to the task
Lower effort for simple edits and quick questions
Higher effort for tricky bugs and architecture work
A fresh session via /clear for every new task
12
Avoid common mistakes
Saying “make it better” without defining better
Bundling many unrelated changes into one request
Leaving no way to check the result
Letting it edit files you never mentioned
The golden rule
Do not tell Claude Code how to feel. Tell it what to change, what to leave alone, and how you will know it worked.
Task
Context
Constraints
Done means
Plan
Correct
Effort
Rewrite your next request with a task, context, constraints, and a done means line, then compare the diff.
It has 12 sections, starting with “See why prompting matters”, “Learn the anatomy of a good prompt”, “Give the right context” and “Plan before changing anything”, plus 8 more sections.
How long does it take to read?
About 3 minutes. Every section is a short, self-contained card, so you can jump straight to the part you need.
Is this guide free?
Yes. The full guide is free to read on this page, with no sign-up.
For research and ideas only. Results vary and nothing here is a promise of income. See our Disclaimer.
See you Monday!
Weekly newsletter
Everything new, every Monday.
One short email every Monday with everything shipped that week: new free tools and websites, new guides, new free browser tools and what's new in my free Gumroad libraries, plus how the site is growing. Free, and you can unsubscribe anytime.
You sign up on Gumroad, which stores your email to send the newsletter. See our Privacy Policy.
Cookies and your choices
Visits are counted by Cloudflare Web Analytics, which sets no cookies and stores nothing on your device. An affiliate tracking script from Impact.com also loads on our pages and can set its own cookies so partner companies can credit us for sign-ups. Essential storage is always on so pages load and work correctly. You decide whether your browsing preferences are saved on your device. Read the Privacy Policy.