How to write prompts that get better results faster from Claude Code.
Vague prompts lead to vague searches. Tell Claude exactly where to look.
Instead of:
"Fix the login bug"
Try:
"Fix the session expiry bug in
src/auth/session.ts, therefreshTokenfunction around line 80"
This skips the file-search phase and gets straight to the fix.
Tell Claude how to confirm the change worked. This prevents shallow fixes that pass the eye test but break at runtime.
Implement the rate limiter in middleware/rateLimit.ts.
After implementing, run `npm test -- --testPathPattern=rateLimit` to confirm all tests pass.
Claude will run the tests and iterate if they fail, rather than stopping after the first attempt.
Claude will match your codebase style when you show it an example.
Add a DeleteWidget endpoint following the same pattern used in src/api/CreateWidget.php.
This produces code that fits naturally instead of code that looks like it was written by a different team.
Saying "find the token refresh logic" triggers a wide codebase search. Scoping it saves time and tokens.
Check src/auth/ for the token refresh logic.
If you know the file, be even more specific:
Look at src/auth/oauth.ts for how token refresh is handled.
For features with many unknowns, ask Claude to interview you before writing any code. This surfaces assumptions and design decisions upfront.
I want to add multi-tenant support. Interview me about the requirements before making any changes.
Claude will ask focused questions, then produce a plan grounded in your actual constraints.
Claude Code accepts images. For layout bugs, design implementation, or UI review, paste a screenshot directly into the prompt. No need to describe the visual in words.
This is especially effective for:
- Pointing out a CSS bug ("the button is overlapping the nav, see screenshot")
- Implementing a design mockup
- Comparing before/after states
Before letting Claude execute a large refactor or migration, switch to plan mode first.
Press Shift+Tab twice to enter plan mode, then describe the task. Claude will lay out every step it intends to take. Review and edit the plan before approving execution.
This catches misunderstandings before any files change.
When you need Claude to investigate something that requires reading many files or running multiple searches, asking it to use subagents keeps the main context clean.
Use subagents to find all places where we call the payments API and summarize the patterns.
The research happens in isolated subagent contexts. Only the summary comes back to the main session.
If your task involves a library, API, or framework, paste the URL to the relevant docs. Claude will fetch and read them.
Update our Stripe integration to use the new Payment Intents API.
Docs: https://stripe.com/docs/payments/payment-intents
This is more reliable than relying on training data for fast-moving APIs.
For hard problems that require deep reasoning, tell Claude explicitly to think harder.
ultrathink: what is the safest way to migrate this schema without downtime?
This activates extended thinking and produces more thorough analysis on problems that reward it.
Claude defaults to using mocks in tests. If you prefer real objects or integration-style tests, say so.
Write tests for the UserRepository. Don't use mocks - use the real database with a test transaction that rolls back.
Or for the opposite:
Write unit tests. Use mocks for all external dependencies.
Being explicit avoids re-work when Claude's default does not match your project's style.