Claude Code Prompt Templates Collection

Efficient prompt templates for various development scenarios to help developers quickly master Claude Code usage techniques.

Project Initialization

Project Analysis

Please read the project's README.md, package.json, and main directories to help me understand the project's architecture and tech stack, but don't write any code yet.

Create Project Configuration File

Please help me create a detailed CLAUDE.md file that includes project architecture description, common commands, coding standards, and development environment configuration.

Project Environment Setup

Please check the project's environment configuration, ensure all dependencies are correctly installed, and run initialization scripts. If there are any issues, please tell me how to resolve them.

Feature Development

New Feature Development Process

I need to develop [feature description]. Please follow these steps:
1. First read relevant code to understand existing architecture
2. Create a detailed implementation plan
3. Implement core functionality
4. Write tests
5. Update documentation
Pause and wait for my confirmation after each step.

Test-Driven Development

I want to implement [feature description]. Please first write test cases based on expected inputs and outputs, ensure tests fail, then implement the feature code to make tests pass.

API Interface Development

Please help me design and implement [API description] interface, including:
- Route definition
- Request parameter validation
- Business logic implementation
- Response format definition
- Error handling
- API documentation

Component Development

Please help me create a [component name] component with requirements:
- Follow existing component patterns in the project
- Include TypeScript type definitions
- Support [specific functional requirements]
- Write corresponding test files

Code Debugging and Optimization

Error Diagnosis

I encountered this error: [error message]. Please help me analyze the cause and provide a fix. Let me know if you need to see related code.

Performance Optimization

Please analyze performance issues in [file/feature] and provide optimization suggestions. Focus on:
- Execution efficiency
- Memory usage
- Loading speed
- User experience

Code Refactoring

Please refactor [function/class] in [filename], with goals to:
- Improve code readability
- Reduce duplicate code
- Follow best practices
- Maintain functionality unchanged
Please analyze existing code first, then provide a refactoring plan.

Code Review

Please review [file/feature] code, focusing on:
- Code standards
- Security issues
- Performance issues
- Best practices
- Potential bugs

Test Case Writing

Please write comprehensive test cases for [function/class/component], including:
- Normal case tests
- Boundary condition tests
- Error case tests
- Mock dependencies

Test Fixing

Several tests are failing, please analyze the failure reasons and fix them. The test command is: [test command]

Test Coverage Improvement

Please analyze current test coverage and add test cases for areas with insufficient coverage.

Frontend Development

UI Component Implementation

Please implement UI component based on this design: [upload design]
Requirements:
- Responsive design
- Support dark mode
- Accessibility support
- Comply with design specifications

Style Adjustment

Please optimize styles for [component/page] to achieve:
- [specific style requirements]
- Maintain consistency with overall design
- Ensure proper display on different devices

State Management

Please implement state management for [feature], including:
- State structure design
- Action definitions
- Reducer implementation
- Async operation handling

Backend Development

Database Design

Please design database table structure for [feature], including:
- Table structure definition
- Index design
- Relationship constraints
- Migration scripts

Middleware Development

Please implement a [middleware name] middleware with features:
- [specific functional requirements]
- Error handling
- Logging
- Performance monitoring

Service Integration

Please help me integrate [third-party service], including:
- SDK configuration
- API call encapsulation
- Error handling
- Unit tests

Documentation Writing

API Documentation Generation

Please generate API documentation for the project, including:
- Interface list
- Request parameter descriptions
- Response format examples
- Error code descriptions

Code Comments

Please add detailed code comments to [file/function], including:
- Function description
- Parameter descriptions
- Return value description
- Usage examples

README Update

Please update the project's README.md file to ensure it includes:
- Project introduction
- Installation instructions
- Usage methods
- Contribution guidelines

Git Workflow

Code Commit

Please review current changes, write appropriate commit messages and commit the code. Commit messages should follow the project's commit conventions.

Create PR

Please create a Pull Request, including:
- Clear title and description
- Summary of changes
- Test plan
- Related Issue links

Branch Management

Please help me create a new feature branch [branch name] and switch to it to start development.

