20 coding prompts that stop the AI guessing
Most bad AI code comes from the model filling in gaps you left. Each prompt here closes one: the model reads before it writes, tests before it fixes, and ranks its guesses out loud.
Swap anything in [brackets] for your own code, error or goal.
01. Map the blast radius before you touch anything
Before changing code you did not write.
Read the code below. Do not write or change any code yet. Tell me: 1. What it does, in three sentences or fewer. 2. Every assumption it makes about its inputs, its callers and its environment. 3. What would break if I [describe the change you want to make], and where. If you need to see another file to answer, name the file and stop. [paste the code]
02. Rank the causes before anyone writes a fix
A bug you cannot explain yet.
Here is an error and the code around it. List the three most likely causes, most likely first. For each one, give me the single log line or test that would confirm it or rule it out. Do not propose a fix. I will run the checks and tell you which cause it was. Error and stack trace: [paste the error] Code: [paste the relevant code]
03. Write the failing tests, then stop
Before you ask for new code or a fix.
Write tests for [function or feature] using [test framework]. Cover the normal case, these edge cases: [list any you already know], and at least two cases you think I have not considered. Say in one line why each of those two matters. Every test should fail against the current code or a missing implementation. Do not write the implementation.
Unlock the other 17 prompts for free
Sign up for the Whizi newsletter to read the rest of this pack.
- Review the diff as the person who gets paged
- Refactor without changing a single behavior
- Pick the five files to read first
- Write the query against your real schema
- Get a regex with the cases that prove it
- Port code so it reads like a native wrote it
- Find where the time goes from a real profile
- Trace untrusted input from source to sink
- Write the README a stranger can use
- Write the commit message from the diff
- Learn a concept using your own code
- Design the API, then attack the design
- Plan a migration that never takes the site down
- Make the model ask the questions
- List the inputs that will break it
- Find what a dependency upgrade breaks in your code
- Ask a second model to grade the first