15 Ready-to-Use AI Prompts for Developers
Good prompts give the AI the same information you'd give a colleague: context, the goal, constraints and the format you want back. These 15 templates work with ChatGPT, Claude, Gemini and coding agents. Replace the parts in square brackets.
Understanding code
1. Explain unfamiliar code
Explain what this code does, step by step, for a developer new to [language/framework].
Point out anything surprising, risky or non-obvious.
[paste code]
2. Map a codebase (agents)
Give me a map of this repository: main modules, how a request flows through them,
where configuration lives, and the 5 files I should read first to understand [feature].
Reviewing and debugging
3. Code review
Review this change as a senior [language] developer. Focus on bugs, security issues,
edge cases and readability, in that order. For each finding: severity, line, why, fix.
Don't comment on style unless it hides a bug.
[paste diff]
4. Debug from an error
I get this error: [error and stack trace].
Expected: [what should happen]. Actual: [what happens].
Relevant code: [code]. List the most likely causes in order and how to confirm each.
5. Find the root cause, not the symptom
This bug was "fixed" before by [previous fix] but came back. What underlying cause
could explain both occurrences? Suggest a fix that addresses it, plus a test that would fail today.
Writing code
6. Clarify before coding
I need [feature]. Before writing any code, ask me up to 5 questions about requirements,
edge cases and constraints that would change your implementation.
7. Implement with constraints
Write [function/class] in [language, version] that [does X].
Constraints: no new dependencies, handle [edge cases], follow the style of this example: [snippet].
Include brief comments only where the logic isn't obvious.
8. Refactor safely
Refactor this code to [goal: remove duplication / improve testability] without changing behaviour.
Show the result, then list every behavioural risk you see.
[code]
Tests
9. Generate tests
Write [framework] unit tests for this function. Cover normal cases, boundaries, invalid input
and error paths. Use descriptive test names. [code]
10. Test the tests
Here is a function and its tests. Which realistic bugs would these tests NOT catch?
Add tests for the three most important gaps.
Data and text
11. SQL from a description
Schema: [tables and columns]. Write a [SQL dialect] query that returns [result].
Explain any joins and how NULLs are handled, and suggest an index if it would help.
12. Regex with examples
Write a regex for [flavour] that matches: [examples] and does NOT match: [counterexamples].
Explain each part and list inputs that could still break it.
Documentation and communication
13. Commit message
Write a conventional commit message for this diff: a short subject (max 60 chars)
and a body explaining why the change was needed. [diff]
14. README section
Write a "Getting started" section for this project: prerequisites, install, configuration,
first run and common errors. Audience: a developer who has never seen the project.
Design
15. Architecture decision
We need to choose between [option A] and [option B] for [problem].
Context: [team size, traffic, constraints]. Compare them on complexity, cost, scalability,
operations and lock-in, then recommend one and say what would change your mind.
Tips
- Paste less but better context: the relevant function, not the whole file.
- Ask for assumptions to be listed; wrong assumptions are the most common source of bad AI code.
- Always run and review generated code. Treat AI output like a pull request from a fast but new teammate.
Frequently asked questions
Do these prompts work with any AI assistant?
Yes. They are written for general chat assistants and coding agents alike. Agents that can read your repository need less pasted context.
Should I paste company code into an AI assistant?
Only into tools your company has approved for code, ideally business plans that exclude your data from training, or self-hosted models.
Why do the prompts ask questions first?
Asking the assistant to clarify requirements before writing code reduces wrong assumptions, which saves more time than it costs.