How to write prompts for code that get you useful results

The model does not know what you want until you tell it. Most weak results come not from a weak model but from an under-specified task.
1. Give context and a goal
Write which language and framework you work in, what already exists in the project and why the new feature is needed. The goal matters more than the method: "the user should be able to sign up for the newsletter" says more than "add a form".
2. State the constraints
If you do not want new dependencies, do not accept changes to the file structure or the code has to run on an older version of the environment, say so outright. The model happily adds libraries nobody asked for.
3. Work in small steps
Instead of one huge instruction, split the work into stages that can be checked separately. It is then easier to find the moment when something broke.
4. Plan first, then code
For bigger tasks, ask for a short plan of changes and approve it before the model starts writing. Fixing a plan is cheaper than fixing three hundred lines of code.
5. Describe how you will know it works
Acceptance criteria, examples of input data and expected results, and ideally a request for tests. A model that knows how it will be judged writes more precisely.
Example
Instead of "make a to-do list page", try something like this:
When something does not work
Paste the full error message, not a summary of it, and write what changed right before it appeared. If after three attempts the model keeps going in circles, start a new conversation with a short summary of the problem. A tangled context does as much harm as a missing one.


