How to Write a Prompt That Actually Helps
A good prompt is not a magic phrase. It is a clear request. I write software, automation and electronics projects for a living, and I use assistants almost every day. The pattern that helps me is simple: say what you wan
A good prompt is not a magic phrase. It is a clear request. I write software, automation and electronics projects for a living, and I use assistants almost every day. The pattern that helps me is simple: say what you want, say how it should look, give the context the model cannot see, and then correct the first draft instead of starting over.
Official prompting guides say much the same thing. OpenAI's prompting documentation is built around clear instructions, examples, and giving the model enough structure to finish the job. Anthropic's prompt-engineering overview makes the same point in slightly different words: be explicit about the goal, the constraints, and the output format. You do not need a secret prefix.
A practical framework I actually use
I keep a short checklist next to the chat box. If a task matters, I fill it in before I press Enter.
- Goal. What should I have in my hands when this is done, and who is it for?
- Format. A list, a table, a commit message, a polite email, a JSON object, a 200-word explanation?
- Constraints. Length, language, tone, libraries I am allowed to use, things to leave out.
- Context. The facts the assistant cannot see: the error message, the file names, the battery voltage, the audience, the deadline.
- Example. One short sample of a good answer, if I have one.
- Check. If the first reply is almost right, I say what to change. I do not throw the whole prompt away.
That is the whole method. The rest of this article is just how those six lines look in practice.
A weak prompt, then a better one
Here is a request I used to write, and still catch myself writing when I am in a hurry:
Write a Python script that reads a CSV and sends emails.
It is not wrong. It is just unfinished. The assistant has to invent a library, a column layout, a mail server, an error policy, and a tone. You will spend the next ten messages unsaying things it guessed.
Here is the same task, written as a prompt I would actually send:
Goal: a small Python 3 script I can run from the command line to send
a reminder email to people listed in a CSV file.
Format:
- one .py file
- use the standard library only (csv, smtplib, argparse, pathlib)
- print a one-line summary at the end: sent / skipped / failed
Constraints:
- do not send anything when --dry-run is set; only print what would be sent
- skip rows with an empty email field and count them as skipped
- do not invent SMTP credentials; read host, port, user and password
from environment variables
- keep comments to a minimum
- I will review the message body before I ever run this without --dry-run
CSV columns: name, email, due_date
Email subject: "Reminder: your item is due on {due_date}"
Body: short, polite, plain text, in English.
Please show the script first, then a short example of how to run it.
The second prompt is longer, but it removes most of the guessing. The first answer is usually close enough that I only have to adjust a few lines.
Put the goal in the first line
Models pay attention to the beginning of a prompt. I start with the outcome, not the backstory.
- Weak: "I have been thinking about rewriting our onboarding email and maybe you can help."
- Better: "Write a 120-word onboarding email for a new freelance client. Tone: calm, direct, no marketing slogans. Include: what happens this week, when I will send the first draft, and how to reach me."
If the task has a reader, I name the reader. "Explain this circuit to a computer science student who has not done much analogue work" produces a different answer than "Write this up for a hardware engineer who already knows the parts."
Say the format, or you will get an essay
If I need a table, I say "a markdown table with these columns." If I need a git commit message, I say "one subject line under 72 characters, then a short body." If I need code, I say which language and which libraries are allowed.
This is also where I stop the model from padding. "No preamble. No 'hope this helps'." is a dull instruction, but it saves me a cleanup pass.
OpenAI's own guidance has said for years that you should be specific about length, format and style, and that examples help more than adjectives. I have found that to be true.
Give context the model cannot see
An assistant does not see your desk, your repository, or your last email. If you leave those out, it will fill the gaps with something typical, which is often wrong for your case.
For code, I paste the error, the function, and the versions. For electronics, I state the supply voltage, the load, and whether this is a prototype or a device that has to run for months on a battery. For writing, I state what must not be claimed — no invented clients, no invented benchmarks, no private details.
I also say what to do when the context is missing: "If a fact is not in the text I pasted, say you do not know. Do not invent a citation."
Use an example when the shape matters
One short example is worth a paragraph of style notes. If I want a changelog written a certain way, I paste two real lines from an old changelog and say "match this shape." That is few-shot prompting, and it is ordinary engineering, not a trick.
Keep the example small. A huge example buries the actual task.
For a hard task, ask for steps, then the answer
If the job is a refactor, a diagnosis, or a design choice, I ask the assistant to work through the problem in short steps and only then give the final answer. OpenAI has long recommended giving the model time to work out a solution instead of jumping to a conclusion. Anthropic's guides similarly suggest breaking complex work into stages.
I do not always need to see the reasoning in the final document. Sometimes I say: "Think the options through first. In the final answer, give me the recommendation and the two main risks."
Correct the draft. Do not start from zero
The first reply is a draft. If it is 80 percent right, I reply with the 20 percent that is wrong: "Keep the function, but drop the extra class. Use argparse instead of hard-coded paths. The CSV has a header."
Starting a brand-new chat is useful when the thread has become messy. It is not useful when you only need a small correction.
What I do not bother with
I ignore lists of "secret codes," magic roles, and copied jailbreaks. They age badly, they often do not do what the post claims, and they teach the wrong habit: looking for a hidden switch instead of stating the task. If a product has a useful feature — custom instructions, projects, temporary chats, a system prompt in an API — use the official feature. I will write about those separately.
I also do not pretend that a perfect prompt removes the need to check the result. Assistants still invent function names, paper titles and confident explanations. A clear prompt reduces the mess. It does not replace a review.
A short template you can copy
Goal: [what I need, and who it is for]
Format: [list / table / code / email / length / language]
Constraints:
- [must include]
- [must avoid]
- [tools or libraries allowed]
Context:
- [the facts, errors, or files the model cannot see]
Example (optional):
[one short sample of a good answer]
Process: if the task is complex, work through it in steps.
If something is unknown, say so instead of guessing.
Now do the task.
Fill it in, send it, and then edit the reply. That is enough. Clear instructions still beat clever phrasing.
I'm Saulius, an independent full-stack, automation and electronics developer in Kaunas, Lithuania. You can also find me on Dev.to and LinkedIn.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.