ChatGPT prompts for Developers: 20 ready templates
Copy-ready prompts for code review, tests, explaining legacy code, debugging, SQL, documentation, and commit messages. Each prompt tells the tool to say it does not know when context is missing instead of guessing. Before pasting code, remove keys, passwords, tokens, and customer data, and review every suggestion and run the tests before merging.
- Prompt for a code review that finds bugs Reviews a piece of code for logic bugs, edge cases, and performance issues, ordering findings by severity.
- Prompt to write unit tests for a function Writes tests covering the normal case, edge cases, and expected errors, using your test framework.
- Prompt to explain legacy or undocumented code Explains step by step what old code does, and flags hidden assumptions and risky parts before you change it.
- Prompt to write a clear commit message from a diff Reads a diff and writes a commit message explaining what changed and why, in your team's format.
- Prompt to write a pull request description Writes a PR description covering purpose, changes, how it was tested, and risks, to make the reviewer's job easier.
- Prompt to analyse an error and find its cause Reads the error, stack trace, and related code, then ranks likely causes with a way to check each one.
- Prompt to write a SQL query from a plain description Writes a SQL query from your description of the result and table structure, explaining each part and stating assumptions.
- Prompt to speed up a slow SQL query Reads the query and its EXPLAIN plan, then suggests rewrites and indexes with the trade-off of each.
- Prompt to write a README for a project Writes a README explaining the project and how to install, run, and test it, from the config files you paste.
- Prompt to write docstrings and useful code comments Adds function docs in your language's format (JSDoc, docstrings) and comments that explain why, not what, without changing code.
- Prompt to refactor code without changing behaviour Proposes a refactor in small steps that improves readability and cuts duplication, keeping behaviour and the public interface.
- Prompt to write and explain a regular expression Writes a regex from examples of what should and should not match, explains it piece by piece, and adds test cases.
- Prompt to document an API endpoint Documents an API endpoint from its code: route, parameters, request and response examples, and error codes as in the code.
- Prompt for a security review of code Checks code for common vulnerabilities like injection, weak authorisation, and data leaks, stating confidence for each.
- Prompt to convert code from one language to another Converts code to another language in its idiomatic style, noting behaviour differences and libraries with no direct equivalent.
- Prompt for a technical design document Organises your thinking on a new feature into a design doc: problem, proposed solution, alternatives, risks, and rollout plan.
- Prompt to write an incident postmortem Turns an incident log and team notes into a blameless report: timeline, impact, root cause, and actions.
- Prompt to break a large dev task into smaller tasks Splits a large feature or ticket into small tasks ordered by dependency, flagging the unknowns that make estimating hard.
- Prompt to review Arabic and RTL support in a UI Checks UI code for right-to-left issues, fonts, numerals, dates, and mixed-direction text.
- Prompt to plan a library or framework upgrade Reads the release notes you paste, finds breaking changes that affect your code, and orders a safe upgrade plan.