Writing better prompts
A good prompt names the role, gives context and constraints, shows examples, and asks for a plan before code.
- State a role, a goal and concrete constraints.
- Provide the smallest context that contains the answer.
- Give an example of the exact output you want.
- Ask for a plan and assumptions before large changes.
In plain English
Writing a better prompt means telling the model who it should act as, what you want, what limits it must follow and what shape the answer should take. Context is the specific information you give it, and providing the smallest relevant context keeps the answer focused and inside the context limit. Examples are one of the strongest signals you can send, because they show the exact pattern you want instead of describing it in words. For any task larger than a small edit, ask the model to write a plan first so you can correct its understanding before it writes code. If your request is ambiguous, ask it to list the assumptions it made so you can catch wrong guesses early.
Step by step
- 1Rewrite a vague request as a role plus a goal.
- 2Cut the context down to only what the answer depends on.
- 3Add one example showing the output format you expect.
- 4For a multi-step task, ask for a plan before any code.
- 5Ask the model to list assumptions when the requirement is unclear.
Role: a careful TypeScript reviewer
Goal: find bugs in the function below
Context: runs in Node 22, no framework
Constraints:
- no style suggestions yet
- at most 5 findings
- do not invent APIs
Output: JSON array of {line, issue, severity}
If anything is ambiguous, list your assumptions first.Common mistakes
- Leaving the role and constraints out invites a generic answer that ignores your real situation.
- Pasting a huge codebase without focus wastes the context limit and buries the relevant part.
- Asking for the best solution without examples gives you a vague answer you cannot judge.
- Skipping the plan step on a big task lets the model guess your intent and run far in the wrong direction.
Upgrade a vague prompt
Take the starter prompt and add a role, one constraint, and an output format. Keep it under five lines.
Help me with my React app.Which part of a prompt most reliably steers the output format?
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Lock in what you just learned.
Mark this lesson complete to save your place and move one step closer to the certificate.