50+ battle-tested Claude prompts for coding tasks.
Refactoring
Improve Code Quality
Refactor this code to be more readable and maintainable. Don't change behavior. Highlight any potential issues you find.
[CODE]
Apply SOLID Principles
Refactor this code to follow SOLID principles. Explain each change.
[CODE]
Extract Functions
Break this function into smaller, focused functions. Each should do one thing.
[CODE]
Code Review
Security Review
Review this code for security issues. Focus on: input validation, SQL injection, XSS, auth, secrets management. List findings by severity.
[CODE]
Performance Review
Identify performance bottlenecks. Suggest specific improvements. Estimate impact.
[CODE]
Style Review
Review against [STYLE GUIDE / LANGUAGE CONVENTIONS]. List violations.
[CODE]
Debugging
Find the Bug
This code [DESCRIBE EXPECTED BEHAVIOR] but actually [ACTUAL BEHAVIOR]. Find the bug. Walk through execution step by step.
[CODE]
Explain Error
This error: [ERROR]. Possible causes? How to fix?
[STACK TRACE]
Reproduce Issue
Help me write a minimal reproduction for this bug. The original code does [X]. The bug is [Y].
Testing
Write Unit Tests
Write comprehensive unit tests for this function. Cover happy path, edge cases, error cases. Use [JEST / PYTEST / etc.].
[CODE]
Write Integration Tests
Write integration tests for this API endpoint. Test auth, validation, success, errors. Use [FRAMEWORK].
[CODE]
Improve Test Coverage
Identify untested paths. Write tests for them.
[CODE + EXISTING TESTS]
Architecture
Design System
Design a [SYSTEM TYPE]. Requirements: [LIST]. Constraints: [LIST]. Propose architecture with components, data flow, key tradeoffs.
Database Schema
Design a database schema for [USE CASE]. Include relationships, indexes, constraints. Explain tradeoffs.
API Design
Design REST API for [DOMAIN]. Include endpoints, request/response shapes, status codes, auth, rate limiting.
Documentation
Docstrings
Add JSDoc / docstrings to this code. Include params, returns, throws, examples.
[CODE]
README
Write a README for this project: overview, install, usage, API, contributing, license.
[PROJECT INFO]
Architecture Decision Record
Write an ADR for [DECISION]. Sections: context, decision, consequences, alternatives.
Migration
Language Translation
Translate this code from [LANG A] to [LANG B]. Preserve behavior. Adapt to idioms.
[CODE]
Framework Migration
Migrate this from [FRAMEWORK A] to [FRAMEWORK B]. Preserve features. Explain changes.
[CODE]
Version Upgrade
Upgrade this code from [OLD VERSION] to [NEW VERSION]. Note breaking changes.
[CODE]
SQL
Write Query
Write a SQL query that [DESCRIPTION]. Schema: [TABLES + COLUMNS].
Optimize Query
This query [QUERY] is slow. Optimize it. Schema: [TABLES + INDEXES]. EXPLAIN: [PLAN].
Index Suggestion
Suggest indexes for these common queries: [QUERIES]. Schema: [TABLES].
Production
Add Logging
Add structured logging to this code. Use [WINSTON / STRUCTLOG]. Include relevant context.
[CODE]
Add Monitoring
Add observability: traces, metrics, error tracking. Use [SENTRY / DATADOG].
[CODE]
Add Caching
Identify where caching would help. Implement with [REDIS]. Address cache invalidation.
[CODE]
Code Translation
Python to TypeScript
Translate Python to TypeScript. Preserve behavior. Use [STRICT TYPES].
[CODE]
Cobol to Modern
Translate this Cobol to [TARGET LANGUAGE]. Preserve business logic.
[CODE]
Pro Tips
- Include relevant context (existing code, conventions)
- Specify language version
- State expected output format
- Ask Claude to explain reasoning
- Iterate: refine prompt based on output
System Prompt for Coding Sessions
You are a senior engineer pair-programming with me. Style:
- Explain reasoning briefly
- Highlight tradeoffs
- Suggest alternatives
- Ask clarifying questions when needed
- Prefer simplicity
- Note risks
Next Step
Read Claude API guide for programmatic use.