- Claude Code prompts for understanding a codebase
- Claude Code prompts for planning before you build
- Claude Code prompts for fixing bugs
- Claude Code prompts for tests, refactors and clean-up
- Claude Code prompts for docs and git tasks
- How to get better results from Claude Code prompts
- Frequently asked questions
These Claude Code prompts help you understand a project, plan changes, fix bugs, write tests and handle git tasks from your terminal. Copy one, swap the [brackets] for your details, and always read the changes before accepting them. Anthropic's top tip is to give Claude a check it can run, like a test.
Claude Code lives in your terminal, reads your project files, runs commands and makes the edits itself. That's a different job from a chatbot, so the prompts that work best are different too. I've collected prompts here that I'd reach for on a real project, grouped by the job you're trying to get done.
Copy one, swap the [brackets] for your own details, and paste it in. Two ground rules before you start. Read every change Claude proposes before you accept it, and never paste passwords, API keys or other secrets into a prompt. If a task needs a secret, point Claude at the name of the setting instead. If you've never written code at all, start with my guide to using Claude Code as a complete beginner.
Claude Code prompts for understanding a codebase
Anthropic suggests asking Claude the questions you'd ask another engineer. These are the ones I'd ask on day one of any project.
Get the lay of the land
Copy this prompt
Read the top level of this project and explain in plain English what it does, how it's organised, and which folders matter most. Don't change anything yet.
Trace one feature end to end
Copy this prompt
Follow what happens when a user [does the action, for example submits the contact form]. List each file involved in order, with one line on what each one does.
Explain a confusing file
Copy this prompt
Explain @[path/to/file] as if I'm new to this language. Cover what it's for, its main functions, and anything that looks risky or unusual.
Find where something lives
Copy this prompt
Where in this project do we handle [feature, for example login or email sending]? Show me the files and the key functions, and tell me how confident you feel about each.
Check the history
Copy this prompt
Look through the git history for @[path/to/file] and summarise how it came to look the way it does. Point out any change that looks like a workaround.
Claude Code prompts for planning before you build
Anthropic's own advice is to explore first, then plan, then code, with plan mode keeping Claude read-only until you approve. Use these before anything touching more than one file.
Plan a feature in plan mode
Copy this prompt
I want to add [feature]. Which files need to change, and what's the safest order? Write a step-by-step plan and wait for my approval before editing anything.
Let Claude interview you
Copy this prompt
I want to build [brief description]. Interview me about the technical choices, edge cases and trade-offs, skipping the obvious questions. When we're done, write the result to SPEC.md.
Compare two approaches
Copy this prompt
Give me two ways to [goal]. For each, list the files touched, the risks, and what would be hardest to undo. Recommend one and say why.
Define what done looks like
Copy this prompt
Before we start on [task], write a short checklist of what must be true when it's finished, including one check you can run yourself to prove it.
Claude Code prompts for fixing bugs
Anthropic's guidance is to describe the symptom, the likely location and what fixed looks like. These prompts follow that pattern.
Fix from an error message
Copy this prompt
The build fails with this error: [paste the error, minus any secrets]. Find the root cause, fix it, and run the build again to show me it passes. Don't just hide the error.
Write a failing test first
Copy this prompt
Users report that [symptom] after [trigger]. Check [folder or file], write a test that reproduces it and fails, then fix the bug until the test passes.
Investigate without editing
Copy this prompt
Something's wrong with [feature]. Stay read-only: list your three most likely causes, which file you'd check for each, and what you'd look for.
Fix it from a screenshot
Copy this prompt
Here's a screenshot of the layout bug on [page]. Find the cause in the styles, fix it, take a fresh screenshot and compare it with the original.
Explain the fix back to me
Copy this prompt
Want AI doing the heavy lifting in your marketing?
I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.
After you fix [bug], tell me in two sentences what was wrong and why your change works, so I can recognise the same problem next time.
Claude Code prompts for tests, refactors and clean-up
Small, checkable steps keep these safe. Ask for evidence at the end of each one.
Add tests for an edge case
Copy this prompt
Write tests for @[file] covering the case where [edge case, for example the user is logged out]. Avoid mocks where you can, run them, and show me the output.
Refactor one function
Copy this prompt
Refactor [function name] in @[file] so it's easier to read, without changing what it does. Run the existing tests before and after and show both results.
Remove dead code
Copy this prompt
Find functions and files in this project that nothing uses. List them with your evidence for each, and wait for me to approve before deleting anything.
Follow an existing pattern
Copy this prompt
Add a new [component or endpoint] for [purpose]. Look at how @[example file] is built and follow the same pattern and naming exactly.
Review the diff like a sceptic
Copy this prompt
Review the changes you just made. Flag only problems that affect correctness or our requirements, such as missed cases, broken tests or edits outside the task.
Claude Code prompts for docs and git tasks
Housekeeping is where an agent that can run commands saves the most time.
Write a README for newcomers
Copy this prompt
Draft a README for this project covering what it does, how to install it, how to run it and how to run the tests. Use only what's in the code.
Document a tricky module
Copy this prompt
Add clear comments to @[file] explaining why each non-obvious section exists. Don't rewrite any logic, and show me the diff when you're finished.
Write a good commit message
Copy this prompt
Look at my staged changes and write a clear commit message: a short summary line, then a few bullets on what changed and why. Don't commit yet.
Summarise changes for a pull request
Copy this prompt
Compare this branch with main and write a pull request description covering what changed, why, how to test it, and anything reviewers should check carefully.
Undo safely
Copy this prompt
I don't like the last change. Explain what reverting it would affect, then show me the exact git command you'd run before you run it.
How to get better results from Claude Code prompts
- Give Claude a way to check its own work, such as a test, a build or a screenshot. Anthropic says this is the difference between a session you watch and one you can walk away from.
- Be specific about files, constraints and what fixed looks like. Anthropic's guidance is that precise instructions mean fewer corrections.
- Use plan mode for anything that touches several files. Skip it for tiny jobs like renaming a variable.
- Run /clear between unrelated tasks. A cluttered conversation makes mistakes more likely.
- Keep a short CLAUDE.md for rules Claude can't guess, and run /init to get a starter version.
- Treat checkpoints as an undo button, but keep using git for anything you want to keep.
If you're still deciding which tool suits you, my roundup of AI coding assistants for business compares the options, and my notes on using ChatGPT prompts to speed up coding work cover the chat-window approach.
Related guides live in the ChatGPT Prompts and Limits: 30 Guides to Fun Prompts, Photo Edits and Daily Caps. To write your own, try the free prompt generator.
Frequently asked questions
What are Claude Code prompts?
They're instructions you type into Claude Code, which runs in your terminal and can read files, run commands and edit your project. The best ones name the files, the goal and a check Claude can run.
Do I need to know how to code to use these prompts?
Not to start, but you do need to review what it changes. Ask Claude to explain each change in plain English, and stick to small tasks in a project you can restore.
Should I use plan mode every time?
No. Anthropic says plan mode is most useful when you're unsure of the approach, the change touches several files, or you don't know the code. If you can describe the change in one sentence, just ask for it.
Is it safe to paste my passwords or API keys into a prompt?
No. Keep secrets out of prompts entirely, and tell Claude which setting holds the value rather than the value itself.
What if Claude keeps getting something wrong?
Anthropic suggests that after two failed corrections you run /clear and start again with a more specific prompt that includes what you've learned.


