Launch price: $49 one-time for all 38 specialists. Get it →
Claude prompts
18 Claude Code Prompts for Planning, Debugging and Code Review
Plan mode, codebase maps, bug fixes, pre-push and PR reviews, CLAUDE.md and session handoffs.
Updated October 202618 promptsFree to copy, no signup
These prompts are written to run inside Claude Code in a real repository, where Claude can read files, run commands and edit code. Because it can act, the best prompts are less about wording and more about process: explore before answering, plan before editing, and prove the result with tests and commands before calling it done.
How to use these prompts
Start each session in the repository root so Claude Code can read your files and CLAUDE.md.
Replace every [PLACEHOLDER] with specifics, since concrete goals and done criteria matter more than any phrasing.
Use plan mode or the plan prompt for anything bigger than a one-line change, and approve the plan before edits start.
Save the prompts you reuse as custom slash commands so they become one-word habits.
1. Claude Code prompt to understand a new codebase
Claude Code
Use it when: Run this first in a repo you don't know to get an architecture map, entry points, run commands and risky areas before you change anything.
Prompt 01
I'm new to this repository and need a working mental model of it before I change anything. Explore the codebase and explain it to me.
Read the actual files rather than inferring from names: the README, package or build manifests, config, entry points, and a representative sample of the core modules and tests. If something is still unclear after reading, say so instead of filling the gap.
Give me:
1. What this project does, in two or three sentences.
2. Stack: language, framework, package manager, database, notable libraries.
3. How to run it: install, dev server, tests, build. Quote the exact commands from the repo.
4. Architecture map: the 5 to 10 directories that matter, one line each, and how a typical request or job flows through them from entry point to storage.
5. Conventions to follow: naming, error handling, where tests live, how config and secrets are loaded. Point to one exemplary file for each.
6. Risky or fragile areas: complex code, missing tests, TODOs, surprising coupling.
7. Open questions you couldn't answer from the code.
This is read-only: leave every file unchanged. Keep it under 600 words and cite a file path for every claim.
The area I'll be working on: [AREA OR FEATURE, OR "GENERAL OVERVIEW"]
Why it works: Making Claude read the manifests, entry points and real modules before explaining stops it from describing a typical project of that stack instead of yours. Requiring a file path for every claim lets you check any statement in seconds, and the read-only rule means exploring can't quietly change anything.
Tip: Save the useful parts of the answer into CLAUDE.md so future sessions start with this map instead of exploring again.
2. Claude Code plan mode prompt
Claude Code
Use it when: Use before any non-trivial change so Claude explores the code and proposes a file-by-file plan that you approve before it writes anything.
Prompt 02
I want to [DESCRIBE THE CHANGE]. Plan it before writing any code.
1. Explore first. Open the files involved and trace how the relevant code works today. Base the plan only on code you have actually opened.
2. Restate the goal in one sentence and list your assumptions. If a requirement is ambiguous, ask me up to 3 questions now rather than picking an interpretation silently.
3. Propose a numbered, step-by-step plan. For each step give: the files to create or edit, what changes in each, and how we'll verify that step (a test, a command, or a manual check).
4. List what you will deliberately leave unchanged, and the risks: migrations, breaking API changes, performance, security.
5. If there's more than one reasonable approach, show the top two with their trade-offs and recommend one.
Aim for the smallest change that fully solves the goal. Stop after presenting the plan and wait for my approval before editing any file.
Why it works: Separating exploration and planning from editing catches wrong assumptions while they are still cheap to fix, before they turn into a large diff. Asking for files, changes and a verification method per step turns the plan into something you can actually approve or reject line by line.
Tip: Press Shift+Tab to switch Claude Code into plan mode first, so it can read and plan but can't edit files until you approve.
3. Claude Code prompt to implement a feature
Claude Code
Use it when: Hand Claude Code a feature with explicit done criteria so it builds, tests and verifies it instead of stopping at "this should work".
Prompt 03
<task>
Implement [FEATURE] so that [WHO] can [OUTCOME].
</task>
<done_when>
- [OBSERVABLE CRITERION, E.G. POST /INVITES RETURNS 201 AND SENDS EXACTLY ONE EMAIL]
- [SECOND CRITERION]
- [AN ERROR OR EMPTY CASE, E.G. INVITING AN EXISTING MEMBER RETURNS 409]
</done_when>
<constraints>
- Follow this repo's existing patterns. Before writing, find the closest existing feature and model yours on it.
- Keep scope to the done criteria. If you spot unrelated problems, list them at the end and leave them alone.
- Ask me before adding any new dependency.
</constraints>
Work in this order: read the relevant code, write or update a test for each done criterion, implement, then run the test suite, linter and type checker and fix anything you broke.
When finished, report: files changed with a one-line reason each, the commands you ran and their results, any done criterion you couldn't meet and why, and follow-ups you noticed. Call it done only when every check you ran passes.
Why it works: Observable done criteria give Claude a finish line it can test against, so it stops when the behaviour is proven rather than when the code looks plausible. Pointing it at the closest existing feature makes new code follow your patterns, and the scope rule keeps unrelated edits out of the diff.
Tip: Write each done criterion so a test or a command can prove it; "works well" gives Claude nothing to verify against.
4. Minimal code prompt to stop over-engineering
Claude Code
Use it when: Use when Claude keeps adding abstractions, files and dependencies you didn't ask for, and you want the smallest change that solves the task.
Prompt 04
Before writing any code for this task, walk down this ladder and stop at the first rung that works:
1. Does this need to exist at all? Could a config change, deleting code, or doing nothing solve it?
2. Does the language's standard library already do it?
3. Does the framework or platform have a built-in feature for it?
4. Does a dependency we already have handle it? Check the manifest before proposing anything new.
5. Can it be one line, or a few lines inside an existing function?
6. Only then write new code: as little as possible, following the patterns already in this file.
Before showing the change, tell me in one or two sentences which rung you stopped at and why.
For the change itself: add new files, classes, interfaces or config options only when the task can't be done without them. Build for today's requirement, not imagined future ones. Leave neighbouring code as it is. Small and boring beats clever, because every extra line is something I have to review and maintain.
The task: [DESCRIBE THE TASK]
Why it works: The ladder makes Claude check cheaper options, such as the standard library or an existing dependency, before it writes anything new, which is where most over-engineering is avoided. Having it name the rung it stopped at forces a justification you can disagree with before reviewing any code.
Tip: Put the ladder in CLAUDE.md so it applies to every task, and use this prompt when you want Claude to justify a specific change.
5. Claude Code debugging prompt for stack traces
Claude Code
Use it when: Paste an error and get a reproduced, root-caused, test-covered fix instead of a patch that hides the symptom.
Prompt 05
Fix this bug.
<error>
[PASTE THE ERROR MESSAGE AND FULL STACK TRACE]
</error>
<context>
How to trigger it: [STEPS, REQUEST OR COMMAND]
Expected: [WHAT SHOULD HAPPEN]
When it started, if known: [E.G. AFTER THE LAST DEPLOY, OR UNKNOWN]
</context>
Work through it in this order:
1. Reproduce it. Run the failing path, or write the smallest script or test that triggers it. If you can't reproduce it, stop and tell me what you tried.
2. Find the root cause. Trace back from the top stack frame to where the bad value or state was first introduced, and explain why it happens. The line that crashes is often not the line that's wrong.
3. Write a test that fails because of this bug, and show me it fails for the right reason.
4. Make the smallest fix that makes that test pass. Keep unrelated cleanup out of this change.
5. Run the full test suite to confirm nothing else broke.
6. Search for the same pattern elsewhere in the codebase and list any other places it could occur, without fixing them yet.
Finish with: the root cause in one sentence, the fix, and the test results.
Why it works: Requiring a reproduction and a failing test first proves the bug is understood before anything changes, so the fix targets the cause rather than the line that crashed. The smallest-fix rule keeps the change reviewable, and the final search catches the same mistake elsewhere in the codebase.
Tip: Paste the whole stack trace, not just the last line; the frames above the crash usually point to the real cause.
6. Pre-push code review prompt
Claude Code
Use it when: Run before every git push to catch behaviour changes, broken contracts, edge cases and missing tests in your own diff.
Prompt 06
Review my changes before I push. Look at the commits not yet on the upstream branch plus any uncommitted work (git diff @{upstream} and git status), and read the surrounding code for every changed hunk, not just the changed lines.
Check for:
1. Behaviour changes: anything that now works differently for users or callers, intended or not.
2. Contract breaks: changed function signatures, API request or response shapes, database schemas, events, config keys, CLI flags. Find the callers and say whether they break.
3. Edge cases: empty, null, zero, very large, duplicate, concurrent, unicode, time zones, permission denied.
4. Bugs: wrong conditions, off-by-one, unhandled errors, resource leaks, race conditions.
5. Data and state: migrations, caches, persisted data, and whether existing records still work.
6. Test gaps: changed behaviour with no test that would fail if it regressed.
7. Leftovers: debug logging, commented-out code, secrets, unrelated changes.
Rank each finding as Blocker, Should fix, or Nit, with file:line, a concrete scenario where it goes wrong, and the suggested fix. If you're unsure whether something is a bug, say what would confirm it. Report only; I'll decide what to change. If nothing blocks the push, say so plainly.
Why it works: Telling Claude to read the code around each changed hunk lets it spot broken callers and contract changes that a diff alone hides. The fixed checklist makes it look at categories people skip under time pressure, and severity ranking with a concrete scenario keeps the output actionable instead of a wall of nits.
Tip: Save it as a custom slash command in .claude/commands/ so the review becomes a one-word habit before every push.
7. Claude Code prompt for PR review
Claude Code
Use it when: Review a whole branch against main like a careful senior reviewer, with a verdict and severity-ranked findings tied to what the PR is meant to do.
Prompt 07
Review the pull request on this branch against main.
PR description: [PASTE IT, OR "NONE"]
First understand the intent: run git log main..HEAD and git diff main...HEAD, read the description above, and summarise in two sentences what the PR is trying to do. Flag it if the code does more or less than that.
Then review for:
- Correctness: does it do what it claims, including error and edge cases?
- Design fit: does it follow the existing architecture, or add a second way of doing something the codebase already does?
- Compatibility: public APIs, schemas, migrations, feature flags, and existing data and clients.
- Security: input validation, an authorisation check on every new path, secrets, injection.
- Tests: do they exercise real behaviour, and would they fail if the feature broke?
- Maintainability: naming and structure a teammate can work with.
Open any file you need for context. Output:
1. Verdict: approve, approve with changes, or request changes, with one sentence why.
2. Findings ranked Blocker, Major, Minor, Nit, each with file:line, the problem and a suggested fix.
3. Questions for the author.
4. What's done well, briefly.
Report only; leave the code and the PR untouched.
Why it works: Summarising the PR's intent first gives the review a yardstick, so Claude can flag code that does more or less than the change claims. A verdict plus findings ranked from Blocker to Nit, each with file:line and a fix, reads like a real reviewer's report rather than general commentary.
Tip: If the PR is on GitHub, have Claude read it with gh pr view and gh pr diff so it sees the description and existing review comments too.
8. Claude Code prompt to write meaningful tests
Claude Code
Use it when: Get tests that check real behaviour and would catch a regression, instead of tests bent to pass against whatever the code does today.
Prompt 08
Write tests for [FILE, FUNCTION OR FEATURE].
1. Read the code under test and its callers so you understand what it's supposed to do, not just what it currently does. Find the existing test setup and match its framework, file naming, fixtures and style.
2. Before writing, list the behaviours you plan to test: main success paths, boundaries, invalid input, error handling, and state changes or side effects. Include cases you suspect will fail.
3. Write the tests. One behaviour per test, with a name that states it, e.g. "returns 404 when the invoice belongs to another account". Assert on outputs and observable effects rather than private implementation details. Mock only true external boundaries such as network, time and randomness.
4. Run them.
If a test fails because the code is wrong, keep the test honest: leave the expected value as the correct behaviour, and leave the code without special cases added just to pass. Stop and report it as a likely bug with the input, expected result and actual result. A test that passes because it was written to match the code proves nothing.
Report the behaviours covered, any bugs found, and gaps you deliberately left.
Why it works: Listing behaviours before writing and asserting on observable effects produces tests that fail when the feature breaks, not when internals are renamed. The explicit rule against bending a test or the code to make it pass stops the most common failure of generated tests: confirming bugs instead of catching them.
Tip: Sanity check the suite by breaking one line of the code on purpose and confirming at least one test goes red.
9. Safe refactoring prompt for Claude Code
Claude Code
Use it when: Restructure code in small, verified steps so behaviour stays identical and any step can be rolled back.
Prompt 09
I want to refactor [CODE OR AREA] so that [GOAL, E.G. THE 900-LINE ORDER SERVICE IS SPLIT BY RESPONSIBILITY]. Behaviour must stay exactly the same.
1. Read the code and everything that calls it, and tell me how well it's covered by tests today. If coverage is thin on the parts you'll touch, first write characterisation tests that pin down current behaviour, quirks included, and get them passing.
2. Propose a sequence of small refactoring steps (rename, extract function, move, inline, and so on). Each step must leave the code building and all tests passing. Show me the list and wait for my OK.
3. Then do one step at a time: make the change, run the tests, type checker and linter, and continue only when everything is green. If a step goes red, revert that step rather than patching forward.
4. Keep behaviour, public interfaces and bugs exactly as they are. If you find a bug, note it and leave it, because mixing fixes into a refactor makes both harder to review.
At the end, summarise each step, the before and after structure, and any bugs or follow-ups you noted.
Why it works: Characterisation tests pin down current behaviour before anything moves, so 'behaviour unchanged' becomes something the test suite checks rather than a hope. Small steps that must each go green, with revert instead of patch forward, mean a mistake costs one step rather than the whole refactor.
Tip: Ask Claude to commit after each green step, so a single bad step can be undone with git instead of unpicked by hand.
10. Security review prompt for your codebase
Claude Code
Use it when: Get an evidence-based security review of your repo or latest changes, ranked by real exploitability rather than a generic checklist.
Prompt 10
Do a security review of [THE WHOLE REPO / THE CURRENT DIFF AGAINST MAIN / THIS DIRECTORY].
Start by mapping the attack surface: entry points (HTTP routes, webhooks, CLI arguments, file uploads, queue consumers), where user-controlled data comes in, where it's stored, and where authentication is enforced. Then trace untrusted input from each entry point to where it's used.
Look for:
- Broken access control: missing auth checks, IDs from the request used without checking ownership, data leaking between tenants.
- Injection: SQL, shell commands, templates, path traversal, SSRF, unsafe deserialisation, XSS.
- Secrets in code, logs, client-side bundles or config committed to the repo.
- Auth and sessions: password storage, token expiry, CSRF, cookie flags, rate limits on login and password reset.
- Known-vulnerable dependencies, using the project's audit tool if there is one.
- Sensitive data exposed in logs or error responses.
Report only what you can tie to specific code. For each finding: severity (Critical, High, Medium, Low), file:line, a concrete attack scenario, and the fix. Keep confirmed issues separate from things worth checking that you couldn't verify. This is read-only, so leave files unchanged. Finish with the three fixes to make first.
Why it works: Mapping entry points and tracing untrusted input to where it is used focuses the review on paths an attacker can actually reach. Requiring a specific file:line and an attack scenario for each finding filters out generic checklist warnings, and separating confirmed issues from unverified ones tells you where to spend time.
Tip: Run it on every PR that touches auth, payments, file uploads or permissions, which is where most real vulnerabilities land.
11. Prompt to create or update CLAUDE.md
Claude Code
Use it when: Generate a short, accurate CLAUDE.md from the real repo so every Claude Code session starts knowing your commands, conventions and gotchas.
Prompt 11
Create a CLAUDE.md for this repository, or improve the existing one. It's loaded into every session, so every line costs context: keep it under about 100 lines and include only what can't easily be worked out from the code.
Investigate first: read the manifests, scripts, CI config, linter and formatter config, README, and a few representative source and test files. Check that each command exists before listing it.
Include:
1. A one-paragraph project summary.
2. Commands: install, dev, test, run a single test, lint, typecheck, build, migrate. Exact commands, with any required flags or environment variables.
3. Conventions the tooling doesn't enforce: naming, error handling, where tests live, how config and secrets are read. Point to one exemplary file for each.
4. Architecture: the directories that matter, one line each, and the boundaries between them.
5. Gotchas: what a newcomer would get wrong, fragile areas, and things that need discussion before they change.
Move longer detail (API conventions, deployment, design system) into separate docs and reference them with @path/to/file imports rather than inlining it. Write each rule as a direct instruction, with a short reason where the reason isn't obvious.
If a CLAUDE.md already exists, show me what you'd change and why before writing, and remove anything stale or contradicted by the code.
Why it works: Because CLAUDE.md is loaded into every session, the line budget and the 'only what can't be inferred' rule keep it from eating context with noise. Verifying each command against the repo before listing it means the file guides future sessions correctly, and @imports keep long detail available without loading it every time.
Tip: Re-run it after big changes; a CLAUDE.md that lists a command that no longer exists sends every session down the wrong path.
12. MISTAKES.md prompt so Claude learns from errors
Claude Code
Use it when: Set up a lessons log that Claude reads every session, so a mistake you've corrected once doesn't come back.
Prompt 12
Set up a lessons log for this repo so mistakes from our sessions don't repeat.
1. Create MISTAKES.md in the repo root with a one-line note on its purpose, then entries in this format:
## [YYYY-MM-DD] Short title of the mistake
- What happened: one or two concrete sentences.
- Root cause: why it happened, e.g. assumed the function had no side effects, missed the existing helper.
- Prevention: one imperative rule that would have avoided it, written so it applies next time.
2. Add this single line to CLAUDE.md: "Before starting a task, read MISTAKES.md and follow its prevention rules. When I correct you, or you discover an error you made, add an entry."
3. Add the first entries now: [DESCRIBE WHAT WENT WRONG, OR "REVIEW THIS SESSION AND ADD ANY REAL MISTAKES"].
Keep each entry under 60 words. If a new mistake repeats an existing rule, sharpen that entry instead of adding a duplicate. When a prevention rule has become a permanent project convention, suggest moving it into CLAUDE.md and deleting the entry, so the log stays short enough to actually be read.
Why it works: The fixed format of what happened, root cause and prevention turns each correction into a reusable rule rather than a one-off apology. The single line in CLAUDE.md makes Claude read the log at the start of every session, and the dedupe and pruning rules keep it short enough to be followed.
Tip: Prune it every few weeks; twenty sharp rules get followed, two hundred get skimmed.
13. Commit message prompt from staged changes
Claude Code
Use it when: Turn your staged diff into a clear Conventional Commits message that explains why the change was made, not just what changed.
Prompt 13
Write a commit message for my staged changes. Run git diff --staged and read all of it, plus surrounding code if you need context.
Use the Conventional Commits format:
type(optional scope): summary
body
footer
- type: feat, fix, refactor, perf, test, docs, build, ci, chore or style. Pick the one that matches the main intent.
- summary: imperative mood ("add", not "added"), under 72 characters, no full stop, specific enough to find in git log a year from now.
- body: wrap at 72 characters. Explain why the change was made and how behaviour changes; the diff already shows the how. Mention anything a reviewer could miss, such as migrations, config changes or removed features.
- footer: if a public API or contract breaks, add "BREAKING CHANGE:" followed by what callers must do. Reference [ISSUE OR TICKET ID, IF ANY].
Extra context on why: [OPTIONAL: THE BUG REPORT, REQUEST OR INCIDENT BEHIND THIS CHANGE]
If the staged changes do two unrelated things, tell me and suggest how to split them into separate commits instead. Show the message and wait for my confirmation before committing.
Why it works: Making Claude read the full staged diff ties the message to what actually changed, and asking the body to explain why adds the one thing the diff can't show. The rule to flag unrelated changes and suggest a split keeps history clean, and waiting for confirmation keeps you in control of the commit.
Tip: Fill in the optional context line; the reason for a change is rarely in the code, and it's what future you will need from git log.
14. Session handoff prompt for a new chat
Claude Code
Use it when: Use before a session runs out of context to summarize the chat for a new chat, so the next session continues exactly where you left off.
Prompt 14
I'm going to continue this work in a fresh session that has none of this context. Write a handoff document that lets it pick up exactly where we are.
Check the real state rather than relying on memory: look at git status and git diff, and re-run the tests so the status you report is current.
Use these sections:
1. Goal: what we're trying to achieve overall, in two sentences.
2. Done: what's finished, and how it was verified.
3. In progress: what's partly done and its exact state.
4. Decisions: choices we made and why, including approaches we tried and rejected, so they don't get retried.
5. Open issues: known bugs, failing tests and unanswered questions, with error messages quoted exactly.
6. Next steps: an ordered list, the first one specific enough to start on immediately.
7. Files touched: paths, with a few words on what changed in each.
8. Commands: how to run, test and reproduce anything relevant.
Be concrete: file paths, function names, exact errors. Leave out the story of how we got here. Save it to [HANDOFF.md OR ANOTHER PATH] and show me the content. I'll start the next session with: "Read [HANDOFF.md] and continue from Next steps."
Why it works: Checking git status and re-running tests makes the handoff reflect the real state rather than what Claude remembers, which drifts in long sessions. Recording rejected approaches and exact error text stops the next session from repeating dead ends, and a concrete first next step lets it start immediately.
Tip: Ask for the handoff while there's still room in the context; once a session starts compacting, the details you need most are the first to blur.
15. Prompt to stop Claude guessing about code
Claude Code
Use it when: Get answers about your codebase grounded in files Claude has actually opened, with file:line evidence and an honest "I don't know" where the code is silent.
Prompt 15
I have a question about this codebase: [YOUR QUESTION, E.G. WHAT HAPPENS TO A USER'S DATA WHEN THEY DELETE THEIR ACCOUNT?]
Answer only from code you have opened in this session. Before answering:
1. Search for the relevant symbols, routes, config and tests, and open the files. Follow calls across files to the end of the path, including background jobs, event handlers, scheduled tasks and database triggers.
2. If the answer depends on runtime config, environment variables or external services you can't see, say so explicitly.
Then answer in this format:
- Short answer: two or three sentences.
- Evidence: the path through the code as a numbered list, each step with file:line and a short quote of the relevant line.
- Inferred: anything you concluded without reading it directly, labelled as such.
- Not found: what you looked for and couldn't find, and where you looked.
"I don't know" and "the code doesn't show this" are good answers when they're true. I'd much rather see a gap than get a confident answer built on a guess, because I'm going to act on what you tell me.
Why it works: Restricting answers to code opened in this session, with file:line quotes, removes the room for plausible but invented explanations. Explicitly welcoming 'I don't know' and asking for separate Inferred and Not found sections makes gaps visible instead of papered over.
Tip: Add the line "Never speculate about code you have not opened" to CLAUDE.md so this standard applies to every question, not just this one.
16. Prompt to upgrade a dependency safely
Claude Code
Use it when: Upgrade a library or framework with the breaking changes mapped up front, a test baseline, and a rollback path.
Prompt 16
Upgrade [PACKAGE OR FRAMEWORK] from [CURRENT VERSION] to [TARGET VERSION].
1. Confirm the installed version from the lockfile and find everywhere it's used: imports, config, plugins, and other dependencies that depend on it or pin it.
2. Read the official changelog, release notes and migration guide for every major version between current and target. If you can't access them, tell me and I'll paste them in; breaking changes need a source, not memory.
3. Before changing anything, give me an impact report: each breaking or deprecated change that affects our code, the files it touches, and any peer dependency conflicts. Recommend going straight to the target or stepping through intermediate versions.
4. After I approve: run the test suite to record a baseline, then upgrade, apply the code changes, update the lockfile with the project's package manager, and run tests, type checks, lint and the build.
5. Compare against the baseline. Treat any new failure as caused by the upgrade until proven otherwise.
Report what changed, what you verified, what needs a manual check and how to do it, and how to roll back.
Why it works: Requiring the official changelog and migration guide as the source for breaking changes prevents Claude from relying on outdated memory of the library. The impact report before any edit and the test baseline before the upgrade make it clear which failures the upgrade caused.
Tip: Do one major upgrade per branch; when several land together, it's hard to tell which one broke something.
17. Claude Code prompt to fix slow performance
Claude Code
Use it when: Find and fix a real performance bottleneck with before and after measurements instead of guesses.
Prompt 17
[WHAT IS SLOW, E.G. THE REPORTS PAGE TAKES 6 SECONDS TO LOAD WITH 10,000 ROWS]. Target: [E.G. UNDER 500 MS AT P95]. Find out why and fix it, using measurements rather than intuition.
1. Reproduce and measure. Build a repeatable benchmark or timing for the slow path with realistic data volume, and record the baseline. If you need data or access I haven't given you, ask.
2. Profile. Use the right tool for the stack (a profiler, EXPLAIN on queries, request timing, a bundle analyser) to find where the time actually goes. Show me the evidence: the top costs and their share of the total.
3. Propose fixes for the biggest cost first, with expected impact and trade-offs such as memory, complexity or stale data from caching. If there's more than one sensible option, wait for my pick.
4. Apply one fix at a time, re-run the same benchmark, and keep a change only if it measurably helps. Run the tests to confirm behaviour is unchanged.
Report a before and after table from the same benchmark, what you changed, and what you tried that didn't help. Spend effort only where the profile shows time is going.
Why it works: A repeatable benchmark and a profile before any change ensure Claude optimises where time is actually spent, not where it guesses. Applying one fix at a time and keeping it only if the same benchmark improves gives you a before and after you can trust.
Tip: Give Claude a numeric target so it knows when to stop; without one, optimisation tends to drift into code that isn't actually hot.
18. Claude Code subagents prompt for parallel work
Claude Code
Use it when: Split a large task across explorer, implementer and reviewer subagents so each works with a focused context and independent parts run in parallel.
Prompt 18
This task is too big for one context: [DESCRIBE THE LARGE TASK].
Act as the coordinator and use subagents.
1. Explore in parallel. Launch one read-only explorer subagent per area: [AREAS, E.G. API LAYER, DATABASE, FRONTEND]. Each returns a short summary: the relevant files, how the code works, and risks for this task. Summaries only, not whole files.
2. Plan. From their summaries, break the work into units with clear file ownership, so no two implementers edit the same file. Mark which units depend on others. Show me the plan and wait for approval.
3. Implement. Launch an implementer subagent per unit, in parallel where there are no dependencies. Give each a self-contained brief: goal, files it owns, interfaces it must match, done criteria and the test command to run.
4. Review. When the units are done, launch a reviewer subagent with fresh context to check the combined diff for bugs, mismatches between units and missing tests.
5. Integrate. Fix the review findings, run the full test suite, and report what each subagent did and the final results.
Write every brief as if to a capable colleague who hasn't seen this conversation, because subagents start without it.
Why it works: Giving explorers read-only, summary-only jobs keeps the coordinator's context free for planning instead of filling it with file contents. Assigning file ownership prevents parallel implementers from editing the same files, and a fresh-context reviewer catches mismatches the implementers can't see in their own work.
Tip: Define the roles as reusable agents in .claude/agents/ (an explorer with read-only tools, a reviewer without edit access) so the limits are enforced, not just requested.
Getting more out of every prompt
Put standing rules in CLAUDE.md
Anything you would repeat in every prompt, such as test commands, conventions or 'never speculate about code you have not opened', belongs in CLAUDE.md. Claude Code loads it at the start of every session, so the rules apply without retyping them. Keep it short, because every line uses context.
Make Claude verify its own work
Ask for done criteria that a test or command can prove, and require Claude to run the tests, linter and type checker before reporting. Claude Code can run these itself, so a prompt that asks for evidence gets a verified change instead of code that only looks right.
Keep context clean on big tasks
Long sessions accumulate file contents and dead ends that crowd out what matters. Use subagents for broad exploration so only their summaries come back, and write a handoff document before starting a fresh session.
Review before you push
A quick review of your own diff catches broken callers, missing tests and leftover debug code while they are cheap to fix. Running the same review prompt every time makes the check consistent rather than dependent on how tired you are.
Frequently asked questions
What is the best prompt for Claude Code?
There isn't a single best prompt; the biggest gains come from giving Claude Code a clear goal, observable done criteria and an instruction to explore the code before changing it. For anything non-trivial, ask it to plan first and wait for approval. Standing rules you use every time belong in CLAUDE.md rather than in each prompt.
What is plan mode in Claude Code?
Plan mode is a Claude Code permission mode in which Claude can read files and research the codebase but can't edit files or run changes until you approve a plan. You can switch into it with Shift+Tab. It is useful for larger changes, where reviewing the approach first is cheaper than reviewing a wrong diff.
What should go in a CLAUDE.md file?
Include the commands to install, run, test, lint and build the project, conventions the tooling doesn't enforce, a short map of the important directories, and known gotchas. Keep it concise, because it is loaded into every session. Longer reference material can live in separate files referenced with @path imports.
How do I continue a Claude Code session in a new chat?
Ask Claude to write a handoff document covering the goal, what is done, decisions made, open issues, next steps and files touched, checked against git status and test results. Save it to a file in the repo, then start the new session by asking Claude to read it and continue from the next steps. Claude Code can also resume earlier conversations with its continue and resume options.