Clear Instructions and System Prompts
The basics that fix most bad outputs: be specific, give context and constraints, define the audience and format, and use the system prompt well.
Beginner · about 4 hours · difficulty 2/5
Learn first: Messages APIs and Provider SDKs
A prompt is a specification written for a very capable colleague who knows nothing about your project. Most "the model is dumb" problems are really "the prompt was vague" problems.
What a good prompt contains
- Role and context: who the assistant is, who the user is, what product it lives in.
- The task: stated directly, with the goal behind it. Explaining *why* helps the model generalize.
- Constraints: length, tone, what not to do, what to do when information is missing.
- Output format: headings, JSON, bullet points, or plain prose. Show it.
- Inputs clearly separated from instructions.
The system prompt
Use it for stable behaviour: persona, rules, policies, formatting defaults, tool usage guidance. Put per-request data in the user turn. Keep it organized; long system prompts are fine, messy ones are not.
Habits that work
- Tell the model what to do rather than only what not to do.
- Give an explicit escape hatch: "If the answer is not in the documents, say you do not know."
- Iterate against a set of test inputs, not a single example. A prompt that works once may fail on the fifth input.
- Modern models follow instructions literally; if you want thorough or creative output, ask for it.
Good enough to move on
You can take a weak one-line prompt, rewrite it into a structured specification, and show improved results across at least ten test inputs.
Key concepts
- Role, context and goal
- Constraints and output format
- System vs user prompt content
- Escape hatches for missing info
- Positive instructions over prohibitions
- Prefilling the response: Supported by some APIs
Mini project
Write a system prompt for a college placement FAQ assistant, test it against 15 realistic student questions including ones it should decline, and iterate until all answers meet your checklist.
Check yourself
Why does explaining the reason behind an instruction often produce better results than stating the rule alone?
Free resources
- Anthropic prompt engineering overview (Anthropic)
- OpenAI prompt engineering guide (OpenAI)
- Prompt Engineering Guide (DAIR.AI)