Coding prompts for GPT
Prompts for a normal week of software work: errors and logic bugs, reviews and refactors, tests and fixtures, SQL and regex, docs, Git trouble and new languages.
Twenty prompts for the coding jobs that come up week after week: making sense of an error in your own project, catching a bug that gives wrong answers without crashing, reviewing a change, refactoring, writing tests and sample records that break careless code, building SQL and regular expressions, shell scripts, docs, Git rescues and learning a new language from one you already know.
Context decides the quality of the answer. Name the language, framework and versions; paste the shortest piece of code that still shows the problem, with the complete error text; describe what you expected to happen instead. Six prompts suggest GPT-6.1 Terra, which spends a moment reasoning before it replies. That pays off for logic bugs, performance work, attacker-style security reviews, schema design and planning how to split a huge file. GPT-6 Luna, the fast default, covers explanations, documentation and boilerplate well. One prompt turns an attached screenshot of a form or card into a component.
Be sceptical in the right places. What the models know about libraries stops at their training date, and our chat cannot fetch today's docs, so an API it suggests may have changed or may never have existed. Run everything and keep your tests in charge. Strip API keys, passwords, tokens and customer data before you paste, because messages travel through our server to the model provider. Long pastes get trimmed, so send the function in question rather than the whole project.
See how developers use GPT, try the Code Assistant or read about the GPT API.
How to adapt these prompts
- Give versions: "Python 3.13 with Django 5" beats "Python".
- Get a plan first when the task is larger than a single function, then ask for the code step by step.
- Want a reason next to each change, so you can judge the thinking as well as the result.
- Paste test failures back into the same chat; the model keeps the earlier context.
- Say what you can't change, such as a public interface or a dependency you must keep.
-
01
Explain an error in my own code
Here is an error from my [language and framework, with versions] project: [paste error]. Tell me in plain words what it means, which line of this snippet most likely triggers it, [paste code], and the fix you would try first. If you need more information, ask for it.
-
02
Rubber-duck a logic bug
I'm going to describe what my [language] code is supposed to do, step by step: [your description]. Here is the code itself: [paste code]. Compare my description with what the code really does, name every place where they disagree, and tell me which disagreement explains the symptom [symptom]. Suggest the smallest fix.
-
03
Refactor for readability
Refactor this [language] code for readability without changing what it does: [paste code]. Use clearer names, smaller functions and early returns where they help. List each change with a one-line reason, and point out anything you weren't sure was safe to change.
-
04
A regex with its own test table
Write a regular expression in [language or regex flavour] that matches [what to match] but not [what to exclude]. Explain each part of the pattern, then give a table of eight test strings with the expected result for each, including at least three tricky ones.
-
05
Code review with severity labels
Review this [language] change as a careful senior engineer: [paste diff]. Label each comment as blocker, should fix or nitpick, quote the line it refers to and explain the risk. End with the two comments the author should deal with first.
-
06
Screenshot to a component
I've attached a screenshot of a [form, card or page section]. Write it as a [framework] component with semantic HTML and plain CSS, keeping the spacing and hierarchy close to the original. Use placeholder text where content is unreadable, and list any interaction you had to guess.
-
07
A shell script that fails safely
Write a [bash or PowerShell] script that [task]. It should stop on the first error, check that the required tools and files exist before starting, print what it is doing, and support a dry-run flag that shows the changes without making them. Comment the lines that aren't obvious.
-
08
Walk me through a SQL query
Explain what this SQL query does, clause by clause, as if I were new to [database]: [paste query]. Then describe the result in one sentence, point out any performance problem on large tables, and suggest an index if one would help.
-
09
Make slow code faster
This [language] code is too slow for inputs of about [size]: [paste code]. Estimate its time complexity, find the step that dominates the cost and propose a faster approach. Show the improved code, explain its complexity and mention any trade-off in memory or readability.
-
10
Move a module to another language
I'm moving this module from [source language] to [target language]: [paste code]. Rewrite it the way an experienced [target language] developer would, not line by line. Afterwards, list the behaviour that could silently differ after the move, for example rounding, text encoding, null handling or exceptions, with a test for each.
-
11
Design a database schema
Design a relational schema for [application], which needs to store [entities and what users do]. Give the tables with columns, types, keys and indexes, explain each relationship, and list two queries the app will run often with how the schema supports them. Point out any decision that rests on an assumption.
-
12
Document a function
Write documentation for this [language] function in [docstring or JSDoc] style: [paste code]. Describe what it does, each parameter and its type, the return value, the errors it can raise and one short usage example. Don't describe the implementation line by line.
-
13
Get out of a Git mess
I'm stuck in Git: [describe what you did and what git status shows]. Explain what state my repository is in, then give the exact commands to reach [desired state], one at a time, with what each command does. Warn me before any command that can lose work.
-
14
Design a small HTTP API
I'm adding an HTTP API for [feature] to a [framework] backend. Propose the endpoints with methods, paths, request and response bodies, status codes and an error format. Explain how you handle pagination, validation and authentication, and note one design choice I should discuss with the team.
-
15
Learn a new language from one I know
I know [known language] well and need to start writing [new language]. Teach me the ten differences most likely to trip me up, each with a short side-by-side code example. Then give me a small exercise that uses several of them, and review my solution when I paste it.
-
16
A README from my notes
Write a README for my project [name], which [what it does]. Include a one-paragraph overview, requirements, installation and usage steps with commands, configuration options and a short troubleshooting section. Use only these details and leave clear placeholders for anything missing: [details]
-
17
Read my code like an attacker
Read this [language] code as an attacker would: [paste code]. Describe the inputs or requests you would try in order to break it, what each attempt could achieve and how likely it is to work. Then give the developer a prioritised list of fixes, with corrected code for the most serious one.
-
18
Sample records that break things
I need sample records for [entity] in [JSON or SQL] to test my [app or feature]. Fields: [fields]. Make [number] ordinary records, then a separate group designed to break careless code: missing values, extreme lengths, accented and right-to-left text, duplicates and dates at the edges of a month or year. Label why each tricky record exists.
-
19
A concept explained with runnable code
Explain [programming concept] with a short, runnable [language] example. Start with the problem the concept solves, show the example with comments, then show one common misuse and why it fails. Keep the explanation under 300 words plus the code.
-
20
Plan the split of a huge file
This [language] file has grown to [size] and mixes several responsibilities: [paste outline or key parts]. Propose how to split it into modules, an order of steps that keeps the tests passing after each one, and the risks to watch for. Give me the plan first, not all the code.
Got a question? Ask it now
No account and no download. Open the chat, type what is on your mind, and the answer starts appearing in a second or two.
Start chatting