Writing new code
Describe the feature or function you want and Claude writes it, places it in the right file, and follows the conventions already in your codebase. Example prompts:Editing existing code
Point Claude at what to change and it makes targeted edits — without touching unrelated code. Example prompts:Refactoring
Ask Claude to restructure code for clarity, performance, or consistency. Give it context about your goal. Example prompts:Debugging
Share an error message or describe unexpected behavior and Claude diagnoses the cause and fixes it. Example prompts:Running and fixing tests
Ask Claude to run your test suite and fix any failures it finds. Example prompts:Claude runs tests using your project’s existing test runner (Jest, pytest, Vitest, etc.) via the shell. Make sure your test command works from the terminal before asking Claude to run it.
Searching the codebase
Claude uses ripgrep and glob-based file search to find relevant code before making changes. You can also ask it to search explicitly. Example prompts:Example interactions
- New feature
- Bug fix
- Refactor
Tips for better prompts
Include file paths
Tell Claude which file to look in. “In src/auth/validate.ts, fix the null check” is faster and more precise than “fix the null check somewhere in auth”.
Share the error message
Paste the full error output when debugging. Stack traces, line numbers, and error text all help Claude pinpoint the issue.
Describe the goal, not just the change
“Extract this into a separate function so it can be unit tested” gives Claude more context than “refactor this function”.
Ask for tests alongside code
“Write the function and add unit tests for it” in a single prompt ensures the new code is testable from the start.