Write a clear prompt
State the task, the context and the reason behind it, the constraints and the output - specific enough that success is checkable.
- Build a prompt from task, context, constraints and output format
- Replace vague requests with observable requirements
- Explain why giving the reason behind an instruction helps
A useful test: would a smart new colleague, with no background, know exactly what to do from your prompt? Models are in the same position - they know a lot about the world and nothing about your situation unless you say it.
Clear prompts usually cover:
- Task - what to produce, stated directly.
- Context - who it’s for, where it will be used, what’s already known. Say why a rule matters: “Keep it under 80 words because it’s shown in a phone notification” lets the model make sensible trade-offs instead of following the rule blindly.
- Constraints - length, tone, what to avoid - only those that matter.
- Output - the exact shape you need, so you can check it.
Before writing any prompt, define what success looks like and how you’ll test it (Anthropic’s guide puts this first).
Try it
Up to 15 XPPrompt duel
Each round has one goal and two prompts. Pick the one more likely to get a useful result, then read why.
1parts = {
2 "task": "Summarize the announcement in one sentence.",
3 "context": "The park opens at 7 am on Saturday.",
4 "format": "Include the opening time.",
5}
6print("\n".join(f"<{name}>{text}</{name}>" for name, text in parts.items()))<task>Summarize the announcement in one sentence.</task> <context>The park opens at 7 am on Saturday.</context> <format>Include the opening time.</format>
Key takeaways
Write for a smart newcomer: task, context and why, constraints, output.
Replace vague words (“better”, “some”, “etc.”) with observable requirements.
Define success and how you’ll test it before polishing the prompt.
Lesson quiz
6 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write Python
Write Python in the editor and run it against sample inputs. Python runs locally in your browser using a WebAssembly runtime.
Assemble a prompt from parts
Each line is field: value for any of role, context, task, format, in any order. Print the non-empty fields as <field>value</field>, one per line, in the order role, context, task, format. If there is no task, print error: a prompt needs a task instead.
- All parts, shuffled
- Empty format
- No task
Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.
Flag vague phrases
For each input line (a prompt), find the VAGUE phrases it contains as whole words, ignoring case. Print prompt N: followed by the phrases found (in the order of the VAGUE list, comma-separated), or looks specific.
- Three prompts
Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…