The short answer
The best Claude prompts for coding follow Anthropic's own guidance: paste code and errors inside XML tags, tell Claude never to speculate about code it has not opened, ask for a failing test before a fix, forbid gaming the tests and ask for the commands and output that prove the change works. The 17 prompts here cover debugging, planning, review, refactoring, tests, docs and Claude Code, which is included from the Pro plan up and not on the free plan.
Why Claude for coding, and how these prompts use it
Claude, the AI assistant made by Anthropic, is a strong choice when the work needs careful reading of real code: finding the cause of a bug, reviewing a change or explaining a codebase nobody documented. The 17 Claude prompts for coding on this page work in the Claude app on any plan and in Claude Code, Anthropic's coding agent that runs in your terminal and editor and is included on Pro, Max, Ultra, Team and Enterprise (not on the free plan, per Anthropic's pricing page in November 2026).
Every prompt follows Anthropic's published prompting advice for its current models, including Claude Opus 5.5, released on 22 September 2026. Four ideas from that guidance shape them. First, put pasted code, logs and specs inside XML tags such as <code> and <error>, so Claude can tell your material from your instructions. Second, tell Claude to read code before answering: Anthropic's guide suggests the line "Never speculate about code you have not opened." Third, protect your tests: the guide tells Claude that tests "are there to verify correctness, not to define the solution", and several prompts here repeat that. Fourth, say whether you want changes or suggestions. Anthropic notes that "can you suggest some changes" will sometimes get suggestions rather than changes, while "change this function" gets the change made.
On models: the free plan uses Claude Sonnet 5.5 and Claude Haiku 5.5, which handle every prompt in the app with tighter limits that reset every five hours and weekly. Paid plans add Claude Opus 5.5, and Claude Fable 5.2 through usage credits on Pro, which are the better pick for large or tangled codebases. See our Claude guide for the full plan breakdown.
Claude prompts for debugging
Debugging is where a precise prompt saves the most time. The first prompt forces Claude to read before it guesses, and to ask for the file it needs rather than inventing one. The second follows the pattern Anthropic's Claude Code best practices recommend: name the symptom, ask for a failing test that reproduces it, then the fix. A failing test turns "I think it is fixed" into something you can check. The stack trace and error log prompts are for the moments when you are staring at 200 lines of red output and need an order to work in.
The habit that matters most: always paste the exact error and the input that triggers it. "It doesn't work" gets a generic answer; the real message and a reproducible input get a specific one.
Claude prompts for code review and security
Claude reads a diff more patiently than a tired reviewer at 6 p.m., and it is good at spotting the concrete case where a change breaks. The review prompt asks for a failure case for every issue, which filters out vague comments, and it tells Claude to skip what a linter already catches. The security prompt asks for an example exploit input for each finding and gives Claude explicit permission to say it found nothing, which cuts down on invented problems.
If your team is on a Claude Team or Enterprise plan and hosts code on GitHub, these prompts pair well with Claude Ship, launched on 23 November 2026, whose Code Review agent can review pull requests automatically (it skips drafts and pull requests from forks). See how to set up Claude Ship for the steps and costs.
Treat Claude's review as a second pair of eyes, not a sign-off. A human who knows the system should still approve anything that touches authentication, payments or customer data.
Claude prompts for writing and changing code
The refactor prompt borrows Anthropic's own wording against over-engineering: only make changes that are directly requested or clearly necessary. Anthropic notes that some Claude models tend to over-engineer without it, adding extra files and abstractions nobody asked for. The feature prompt asks for a five-line plan before any code, so you can catch a wrong approach in seconds instead of after 300 lines.
The interview prompt follows a tip from Anthropic's Claude Code best practices: let Claude interview you and write a SPEC.md, then start a fresh session to build from it. It works because most bad code from AI comes from a vague request, not a weak model.
Claude prompts for tests
Ask Claude for tests and it will happily write tests that pass. The prompts here ask for tests that check behaviour, cover edge cases and expose real bugs, and they tell Claude to report a bug rather than write a test that matches it. Anthropic's guidance for long coding tasks is blunt on the same point: it is unacceptable to remove or edit tests, because that could lead to missing or buggy functionality.
Claude prompts for understanding code and writing docs
The codebase tour prompt is the one to use on your first day in a new repository or before touching a legacy system. It asks Claude to mark anything it is inferring, which keeps guesses separate from facts. The documentation prompt writes for a named audience and only from what the code does, so you do not ship docs that describe a feature that never existed.
Prompts for Claude Code: memory and proof
Two prompts are built for Claude Code. The CLAUDE.md prompt writes the project memory file that Claude Code loads at the start of every session. Anthropic's best practices say to keep it short and include only what Claude cannot work out from the code: the commands to build and test, misleading code, undocumented decisions and corrections you keep repeating. The /init command generates a starting version that you then cut down; the prompt here writes a short one directly. The guide calls the command that runs your tests "the single most useful line" in that file.
The proof prompt fixes the most common frustration with coding agents: being told everything works when nothing was run. Anthropic's best practices recommend asking for evidence, meaning the command and its output, rather than accepting "All tests pass".
Prompts for planning a feature and tracing a request
Coding agents write code quickly, so the expensive mistakes are now in the plan. Three prompts handle that. Trace a request end to end follows one real user action through the system, from the route or component to the database and back, and asks where an error could be swallowed silently. That is how most hard bugs are found, and it gives you file paths you can check. Plan a feature before writing code asks for a numbered plan with files to change, data changes, risks and tests, lets Claude ask up to three questions, and then tells it to wait for your approval. Implement one step of the plan keeps each change small enough to review, runs your test command and summarises the diff in five bullets, including anything Claude was unsure about.
Used together they give a simple loop: plan, approve, build one step, check the test output, repeat. If the diff for a step is longer than you would read carefully, the step was too big, so ask Claude to split it.
Using these prompts in GitHub Copilot and Cursor
Nothing in these prompts is locked to Claude. The XML tags, the guard lines and the request for proof help any coding agent, and two editor features make them work even better.
- GitHub Copilot. Copilot Free includes 2,000 inline completions a month plus agent mode and MCP in the editor, with limited chat and agent usage. Paid plans add a monthly allowance of GitHub AI Credits for chat and agent work, while code completions stay unlimited. Paste a prompt into Copilot Chat in agent mode and it can read files and run your test command itself. See our GitHub Copilot guide.
- Cursor. Press Shift+Tab in the chat input to switch to Plan Mode: the agent researches the code, asks clarifying questions and writes an editable plan before coding, which does the job of the planning prompt for you. Cursor reads project rules from .mdc files in the .cursor/rules folder and also supports an AGENTS.md file, so the CLAUDE.md prompt works there too if you ask for AGENTS.md instead. See our Cursor guide and Cursor vs GitHub Copilot.
Check the training settings before you point any agent at company code. In GitHub Copilot, interaction data on Free, Pro, Pro+ and Max can be used for training unless you open your profile picture, then Copilot settings, and set Allow GitHub to use my data for AI model training to Disabled; Business and Enterprise data is not used for training. In Cursor, turn on Privacy Mode in settings; it is on by default for Enterprise.
How to adapt these prompts
- Fill every placeholder. Language, framework and test framework change the answer a lot. "pytest on Python 3.13 with Django" beats "Python".
- Paste less, but the right things. The function, its caller and the failing test beat an entire 3,000-line file. In Claude Code, mention files with @ instead of pasting.
- Keep the guard lines. "Do not change anything else", "work for all valid inputs" and "mark what you infer" are what stop the usual AI coding mistakes.
- Start fresh when it goes wrong. Anthropic's advice for Claude Code is that after two failed corrections you should clear the session and write a better prompt rather than a third correction.
- Save the ones you reuse. Put your stack and standards in a Claude Project or a CLAUDE.md file so you stop retyping them.
Two old habits to drop: Anthropic now lists adding "IMPORTANT" in capitals and phrases like "think harder" as outdated for Claude Code. Use the /effort setting instead when a task needs more thinking.
Which tool works best for these prompts
Claude in the browser or desktop app is the right place for one-off questions: a stack trace, a review of a pasted diff, an explanation. Claude Code is better as soon as the work spans several files, because it reads the repository itself, runs your tests and shows you the output. If you live inside an editor and want completions as you type, compare it with Cursor and GitHub Copilot in our best AI for coding guide. All 17 prompts also work in ChatGPT and Gemini with small changes, and in GitHub Copilot and Cursor as described above.
One privacy point before you paste company code: on Free, Pro, Max and Ultra, Anthropic can use your chats and coding sessions for model training unless you turn off Help Improve our AI models in Settings > Privacy. Team and Enterprise are not used for training by default. Check your employer's AI policy before pasting proprietary code into a personal account.
Prompts to copy
Find a bug from a symptom
<code> [paste the function or file] </code> <error> [paste the error message or describe what goes wrong, with the input that triggers it] </error> Find the cause of this bug. Read the code above before you answer and do not guess about code I have not shown you; if you need another file, tell me which one. Explain the cause in two or three sentences, then show the smallest change that fixes it. Do not change anything else.
You get: The real cause in plain words and a minimal fix, or a clear request for the missing file
Write the failing test first
<code> [paste the code with the bug] </code> The bug: [describe the symptom and the input that triggers it]. Write a failing test in [test framework, e.g. pytest or Jest] that reproduces this bug. Then fix the code so the test passes. The fix must work for all valid inputs, not just this test case. If you think the test or the requirement is wrong, tell me instead of working around it.
You get: A test that proves the bug exists and a fix that makes it pass without gaming the test
Explain a stack trace
<trace> [paste the full stack trace] </trace> <code> [paste the files named in the trace] </code> Walk me through this stack trace from the bottom up in plain English. Point to the line where things first go wrong and say why. Then list the two most likely fixes, which one you would choose and why.
You get: A readable explanation of the failure point and a ranked choice of fixes
Review a pull request like a senior engineer
<diff> [paste the diff or the changed files] </diff> You are a senior [language] engineer reviewing this change before it merges. Look for correctness bugs first, then security problems, then missing tests, then readability. For each issue give the file and line, what goes wrong in a concrete case, and a suggested change. Skip style nitpicks a linter would catch. End with: merge, merge after fixes, or do not merge.
You get: A review ranked by severity, with concrete failure cases rather than vague comments
Check a change for security problems
<code> [paste the code that handles user input, auth, files or database queries] </code> Check this code for security problems: injection, broken access control, secrets in code, unsafe file handling and missing input validation. For each problem, show an example input that would exploit it and the fixed code. If you find nothing serious, say so plainly instead of inventing issues.
You get: A focused security pass with an example exploit for each real issue
Refactor without changing behaviour
<code> [paste the code] </code> Refactor this code to make it easier to read and change. The behaviour must stay exactly the same: same inputs, same outputs, same errors. Avoid over-engineering: no new abstractions unless they remove real duplication. Show the new code, then list each change with one line on why it helps.
You get: Cleaner code with a short changelog, and no surprise behaviour changes
Write unit tests for existing code
<code> [paste the function or module] </code> Write unit tests for this code in [test framework]. Cover the normal cases, the edge cases (empty input, very large input, wrong types, [any domain edge case]) and the error paths. Name each test after the behaviour it checks. If the code has a bug that a test exposes, tell me rather than writing the test to match the bug.
You get: A readable test suite that covers edge cases and flags real bugs
Write a feature from a spec
<spec> [paste the user story, ticket or acceptance criteria] </spec> <context> [paste the files the feature touches, or describe the stack: language, framework, database] </context> Implement this feature. Before writing code, list the files you will change and the approach in five lines or fewer. Then write the code. Only make changes that the spec asks for or that are clearly necessary. Finish by telling me how to check that it works.
You get: A short plan, the implementation and a way to verify it
Plan a feature before writing code
I want to add [feature] so that [user goal]. Constraints: [framework and version, libraries allowed, must not change public API or schema]. Before writing any code, give me a numbered plan: files to create or change, the approach for each, data or migration changes, risks, and the tests you will add. Ask me up to three questions if anything is unclear, then wait for my approval.
You get: An approved plan before any code is written
Implement one step of the plan
Implement step [number] of the plan we agreed, and nothing else. Follow the existing patterns in [similar file]. When you are done, run [test command], show me the command and its output, and summarise the diff in five bullets including anything you were unsure about.
You get: A small, reviewable change with the test output to prove it
Interview me before building
I want to build [describe the feature or tool in one or two sentences]. Before writing any code, interview me. Ask one question at a time about the users, the inputs and outputs, the edge cases, the constraints and what done looks like. When you have enough, write a SPEC.md I can review and give to a fresh session to build from.
You get: A clear spec built from your answers, ready for a clean build session
Trace a request end to end
<files> [paste the route, component and handler files, or in Claude Code name them with @] </files> Trace what happens when a user [action, such as submits the checkout form]. Start from [route, component or endpoint] and list each function, file and external call in order, including validation, database queries and error handling. Read the files before you answer and say which steps you are inferring. Point out any place where an error could be swallowed silently.
You get: The real path of one user action through the code, with file names you can check
Explain an unfamiliar codebase
<files> [paste the main files, or in Claude Code just point it at the repository] </files> I am new to this codebase. Explain what it does, how a request flows through it from entry point to response, and where the main pieces live. Then list the five files I should read first and why. Only describe what you can see in the code; mark anything you are inferring.
You get: A guided tour of the code with a reading list, and inferences clearly marked
Write a short CLAUDE.md
Look at this repository and write a CLAUDE.md for it. Keep it under 60 lines. Include only what you could not work out by reading the code: the exact commands to build, test and lint, anything misleading in the code, decisions that are not written down, and the corrections I give you most often: [list two or three]. Do not describe the folder layout or architecture.
You get: A short project memory file that saves you repeating yourself every session
Turn an error log into a fix plan
<log> [paste the error log or the failing CI output] </log> Group these errors by root cause. For each group, say which errors belong to it, the likely cause, and the first thing to check. Order the groups so that fixing the first one is most likely to clear the others. Do not suggest fixes for code you have not seen; ask for the file instead.
You get: A short, ordered fix plan instead of a wall of red text
Write documentation from code
<code> [paste the module, API or function] </code> Write documentation for [audience, e.g. a new team member or an API customer]. Start with one paragraph on what it does and when to use it. Then give a working example for the most common use, the parameters and return values in a table, and the errors it can raise. Use only what the code actually does.
You get: Docs a newcomer can follow, with a working example and accurate parameters
Ask for proof that it works
You said the change is done. Show me the evidence: the exact commands you ran to check it and their output. If you did not run the tests or build, run them now and show the results. If anything failed, say so and fix it before telling me it works.
You get: Real test and build output instead of a confident 'all tests pass'
Free on Yuzoki Learn