50 ChatGPT Prompts Every Developer Should Know
The ultimate collection of ChatGPT prompts for developers. Copy-paste prompts for debugging, code review, documentation, testing, and more.
50 ChatGPT Prompts Every Developer Should Know
Stop wasting time with vague prompts. These 50 battle-tested prompts will transform how you use ChatGPT for development. For an even broader collection, see our ultimate guide to coding prompts.
Each prompt is optimized for maximum clarity and includes placeholders for customization.
Debugging Prompts (1-10)
1. Bug Diagnosis
I have a bug in my [LANGUAGE] code. The expected behavior is [EXPECTED], but actual behavior is [ACTUAL]. Here's the code:
[CODE]
Please:
1. Identify the root cause
2. Explain why this happens
3. Provide a corrected version
4. Suggest how to prevent this in future
2. Error Message Decoder
I'm getting this error: [ERROR MESSAGE]
Context:
- Language/Framework: [LANGUAGE]
- What I was trying to do: [ACTION]
Explain what this error means in simple terms and provide 3 possible solutions.
3. Stack Trace Analysis
Analyze this stack trace and explain:
1. What went wrong
2. Which line is the actual cause (vs. just propagating the error)
3. How to fix it
[STACK TRACE]
4. Memory Leak Detection
This code may have a memory leak. Analyze it for:
- Memory leaks
- Resource leaks (file handles, connections)
- Objects that should be garbage collected but aren't
[CODE]
5. Race Condition Debug
I suspect a race condition in this concurrent code. Please:
1. Identify potential race conditions
2. Explain the scenarios where they'd occur
3. Suggest fixes (mutexes, channels, atomic ops)
[CODE]
6. Performance Issue Investigation
This function is slow. Profile the logic and identify:
- Time complexity issues
- Unnecessary operations
- Optimization opportunities
Current execution context: [HOW IT'S CALLED]
[CODE]
7. Null/Undefined Debug
I'm getting null/undefined errors somewhere in this flow:
[CODE]
Trace through the data flow and identify all places where null/undefined could occur.
8. API Integration Debug
My API call isn't working as expected.
Request: [REQUEST DETAILS]
Expected response: [EXPECTED]
Actual response: [ACTUAL]
API documentation says: [RELEVANT DOCS]
What am I doing wrong?
9. Database Query Debug
This query returns wrong results:
[QUERY]
Expected: [EXPECTED ROWS/DATA]
Actual: [ACTUAL ROWS/DATA]
Schema:
[RELEVANT TABLES]
Diagnose the issue and fix the query.
10. Regex Debug
This regex isn't matching correctly:
Pattern: [REGEX]
Should match: [EXAMPLES THAT SHOULD MATCH]
Shouldn't match: [EXAMPLES THAT SHOULDN'T]
Fix the pattern and explain each part.
Code Review Prompts (11-20)
11. Comprehensive Review
Review this [LANGUAGE] code for:
- Bugs and edge cases
- Security vulnerabilities
- Performance issues
- Code smells
- Best practice violations
[CODE]
Format as: 🔴 Critical | 🟡 Suggestion | 🟢 Positive
12. Security Audit
Audit this code for security vulnerabilities including:
- Injection attacks (SQL, XSS, command)
- Authentication/authorization flaws
- Data exposure risks
- Insecure configurations
[CODE]
13. Performance Review
Review for performance issues:
- O(n²) or worse operations
- Unnecessary memory allocation
- Database N+1 queries
- Blocking operations
- Missing caching opportunities
[CODE]
14. Code Style Review
Review against [STYLE GUIDE - e.g., Google, Airbnb, PEP8]:
[CODE]
List all style violations with line numbers.
15. Accessibility Review
Review this frontend code for accessibility:
- ARIA labels
- Keyboard navigation
- Screen reader compatibility
- Color contrast issues
- Focus management
[CODE]
16. API Design Review
Review this API design:
[ENDPOINTS AND SCHEMAS]
Check for:
- REST best practices
- Consistent naming
- Appropriate HTTP methods
- Error response format
- Missing endpoints
17. Schema Review
Review this database schema:
[SCHEMA]
Check for:
- Normalization issues
- Missing indexes
- Poor naming conventions
- Relationship problems
- Scalability concerns
18. Test Coverage Review
Here's my function and its tests:
Function:
[CODE]
Tests:
[TEST CODE]
What cases am I missing? What edge cases should be tested?
19. PR Review Template
I'm reviewing this PR. Help me understand:
Changes:
[DIFF OR DESCRIPTION]
Context: [WHAT FEATURE/FIX THIS IS FOR]
Questions:
1. What could break?
2. What edge cases might be missed?
3. Any potential performance impact?
20. Architecture Review
Review this system design:
[ARCHITECTURE DESCRIPTION/DIAGRAM]
Evaluate for:
- Single points of failure
- Scalability bottlenecks
- Security concerns
- Operational complexity
- Cost efficiency
Browse more code review prompts in our library, or read our AI code review workflow guide for a complete process.
Documentation Prompts (21-30)
21. Function Documentation
Generate documentation for this function:
[FUNCTION]
Format: [JSDoc / Python docstring / Javadoc / etc.]
Include:
- Description
- Parameters with types
- Return value
- Usage example
- Edge cases
22. README Generator
Generate a README.md for my project:
Project name: [NAME]
What it does: [DESCRIPTION]
Tech stack: [TECHNOLOGIES]
Installation steps: [STEPS]
Key features: [FEATURES]
Include badges, quick start, and contributing section.
23. API Documentation
Document this API endpoint:
[ENDPOINT CODE OR SPECIFICATION]
Generate documentation including:
- Description
- URL and method
- Request parameters/body
- Response format with examples
- Error codes
- cURL example
24. Architecture Documentation
Create documentation for this system architecture:
[DESCRIPTION OR DIAGRAM]
Include:
- System overview
- Component descriptions
- Data flow
- Dependencies
- Deployment considerations
25. Code Comments
Add appropriate comments to this complex code:
[CODE]
Comment on:
- Why (not what) for non-obvious logic
- Algorithm explanations
- Magic numbers
- Edge case handling
- Potential gotchas
26. Changelog Entry
Write a changelog entry for this change:
[DESCRIPTION OF CHANGE]
Version: [VERSION]
Type: [Feature / Fix / Breaking / etc.]
Format as Keep a Changelog style.
27. Migration Guide
Write a migration guide for upgrading from v[OLD] to v[NEW]:
Breaking changes:
- [CHANGE 1]
- [CHANGE 2]
Include before/after code examples for each change.
28. Troubleshooting Guide
Create a troubleshooting guide for common issues with [SYSTEM/LIBRARY]:
For each issue include:
- Symptom
- Common causes
- Diagnostic steps
- Solutions
29. Quick Start Guide
Write a 5-minute quick start guide for [PROJECT]:
Target: [Beginner developer / experienced X developer]
Goal: Get [BASIC THING] working
Focus on the absolute minimum to see results.
30. Runbook
Create an operational runbook for [SERVICE]:
Include:
- Health check procedures
- Common incident responses
- Restart procedures
- Rollback steps
- Escalation paths
Refactoring Prompts (31-40)
31. General Refactor
Refactor this code to improve readability:
[CODE]
Preserve functionality but improve:
- Naming
- Structure
- Complexity
- DRY violations
32. Extract Function
Identify code that should be extracted into separate functions:
[CODE]
For each extraction, provide:
- Function name
- Parameters
- The extracted code
- Why this should be separate
33. Design Pattern Application
Refactor this to use [PATTERN NAME] pattern:
[CODE]
Show the refactored code and explain how the pattern applies.
34. Type Safety Refactor
Add TypeScript types to this JavaScript:
[CODE]
Create appropriate interfaces/types.
Make the most strict type definitions that still work.
35. Async Refactor
Refactor from callbacks to async/await:
[CALLBACK CODE]
Handle errors properly and maintain the same behavior.
36. Reduce Complexity
This function has high cyclomatic complexity. Simplify it:
[CODE]
Target: Under 10 cyclomatic complexity while maintaining functionality.
37. Remove Duplication
Find and remove duplication in this code:
[CODE]
Create reusable functions/components for repeated patterns.
38. Modernize Syntax
Update this [LANGUAGE] code to modern syntax ([VERSION]):
[CODE]
Use latest features where they improve the code.
39. Error Handling Improvement
Improve error handling in this code:
[CODE]
Current issues: [KNOWN ISSUES OR "review and identify"]
Implement proper error handling, recovery, and user feedback.
40. Testable Refactor
Refactor this code to be more testable:
[CODE]
Add dependency injection, reduce coupling, make I/O operations injectable.
Utility Prompts (41-50)
41. Regex Generator
Create a regex that matches:
- [WHAT TO MATCH]
And doesn't match:
- [WHAT TO EXCLUDE]
Explain each part of the pattern.
42. Bash Command
Write a bash one-liner that [TASK].
Requirements:
- [ANY CONSTRAINTS]
Explain what each part does.
43. SQL Query
Write a SQL query to [GOAL].
Schema:
[TABLES AND RELATIONSHIPS]
Requirements:
- [PERFORMANCE NEEDS]
- [ANY CONSTRAINTS]
44. Git Command
What git commands do I need to [GOAL]?
Current state: [WHERE I AM]
Desired state: [WHERE I WANT TO BE]
Include safety warnings if applicable.
45. Cron Expression
Create a cron expression that runs [WHEN].
Format for: [cron / AWS / Kubernetes / etc.]
Explain each field.
46. Data Structure Selection
I need to store [DATA] and perform these operations frequently:
- [OP 1]
- [OP 2]
In [LANGUAGE], what data structure should I use and why?
47. Algorithm Selection
I need to solve: [PROBLEM]
Constraints:
- Data size: [SIZE]
- Time constraint: [REQUIREMENT]
- Memory constraint: [REQUIREMENT]
What algorithm should I use? Provide implementation.
48. Boilerplate Generator
Generate boilerplate for [TYPE] in [FRAMEWORK]:
Include:
- Standard folder structure
- Config files
- Essential dependencies
- Basic setup code
49. Test Data Generator
Generate test data for [SCHEMA]:
[DATA MODEL]
Generate:
- [N] records
- Realistic values
- Edge cases included
- Format: [JSON / SQL / CSV]
50. Code Translation
Translate this code from [SOURCE LANGUAGE] to [TARGET LANGUAGE]:
[CODE]
Maintain:
- Same functionality
- Idiomatic patterns for target language
- Equivalent error handling
Bookmark This Page
Keep these prompts handy. Adapt them to your specific needs—the placeholders make it easy to customize for any situation. To sharpen your prompting technique, read how to write better AI prompts.
For more prompts organized by use case, browse our complete prompt library:
- Coding Prompts - 200+ developer prompts
- Data Prompts - SQL, analytics, visualization
- Writing Prompts - Documentation and content
Related Articles
The Ultimate Guide to Coding Prompts for Developers
Master AI-assisted coding with expert prompts for code review, debugging, refactoring, and more. Includes 20+ ready-to-use templates for ChatGPT, Claude, and GitHub Copilot.
How to Use AI for Code Review: Prompts + Workflow Guide
Learn how to leverage AI for effective code reviews. Complete workflow with prompts for security audits, performance checks, and best practices enforcement.
How to Build a Custom GPT: Complete Step-by-Step Guide
Learn how to create your own Custom GPT in ChatGPT. This comprehensive guide covers planning, instructions, knowledge files, actions, and best practices for building effective AI assistants.