DEV Community

EME GUG
EME GUG

Posted on

100+ ChatGPT Prompts for Developers — The Ultimate Collection

A curated collection of battle-tested prompts for software development. Copy, paste, adapt.


🐛 Debugging

Review this error and explain the root cause. Then provide a fix with explanation:

[paste error + relevant code]
Enter fullscreen mode Exit fullscreen mode
This function works for most inputs but fails for [specific case]. 
Analyze why and fix it without changing the function signature:

[paste function]
Enter fullscreen mode Exit fullscreen mode
I'm getting unexpected behavior: [describe what happens vs what should happen].
Here's my code. Find the bug:

[paste code]
Enter fullscreen mode Exit fullscreen mode
This code has a memory leak. Find it and explain how to fix it:

[paste code]
Enter fullscreen mode Exit fullscreen mode
Why does this SQL query return wrong results? Show the correct query and explain the difference:

[paste query + expected vs actual results]
Enter fullscreen mode Exit fullscreen mode

💻 Code Writing

Write a [language] function that [specific behavior].
Requirements:
- Input: [describe input]
- Output: [describe output]
- Handle edge cases: [list them]
- Include type hints and docstring
Enter fullscreen mode Exit fullscreen mode
Convert this [language A] code to [language B]. Maintain the same logic and error handling:

[paste code]
Enter fullscreen mode Exit fullscreen mode
Write a REST API endpoint in [framework] that:
- Accepts [HTTP method] requests at /[path]
- Validates input: [describe schema]
- Returns: [describe response]
- Handles errors: [list error cases]
Enter fullscreen mode Exit fullscreen mode
Create a database migration that:
- Adds [columns/tables]
- Handles existing data: [describe migration strategy]
- Is reversible
- Works with [PostgreSQL/MySQL/SQLite]
Enter fullscreen mode Exit fullscreen mode
Write unit tests for this function. Cover:
- Happy path
- Edge cases: [list them]
- Error conditions
- Use [testing framework]

[paste function]
Enter fullscreen mode Exit fullscreen mode

🔍 Code Review

Review this code for:
1. Bugs and logical errors
2. Security vulnerabilities (OWASP top 10)
3. Performance issues
4. Code style and readability
Rate each issue as Critical/Warning/Suggestion.

[paste code]
Enter fullscreen mode Exit fullscreen mode
Review this pull request diff. Focus on:
- Breaking changes
- Missing error handling
- Race conditions
- Test coverage gaps

[paste diff]
Enter fullscreen mode Exit fullscreen mode
Is this code production-ready? What would you change before deploying?

[paste code]
Enter fullscreen mode Exit fullscreen mode

🏗 Architecture & Design

I'm building [describe system]. Current tech stack: [list].
Design the system architecture. Include:
- Component diagram
- Data flow
- API contracts
- Database schema
- Scaling considerations
Enter fullscreen mode Exit fullscreen mode
Compare these approaches for [problem]:
Approach A: [describe]
Approach B: [describe]
Evaluate: performance, maintainability, complexity, scaling. Recommend one with reasoning.
Enter fullscreen mode Exit fullscreen mode
Design a database schema for [describe application].
Requirements: [list requirements]
Consider: indexes, relationships, normalization, query patterns.
Output as SQL CREATE statements.
Enter fullscreen mode Exit fullscreen mode
I need to add [feature] to an existing [type] application.
Current architecture: [describe]
Constraints: [list]
Propose the implementation plan with file changes and estimated effort.
Enter fullscreen mode Exit fullscreen mode

📝 Documentation

Write API documentation for this endpoint. Include:
- Description
- Request format (headers, body, params)
- Response format (success + error cases)
- Example curl command
- Rate limits if applicable

[paste endpoint code]
Enter fullscreen mode Exit fullscreen mode
Write a README.md for this project:
- What it does: [describe]
- Tech stack: [list]
- Include: installation, usage, configuration, contributing sections
- Tone: professional but approachable
Enter fullscreen mode Exit fullscreen mode
Generate JSDoc/docstring comments for all public functions in this file.
Focus on: purpose, params, return value, exceptions, usage example.

[paste file]
Enter fullscreen mode Exit fullscreen mode

⚡ Performance

Profile this code for performance bottlenecks. Suggest optimizations with expected improvement:

