Prompt Basics: Write Clear Instructions for an LLM
A prompt is the text you give a language model. Because the model continues text based on everything in its context, the quality of the prompt strongly shapes the quality of the answer. There is no secret phrasing; good prompts are simply clear instructions, the kind you would give a capable colleague who knows nothing about your situation.
Five ingredients
- Task: what you want, stated directly. "Summarize this bug report" beats "Thoughts?".
- Context: what the model cannot know: who the audience is, what the text is for, what has been tried.
- Constraints: length, tone, reading level, things to avoid.
- Output format: a bulleted list, a table, JSON with named fields. Saying exactly what you want is easier than cleaning it up later.
- Examples: one to three input/output pairs. This is called few-shot prompting, and it is often the fastest way to show a pattern that is hard to describe.
Put long material, such as an article to summarize, in a clearly marked block so the model can tell instructions from data.
Building prompts in code
Applications usually assemble prompts from a template plus data. The example builds a vague prompt and a structured one for the same job, then a few-shot prompt for classifying support tickets. It only prints the prompts; sending them to a model would need a provider's API and key.
Expected output
=== vague (18 words) Thoughts? Users report the app logs them out after 5 minutes on iOS 17. Started after release 2.3. === structured (56 words) Task: Summarize the bug report below for a non-technical manager. Context: The manager decides whether to delay the next release. Constraints: 3 bullet points, plain English, no jargon. Format: Start each bullet with "- ". Bug report: """ Users report the app logs them out after 5 minutes on iOS 17. Started after release 2.3. """ === few-shot (33 words) Classify each support ticket as billing, bug or other. Ticket: I was charged twice Category: billing Ticket: The app crashes on start Category: bug Ticket: How do I change my email address? Category:
The structured prompt is longer, but every line removes a guess the model would otherwise have to make.
Iterate and check
- Iterate: if the answer misses, ask what was ambiguous and fix the prompt, rather than piling on capital letters or "please".
- Ask for reasoning or sources when you need to verify the answer, and then actually verify it.
- Check everything that matters: facts, numbers, links and code. A confident tone is not evidence. Run generated code and tests before trusting them.
Safety basics
- Do not paste secrets, passwords or personal data about other people into a prompt unless your organization's policy explicitly allows that service.
- Text from outside sources (web pages, emails, uploaded files) can contain instructions of its own. Applications that feed such text to a model should treat it as data and limit what the model is allowed to do with it. This risk is known as prompt injection.
Summary
- State the task, context, constraints and format; add examples for patterns.
- Separate instructions from the material being processed.
- Verify outputs, and keep secrets out of prompts.
Quiz: Prompt basics