Skip to main content
Claude Code handles a wide range of software engineering work — from writing new features to tracking down bugs — directly in your terminal. Describe what you want in plain language and Claude uses tools like file reads, shell commands, and code search to get it done.

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:
Claude reads surrounding files to match your project’s style, naming conventions, and import patterns before writing anything.

Editing existing code

Point Claude at what to change and it makes targeted edits — without touching unrelated code. Example prompts:
The more specific you are about file paths and what to change, the more targeted Claude’s edits will be.

Refactoring

Ask Claude to restructure code for clarity, performance, or consistency. Give it context about your goal. Example prompts:
Claude reads the file first, understands the dependencies, and makes changes that preserve behavior while improving structure.

Debugging

Share an error message or describe unexpected behavior and Claude diagnoses the cause and fixes it. Example prompts:
Claude traces the error, reads relevant source files, and makes the fix — explaining what it found along the way.

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:
Claude returns findings with file paths and line numbers so you can navigate directly to the relevant code.

Example interactions

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.