[paste code]
Enter fullscreen mode Exit fullscreen mode
This SQL query is slow on a table with [X] million rows. Optimize it.
Current indexes: [list]
Explain your changes and suggest additional indexes.

[paste query]
Enter fullscreen mode Exit fullscreen mode
Rewrite this code to handle [X] concurrent requests. Current version handles [Y].
Constraints: [memory/CPU limits]

[paste code]
Enter fullscreen mode Exit fullscreen mode

🔒 Security

Audit this code for security vulnerabilities. Check for:
- SQL injection
- XSS
- CSRF
- Authentication/authorization flaws
- Sensitive data exposure
- Insecure dependencies
For each issue, show the vulnerable line and the fix.

[paste code]
Enter fullscreen mode Exit fullscreen mode
Generate a Content Security Policy for a web app that:
- Uses [CDNs]
- Loads fonts from [source]
- Makes API calls to [domains]
- Uses inline styles: [yes/no]
Enter fullscreen mode Exit fullscreen mode

🚀 DevOps & Infrastructure

Write a Dockerfile for a [language/framework] application.
Requirements:
- Multi-stage build
- Non-root user
- Minimal image size
- Health check
- Environment variable configuration
Enter fullscreen mode Exit fullscreen mode
Write a GitHub Actions workflow that:
- Triggers on: [events]
- Steps: [list build/test/deploy steps]
- Uses caching for [dependencies]
- Deploys to [target]
Enter fullscreen mode Exit fullscreen mode
Write a docker-compose.yml for a development environment with:
- [App framework] on port [X]
- [Database] with persistent volume
- [Cache/queue service]
- Hot reload enabled
Enter fullscreen mode Exit fullscreen mode

🧠 Learning & Explanation

Explain [concept] like I'm a [junior/mid/senior] developer.
Use a real-world analogy, then show a code example in [language].
Enter fullscreen mode Exit fullscreen mode
What's the difference between [A] and [B] in [language/framework]?
Show examples of when to use each.
Enter fullscreen mode Exit fullscreen mode
I don't understand this code. Walk me through it line by line, explaining what each part does and why:

[paste code]
Enter fullscreen mode Exit fullscreen mode

📊 Data & Analysis

Write a Python script to:
1. Read data from [source/format]
2. Clean: [describe transformations]
3. Analyze: [describe metrics]
4. Visualize: [describe charts]
5. Export results to [format]
Use pandas and matplotlib.
Enter fullscreen mode Exit fullscreen mode
Write a SQL query to analyze [describe what you want to know].
Tables: [describe schema]
Group by: [dimension]
Filter: [conditions]
Include percentage calculations and running totals.
Enter fullscreen mode Exit fullscreen mode

🔄 Refactoring

Refactor this code following [SOLID/DRY/clean code] principles.
Keep the same external behavior. Explain each change.

[paste code]
Enter fullscreen mode Exit fullscreen mode
This function is too long ([X] lines). Split it into smaller, testable functions.
Maintain the same public interface.

[paste function]
Enter fullscreen mode Exit fullscreen mode
Migrate this code from [old pattern/library] to [new pattern/library].
Preserve all functionality and error handling.

[paste code]
Enter fullscreen mode Exit fullscreen mode

💬 Git & Collaboration

Write a commit message for these changes. Follow conventional commits format:

[paste diff]
Enter fullscreen mode Exit fullscreen mode
Write a pull request description for these changes:
- What: [summarize]
- Why: [motivation]
- Include: testing notes, migration steps, screenshots needed

[paste diff or description]
Enter fullscreen mode Exit fullscreen mode

Tips for Better Results

  1. Be specific. "Write a function" → "Write a Python 3.12 async function that..."
  2. Provide context. Share your tech stack, constraints, and existing code patterns.
  3. Iterate. First response not perfect? Say "Make it more [specific quality]."
  4. Set the role. Start with "You are a senior [X] developer with expertise in [Y]."
  5. Ask for tradeoffs. "What are the downsides of this approach?"

Get ChatGPT Plus at ios.mom for the best experience with these prompts — GPT-5.6 handles complex developer prompts significantly better than the free tier.


Found this useful? Star the gist and share with your team. I update it monthly with new prompts.

Top comments (0)