prompts coding templates

Best Claude Prompts for Coding: 30+ Ready-to-Use Templates

Copy-paste Claude prompts for coding. 30+ battle-tested prompt templates for code generation, debugging, refactoring, testing, and more.

Updated: February 6, 2026 8 min read

30+ Battle-Tested Claude Coding Prompts

These prompts work in both Claude (web) and Claude Code (terminal). Copy, customize, and use.

Code Generation

Build a Feature

Build [FEATURE] for my [FRAMEWORK] application.
Tech stack: [STACK]
Requirements:
- [REQ 1]
- [REQ 2]
Include: error handling, TypeScript types, and tests.
Follow the existing code patterns in the project.

Create an API Endpoint

Create a REST API endpoint for [RESOURCE].
- Method: [GET/POST/PUT/DELETE]
- Path: /api/[resource]
- Input validation with [ZOD/JOI]
- Error responses with proper HTTP status codes
- Include request/response TypeScript types
- Add rate limiting
- Write integration tests

Generate a React Component

Create a React component called [NAME] that:
- [BEHAVIOR]
- Uses TypeScript with proper prop types
- Is accessible (ARIA labels, keyboard navigation)
- Has responsive design (mobile-first)
- Includes loading and error states
- Write unit tests with React Testing Library

Debugging

Fix an Error

I'm getting this error:
[PASTE ERROR MESSAGE]

In file: [FILE PATH]
Context: [WHAT YOU WERE DOING]

Find the root cause, explain why it happens, and fix it.

Trace a Bug

The [FEATURE] is behaving incorrectly:
Expected: [EXPECTED]
Actual: [ACTUAL]
Steps to reproduce: [STEPS]

Trace the data flow from [START] to [END] and find where it breaks.

Performance Issue

[COMPONENT/ENDPOINT] is slow ([TIME]ms).
Profile the code, identify bottlenecks, and optimize.
Target: under [TARGET]ms.
Don't break existing functionality.

Refactoring

Modernize Code

Refactor [FILE] from [OLD PATTERN] to [NEW PATTERN].
Examples:
- Callbacks → async/await
- Class components → functional components
- var → const/let
- CommonJS → ES modules
Maintain backward compatibility. Update all dependent files.

Extract and Organize

This file is too large ([LINES] lines). Break it into:
- Separate files by responsibility
- Shared utility functions
- Proper exports and imports
- Update all imports across the project
Keep the same public API.

Testing

Write Unit Tests

Write comprehensive unit tests for [FILE/FUNCTION].
Use [TESTING FRAMEWORK].
Cover:
- Happy path
- Edge cases (empty input, null, undefined)
- Error cases
- Boundary values
Aim for >90% coverage.

Write E2E Tests

Write end-to-end tests for the [FEATURE] user flow:
1. [STEP 1]
2. [STEP 2]
3. [STEP 3]
Use [PLAYWRIGHT/CYPRESS].
Include both success and failure scenarios.

Code Review

Review My Code

Review this code as a senior engineer:
[PASTE CODE]
Check for:
- Bugs and logic errors
- Security vulnerabilities
- Performance issues
- Code style and readability
- Missing error handling
- Test coverage gaps
Rate each issue: nit / suggestion / important / critical

Documentation

Generate Docs

Generate documentation for [FILE/MODULE]:
- JSDoc/docstring for every public function
- README with usage examples
- API reference if applicable
- Architecture decision records if relevant
Match the existing documentation style in the project.

DevOps

Create CI/CD Pipeline

Create a [GITHUB ACTIONS/GITLAB CI] pipeline for this project that:
1. Runs on push to main and PRs
2. Installs dependencies
3. Runs linting
4. Runs type checking
5. Runs tests
6. Builds the project
7. Deploys to [TARGET] on main branch

Dockerize

Create a production Dockerfile for this [LANGUAGE/FRAMEWORK] project:
- Multi-stage build
- Minimal final image
- Non-root user
- Health check
- Proper .dockerignore
- Docker Compose for local development

Git

Write Commit Message

Look at the current git diff and write a conventional commit message.
Format: type(scope): description
Types: feat, fix, refactor, test, docs, chore
Keep under 72 characters. Add body if complex.

Pro Tips

  1. Start prompts with what, not how
  2. Include tech stack context
  3. Specify output format explicitly
  4. Reference existing patterns in the project
  5. Ask for tests with every code generation
  6. Use CLAUDE.md for persistent project context

Not working?

Check common errors and instant fixes in the Error Fix Center.

Fix Errors →