DEV Community

massot
massot

Posted on

10 ChatGPT/Claude Prompts Every Developer Should Have Saved

I've been using AI coding tools daily for over a year. The biggest lesson: vague prompts give vague results.

The fix is simple — structure your prompts with a role, context, and output format. Here are 10 templates I use every week. Copy them, fill the [brackets], and paste into Claude or ChatGPT.


1. Root Cause Debugger

Stop describing the error in your own words. Give the AI exactly what it needs:

You are a senior debugger. Here is my code and the error I'm getting:

Code:
[PASTE CODE]

Error:
[PASTE ERROR]

Explain the root cause in simple terms, then give me the fixed code with a one-line comment explaining what changed.
Enter fullscreen mode Exit fullscreen mode

Why it works: Forcing the AI to explain the root cause before fixing prevents it from just patching symptoms.


2. Silent Bug Hunter

For bugs that don't throw errors but produce wrong results:

Review this code for bugs that don't throw errors but produce wrong results (off-by-one, wrong conditions, mutating shared state, etc.):

[PASTE CODE]

List each bug with: line number → what's wrong → how to fix it.
Enter fullscreen mode Exit fullscreen mode

Why it works: Naming specific bug categories (off-by-one, shared state) guides the AI to look in the right places.


3. Unit Test Generator

Write comprehensive unit tests for this function:

[PASTE FUNCTION]

Testing framework: [JEST/PYTEST/VITEST]
Cover: happy path, edge cases, error cases, boundary values.
Use descriptive test names that explain what's being tested.
Enter fullscreen mode Exit fullscreen mode

Why it works: Without specifying "descriptive test names", you get test1, test2. The explicit instruction makes all the difference.


4. Senior Engineer Code Review

Review this code as a senior engineer preparing it for production. Check for:
- Security vulnerabilities
- Performance issues
- Readability and naming
- Missing error handling
- Test coverage gaps

Code:
[PASTE CODE]

Format: issue → severity (low/medium/high) → fix suggestion.
Enter fullscreen mode Exit fullscreen mode

Why it works: The severity format forces prioritization — you know what to fix first.


5. SQL Query Builder

Write an optimized SQL query for [POSTGRESQL/MYSQL/SQLITE]:

I need to: [DESCRIBE WHAT YOU WANT]

Tables involved:
[PASTE TABLE SCHEMAS OR DESCRIBE THEM]

Return the query + a brief explanation of why it's written this way.
Enter fullscreen mode Exit fullscreen mode

Why it works: Asking for the explanation catches bad query patterns before they hit production.


6. Dockerfile Generator

Write an optimized Dockerfile for:

App type: [NODE/PYTHON/GO]
App entry point: [FILE/COMMAND]
Port: [PORT]
Environment variables needed: [LIST]

Requirements: multi-stage build, non-root user, minimal image size, proper layer caching.
Enter fullscreen mode Exit fullscreen mode

Why it works: Without the requirements line, you get a single-stage Dockerfile running as root. The explicit constraints are everything.


7. GitHub Actions Workflow

Create a GitHub Actions CI/CD workflow for:

Trigger: [PUSH TO MAIN / PR / RELEASE]
Steps needed: [TEST / BUILD / LINT / DEPLOY]
Deploy target: [WHERE IT DEPLOYS TO]
Secrets needed: [LIST SECRET NAMES]

Include: caching for faster runs, failure notifications.
Enter fullscreen mode Exit fullscreen mode

Why it works: Specifying secret names upfront means you get a workflow that actually runs, not one that needs 10 edits.


8. Commit Message Writer

Write a conventional commit message for these changes:

[DESCRIBE OR PASTE DIFF]

Format: type(scope): description
Types: feat, fix, docs, style, refactor, test, chore
Keep the subject under 72 chars. Add body if needed.
Enter fullscreen mode Exit fullscreen mode

Why it works: Conventional commits are parseable by changelogs and release tools. This prompt enforces the format automatically.


9. Rubber Duck Debugger

When you're completely stuck:

I'm stuck on this problem. Help me think through it:

What I'm trying to do: [GOAL]
What I've tried: [LIST ATTEMPTS]
What happens: [ACTUAL RESULT]
What I expected: [EXPECTED RESULT]

Ask me clarifying questions first, then suggest approaches I might not have considered.
Enter fullscreen mode Exit fullscreen mode

Why it works: "Ask me clarifying questions first" forces a dialogue instead of a wall of generic suggestions. It often reveals you missed something obvious.


10. Blameless Post-Mortem Writer

Help me write a blameless post-mortem for this incident:

What happened: [DESCRIBE INCIDENT]
When: [DATE/TIME]
Impact: [WHO WAS AFFECTED AND HOW]
How it was resolved: [FIX]

Generate: timeline, root cause analysis, contributing factors, action items with owners and deadlines.
Enter fullscreen mode Exit fullscreen mode

Why it works: Post-mortems written under pressure miss contributing factors. Letting the AI structure it from your notes is a huge time saver.


The Pattern Behind All of These

Every prompt above follows the same structure:

  1. Role — "You are a senior debugger / engineer"
  2. Context — paste the actual code, error, or situation
  3. Output format — exactly how you want the response structured

The [brackets] are intentional — they force you to fill in real context instead of leaving the AI to guess.


Want All 50?

I packaged 40 more prompts across debugging, architecture, testing, DevOps, documentation, prompt engineering, and problem solving into a single Markdown file you can keep open in Obsidian, VS Code, or Notion.

👉 50 Power Prompts for Developers — €7 on Gumroad


What prompts do you find yourself rewriting over and over? Drop them in the comments — I might add them to v2.

Top comments (0)