Project Management

Task Breakdown

I need to implement [large feature description]. Please help me break it down into multiple small tasks, each including:
- Task description
- Estimated time
- Dependencies
- Acceptance criteria

Project Planning

Please help me create a project development plan, including:
- Feature module division
- Development priorities
- Time schedule
- Risk assessment

Technology Selection

For [project requirements], please help me analyze technology selection, compare pros and cons of different solutions, and recommend the most suitable tech stack.

Code Analysis

Dependency Analysis

Please analyze project dependencies, check for:
- Redundant dependencies
- Security vulnerabilities
- Version updates needed
- Alternative solutions

Architecture Analysis

Please analyze the overall project architecture, evaluate:
- Clear module responsibilities
- Reasonable coupling
- Extensibility
- Areas for improvement

Code Statistics

Please provide project code statistics, including:
- Lines of code
- Number of files
- Tech stack distribution
- Test coverage

Environment Configuration

Development Environment Setup

Please help me configure the development environment, including:
- Install necessary dependencies
- Configure environment variables
- Set up development tools
- Verify environment is working

CI/CD Configuration

Please configure CI/CD pipeline for the project, including:
- Automated testing
- Code quality checks
- Automated deployment
- Notification mechanisms

Docker Configuration

Please create Docker configuration for the project, including:
- Dockerfile
- docker-compose.yml
- Environment variable configuration
- Deployment instructions

Advanced Techniques

Batch Processing

Please perform [operation] on all [file type] files in the project, ensuring:
- Operation consistency
- No breaking existing functionality
- Compliance with project standards

Automation Scripts

Please create an automation script to [task description], the script should:
- Support command-line arguments
- Include error handling
- Provide detailed logging
- Be easy to maintain

Code Generation

Please generate corresponding code files based on [configuration/template], including:
- [specific file types]
- Follow project conventions
- Include necessary comments
- Pass basic tests

Usage Suggestions

Prompt Writing Principles

Be Clear and Specific

Describe requirements in detail, avoid vague expressions

Break into Steps

Split complex tasks into multiple steps

Set Boundaries

Clarify what to do and what not to do

Include Context

Provide necessary background information

Verify and Confirm

Require confirmation before continuing important steps

Common Modifiers

"Please first analyze...": Require Claude to understand before acting
"Don't do... yet": Set clear boundaries
"Pause after each step": Control execution pace

Efficiency Tips

Use @ to Reference Files

@src/components/Button.tsx directly references file content

Utilize Extended Thinking

Press Shift+TAB twice to enter PLAN mode for planning

Manage Context Properly

Use /clear and /compact to manage conversation history

Create Custom Commands

Define common commands in .claude/commands/ directory

Batch Operations

Process multiple similar tasks at once for efficiency

💡 Tip: These prompt templates can be adjusted according to specific project needs. It's recommended to bookmark this article as a daily development reference and gradually master efficient communication with Claude Code.

Practical Examples

Example 1: Quick Bug Fix

I'm getting an error when running npm test:
"TypeError: Cannot read property 'map' of undefined at UserList.tsx:45"

Please:
1. Analyze the error cause
2. Provide a fix
3. Explain why this problem occurred
4. Suggest how to avoid similar issues

Example 2: Optimize Code Performance

Users report the list page loads slowly, please:
1. Analyze performance bottlenecks in @src/pages/UserList.tsx
2. Optimize using React DevTools Profiler results
3. Implement virtual scrolling or pagination
4. Add loading states and error handling
5. Ensure functionality works after optimization

Example 3: Implement New Feature

I need to add Excel export functionality:
1. First check existing table component implementation
2. Design the export feature interface
3. Implement frontend export logic
4. Add export button and progress indicator
5. Handle batch export for large data
6. Write corresponding test cases

By using these carefully designed prompts, you'll be able to better leverage Claude Code's powerful capabilities and significantly improve development efficiency and code quality.

Bring endless innovation and opportunities with AI
About
Features
Docs
Pricing
Contact us
Terms & Policies
Terms of Use
Privacy Policy
Specified Commercial Transactions Act