AI Prompts for Developers — Copy & Paste

Battle-tested prompts for the coding tasks you do every day — debugging, reviews, tests, refactoring, SQL, commit messages and documentation. Set your language and framework once and copy.

Runs in your browserUpdated
Your valuesEvery example below updates as you type

Understand code

3
Explain this code
Explain what this TypeScript code does, step by step. Then list:
1. Inputs and outputs
2. Side effects (network, files, state)
3. Edge cases it does not handle

```
[paste code]
```

Asking for side effects and missing edge cases turns a summary into a review.

Map an unfamiliar codebase
I am new to this React project. Based on the file tree and the files below, explain the architecture: the main modules, how data flows from a request to the response, and where I should look to change [feature].

File tree:
[paste tree]

Key files:
[paste files]
Explain a regex or one-liner
Break this down token by token and give three example inputs that match and three that do not:

[paste regex or command]

Debug

4
Find the bug
This TypeScript function should [expected behaviour] but instead [actual behaviour].

```
[paste code]
```

Find the root cause. Explain why it happens before proposing a fix, and show the smallest change that fixes it.

Describing expected vs actual behaviour is the single biggest improvement to debugging prompts.

Explain an error and stack trace
I get this error when [what you did]:

```
[paste error and stack trace]
```

Relevant code:
```
[paste code]
```

Explain what the error means, the most likely causes in order of probability, and how to confirm each one.
Why is this slow?
This TypeScript code takes [time] for [input size]. Identify the bottlenecks, estimate their complexity, and suggest optimisations ordered by impact vs effort. Do not change behaviour.

```
[paste code]
```
Rubber duck me
I am stuck on [problem]. Do not give me the answer yet. Ask me one question at a time to help me find the cause myself.

Good when you want to learn rather than just get a fix.

Write code

5
Implement from a spec
Write a TypeScript function that [does X].

Requirements:
- [requirement]
- [requirement]

Handle these edge cases: [empty input, invalid values, …]. Use no external libraries. Add brief comments only where the logic is not obvious, and include example usage.
Build a component
Create a React component in TypeScript for [describe UI]. Props: [list]. It must be accessible (keyboard, ARIA where needed) and responsive. Keep styling minimal and separate from logic.
Write a SQL query
Write a PostgreSQL query that [goal].

Schema:
```sql
[paste CREATE TABLE statements]
```

Explain the query, mention which indexes it needs, and point out anything that could be slow on large tables.
Convert between languages
Convert this code from [source language] to TypeScript. Keep the same behaviour, use idiomatic TypeScript rather than a line-by-line translation, and list any behaviour that cannot be preserved exactly.

```
[paste code]
```
Write a shell script
Write a bash script that [goal]. It must: exit on errors (set -euo pipefail), print what it is doing, accept [arguments] with a --help message, and be safe to run twice.

Review & refactor

4
Code review
Review this code as a senior TypeScript engineer. Group findings by severity (bug, security, performance, readability). For each, quote the line, explain the problem and suggest a fix. Skip praise and nitpicks about formatting.

```
[paste diff or code]
```
Refactor safely
Refactor this code for readability and maintainability without changing its behaviour or public API. Explain each change in one line. Point out anything you were unsure was behaviour-preserving.

```
[paste code]
```
Security review
Audit this code for security issues: injection, XSS, auth and access control, secrets, unsafe deserialisation, SSRF and input validation. For each finding give a concrete exploit scenario and a fix.

```
[paste code]
```
Simplify
This works but feels too complicated. Show a simpler version with fewer branches and less state, and explain what made the original complex.

```
[paste code]
```

Tests

3
Write unit tests
Write Vitest unit tests for this TypeScript code. Cover the happy path, edge cases and error handling. Use descriptive test names, no shared mutable state, and mock only external dependencies.

```
[paste code]
```
Find missing test cases
Here is a function and its tests. List the important cases the tests do not cover, then write tests for the three most valuable ones.

Code:
[paste code]

