Good Claude Code prompts tell Claude what it can't see in your repo. That means the goal, where to look, and how to check that the work is done. Below are 20 copy-paste prompts for planning, bug fixes, tests, refactors, code review and project setup. Each one follows Anthropic's own best practices for Claude Code.
Replace the square brackets with your file paths, commands and details. Paste a prompt into a Claude Code session started in your project folder. Watch the first minute, and press Esc if Claude heads the wrong way.
What makes a good Claude Code prompt?
Claude Code reads your code well, so you don't need to explain your file layout or framework. A plain first prompt often works. What helps is the knowledge Claude can't get from the repo. Anthropic's docs compare two prompts:
- Vague: "add a calendar widget".
- Specific: "follow the pattern in HotDogWidget.php and build a calendar widget that lets you pick a month and page between years. no new libraries".
The second prompt names the pattern to copy, the behavior and a limit. Three more habits from the docs:
- Hand over what you have. Type
@and a path to include a file, or paste a screenshot of an error. You can also pipe a log in withcat error.log | claude -p "what's going on here". - Give Claude a check to run. Tests, a typecheck, a lint command or a screenshot to compare against. Then ask for the command output as evidence.
- Say how big the job is. Claude reads requests conservatively. The docs say the phrase "be ambitious" helps when you want edge cases and follow-on work included.
Phrases like "think step by step" are ordinary text in Claude Code. To make Claude work harder on a tricky task, raise the effort level with /effort high.
Planning prompts (1-4)
1. Interview me before building
I want to add [feature] but haven't thought it through yet. Interview me until you could write the spec, then write it to SPEC.md. Ask about scope, edge cases, error handling and what is out of scope.
2. Plan first, no edits
Don't edit any files yet. Read [folder or files] and propose a plan for [change]: which files change, in what order, what could break, and which tests prove it works. Wait for my OK before you start.
3. Explain an unfamiliar codebase
I'm new to this repo. Explain how a request flows from [entry point, e.g. the API route] to the database and back. Name the files involved in order, with one line each on what they do. Point out anything unusual.
4. Find where a feature lives
Where is [behavior, e.g. "password reset email"] implemented? List every file involved, the function names, and any config or environment variables it depends on. Don't change anything.
Bug-fix prompts (5-8)
5. Reproduce first, then fix
Users report [symptom] when [steps]. Look at [suspected folder or file]. Write a failing test that reproduces it, run it to confirm it fails, then fix the bug and run the test again. Show me the test output before and after.
6. Debug from a log
@[path/to/error.log]
This error started after [recent change or date]. Find the root cause, not just the line that throws. Explain it in 3 sentences, then propose the smallest fix and the test that would catch it next time.
7. Fix a flaky test
The test [test name] in [file] fails about 1 time in 5. Run it 10 times and report the failures. Find what makes it nondeterministic: timing, shared state, order or network. Fix the cause, not the retry count.
8. UI bug from a screenshot
[paste screenshot]
On [page or component], the layout breaks like this at [screen width]. The expected layout matches [component or mockup]. Fix it with the smallest CSS change, then describe how you checked it at mobile and desktop widths.
Building prompts (9-12)
9. Follow an existing pattern
Build [new component or endpoint] following the pattern in [existing file]. Same structure, same error handling, same naming. No new libraries. Add tests in the same style as [existing test file] and run them.
10. Be ambitious on a feature
Build [feature] from SPEC.md. Be ambitious: empty and error states, loading states, input validation, keyboard navigation and tests for the edge cases in the spec. Run the full test suite when you're done and show me the result.
11. Keep going until checks pass
Implement [change]. After each step, run [test command] and [typecheck command]. Keep going until both pass with no new warnings. At the end, paste the final output of both commands.
12. Add a small API endpoint safely
Add a [GET/POST] endpoint at [path] that [does what]. Validate input, return clear error messages, and add tests for success, bad input and missing auth. Don't change any existing endpoint behavior.
Refactor and cleanup prompts (13-15)
13. Refactor without behavior change
Refactor [file or module] to [goal, e.g. split the 400-line function into smaller ones]. Behavior must not change. Run the existing tests before and after, and show both results. If coverage is thin, add tests first.
14. Remove dead code
Find functions, components and exports in [folder] that nothing imports or calls. List them with the evidence for each. Don't delete anything until I confirm the list.
15. Update a dependency
Upgrade [package] from [old version] to [new version]. Read its changelog for breaking changes, list the ones that affect this repo, then make the changes and run the test suite. Stop and ask if a change touches more than [number] files.
Review prompts (16-17)
16. Review the diff against the spec
Use a subagent to review the diff on this branch against SPEC.md. Check that every requirement is implemented and the listed edge cases have tests. Report gaps that affect correctness and skip style.
Anthropic's docs warn against dropping "skip style" from a review prompt. A reviewer asked to find problems always finds something, and fixing every style nit adds churn.
17. Security pass before a PR
Review the changes on this branch for security issues only: injection, missing auth checks, secrets in code or logs, unsafe file paths and unvalidated input. For each finding, give the file, the line and a concrete fix. Say "none found" if there are none.
Project setup prompts (18-20)
18. Trim your CLAUDE.md
Read CLAUDE.md. Remove every line you could work out from the code yourself. Keep only the test, typecheck and lint commands, required environment setup, and rules you can't infer. Show the removed lines so I can check them.
CLAUDE.md loads into every session. Run /init to generate a first version, then cut it down. The memory guide recommends staying under 200 lines. Put personal preferences in CLAUDE.local.md and keep that file out of git.
19. Turn a procedure into a skill
Our release process is: [steps]. Turn it into a skill at .claude/skills/release/SKILL.md with a clear description and numbered steps. Add disable-model-invocation: true so it only runs when I type /release.
20. Write a hook for a rule with no exceptions
Write a hook that blocks edits to the [folder, e.g. migrations] folder. Explain where it goes in .claude/settings.json and how to test that it works.
Use a hook only for rules that must hold every time. The docs say preferences belong in CLAUDE.md, where Claude can weigh them.
How do you keep a Claude Code session on track?
A few commands from Anthropic's docs save more time than any prompt wording:
Escstops Claude mid-action and keeps the work so far./rewind, orEsctwice on an empty prompt, rolls the code, the conversation or both back to an earlier point./clearbetween unrelated tasks, so the next task starts fresh./compactwith a focus, such as/compact keep the API changes and the test commands.Shift+Tabcycles through permission modes if you want to approve each edit.
The docs suggest a simple rule: after two failed corrections, run /clear and write a better prompt instead of a third correction.
Ready-made coding prompts in the PromptiFex library
These coding prompts are free to copy on PromptiFex and work in Claude Code:
- Deep Repo Architecture Review, a read-only review that grounds every claim in file paths and line ranges.
- Senior Developer Code Review checks bugs, performance, security and readability.
- Coding plan orchestrator splits a feature into tasks with file paths and dependencies.
- Xcode Project Setup Coach turns Markdown specs into a guided Xcode setup.
Browse more in the coding and development prompts and the debugging and troubleshooting prompts. The page on prompts for coding with AI agents shows how to keep these prompts ready for each session. The Claude prompts library covers Claude outside the terminal.
Related guides: Cursor and AI coding agent prompts cover Cursor, Codex, Antigravity and Windsurf. The best Claude prompts cover writing and research in the Claude app.
Frequently asked questions
How do I write a good prompt for Claude Code?
Name the goal or symptom, where to look and how to check the result. Include files with @, paste screenshots or logs, and give Claude a test or command to run. Ask for the command output as evidence that the work is done.
Should I tell Claude Code to think step by step?
It won't hurt, but Anthropic's docs say it is ordinary text, not a special keyword. The effort level controls how hard Claude works. Use /effort high for bugs in code you didn't write or changes that touch many files.
What should go in CLAUDE.md?
Only what Claude can't learn from the code: the exact test, typecheck and lint commands, setup steps and rules with no obvious source. Keep it short, because it loads into every session. Move long procedures into skills.
Do these prompts work in Cursor or Codex?
Most do. The task prompts are plain text and work in any coding agent. Commands like /rewind, /effort and the CLAUDE.md and skill paths are specific to Claude Code.