Tests:
[paste tests]
Generate test data
Generate [number] realistic test records as JSON for this schema. Include tricky values: unicode names, very long strings, empty optional fields, boundary numbers and dates around DST changes.

[paste schema or type]

Docs & communication

5
Commit message from a diff
Write a conventional commit message for this diff: a subject line under 72 characters in the imperative mood, a blank line, then a short body explaining why the change was made.

```diff
[paste git diff --staged]
```

Get the diff with git diff --staged.

Pull request description
Write a pull request description for these changes with sections: Summary, Why, How it works, How to test, Risks. Keep it concise.

[paste diff or list of changes]
Document a function
Add TypeScript doc comments (JSDoc/TSDoc, docstrings or equivalent) to this code: purpose, parameters, return value, errors thrown and one example. Do not change the code.

```
[paste code]
```
Write a README section
Write the "Getting started" section of a README for this project: prerequisites, installation, configuration (environment variables), running locally and running tests. Use copy-pasteable commands.

Project details:
[paste package.json / notes]
Explain to a non-developer
Explain this technical issue to a non-technical stakeholder in under 120 words: what happened, the impact on users, and what we are doing about it. No jargon.

[paste incident notes]

Plan & design

4
Compare approaches
I need to [goal] in a React app. Compare [option A], [option B] and [option C] in a table: complexity, performance, maintenance, cost and when each is the best choice. Then recommend one for my situation: [context].
Design a database schema
Design a PostgreSQL schema for [domain]. Entities: [list]. Show CREATE TABLE statements with keys, constraints and indexes, and explain how it supports these queries: [queries].
Break a feature into tasks
Break this feature into small tasks of at most half a day each, in a sensible order, with acceptance criteria for each:

[describe feature]
Review an API design
Review this REST API design for consistency, naming, status codes, pagination, error format, versioning and security. Suggest concrete improvements.

[paste endpoints or OpenAPI spec]

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the AI Prompts for Developers

  1. Set your language, framework, test runner and database at the top — every prompt updates.
  2. Pick a prompt for your task: understand, debug, write, review, test, document or plan.
  3. Click Copy prompt, paste it into ChatGPT, Claude, Gemini or Copilot Chat, and replace the [bracketed] parts with your code or details.
  4. Ask follow-up questions in the same chat to refine the answer.

What makes a good coding prompt

  • Context — language, framework and versions. “React 19 with TypeScript” gets far better answers than “JavaScript”.
  • Expected vs actual — for bugs, say what should happen and what happens instead.
  • The smallest relevant code — paste the function and its callers, not the whole repository.
  • Constraints — no new dependencies, keep the public API, must run on Node 20…
  • Output format — a diff, a table, tests only, or explanation before code.

Verify before you ship

AI assistants write plausible code that can be subtly wrong: invented APIs, missed edge cases, outdated syntax or insecure patterns. Run the code, read it as carefully as a colleague’s pull request, and ask the assistant to write tests for its own output. Never paste secrets, credentials or customer data.

Format code before pasting with the JSON formatter or SQL formatter, and check generated regular expressions in the regex tester.

Tools that pair well with the AI Prompts for Developers

  • Git Cheat Sheet — Every Git command you use day to day — and the ones you need when something goes wrong — explained in one line.
  • Linux Commands Cheat Sheet — The Linux and bash commands developers use on servers and laptops — files, search, permissions, processes, logs, networking and SSH.
  • Docker Cheat Sheet — The Docker and Docker Compose commands you reach for every week, explained in one line.

Frequently asked questions

Do these prompts work with ChatGPT, Claude, Gemini and Copilot?
Yes. They are plain-language prompts that work with any capable AI assistant, including ChatGPT, Claude, Gemini and GitHub Copilot Chat.
Is it safe to paste my code into an AI assistant?
Check your company’s policy first. Remove secrets, API keys, customer data and internal URLs before pasting, and prefer business or enterprise plans that don’t train on your data.
How do I get better answers?
Give context (language, framework, versions), say what you expect versus what happens, paste the smallest code that shows the problem, and ask for reasoning before the fix. Ask follow-up questions instead of starting over.

Related tools