How to Structure a Prompt (Template)
The building blocks of a strong prompt — role, context, task, constraints, output format, and examples — with a reusable template.
Direct answer
A strong prompt has six parts: a role, the context the model needs, one clear task, explicit constraints, the exact output format, and an example or two. Give the model a role, supply the context, state a single task, list constraints, define the output format, then show an example. The optimizer assembles these from a rough idea.
Open the Prompt OptimizerWhen to use this
- Your prompts are one line and the output is inconsistent.
- You want a reusable template instead of rewriting from scratch each time.
- You are building a prompt to reuse or share.
Steps
- Set a role: You are a senior technical writer.
- Give context: the audience, the source material, and any constraints.
- State one task in a single sentence.
- List constraints: length, tone, what to avoid.
- Define the exact output format (list, table, JSON, sections).
- Add one example of the input and the ideal output, then optimize.
Example
write release notes
You are a release manager. Context: I will paste a list of merged pull requests. Task: Write user-facing release notes from them. Constraints: Group by Added, Fixed, Changed. One line each. No internal jargon. Output format: Markdown with an H2 per group and bullet points. Example input: "Fix login redirect" -> Fixed: - Login now redirects correctly.
Common mistakes
- Skipping the output format is the top reason outputs vary run to run.
- Cramming several tasks into one prompt; split them or chain the prompts.
- Vague roles like 'be helpful' add nothing; name real expertise and audience.
FAQ
- What are the parts of a good prompt?
- Role, context, a single task, constraints, the exact output format, and one or two examples. Missing the output format and constraints is what makes results inconsistent.
- Do I need all six parts every time?
- No. Simple tasks need fewer. But adding an explicit task, constraints, and output format reliably improves results even for short prompts.
- How is this different from reviewing a prompt?
- This is about building a well-structured prompt. If you already have a prompt and want it critiqued, use the prompt reviewer instead.
Related prompt guides
Related Prompt Optimizer guides
Write a Prompt From a Rough Idea
Turn a one-line idea of what you want into a full, ready-to-paste structured prompt.
Few-Shot Prompting: Add Examples to Your Prompt
Show the model one to three input-output examples so it copies the pattern you want.
Chain-of-Thought Prompting: Ask for Step-by-Step Reasoning
Prompt the model to reason step by step to improve accuracy on multi-step math, logic, and planning tasks.
Role and Persona Prompting (Act As)
Assign the model a role or persona to control tone, depth, and vocabulary in its answers.
Control the AI Output Format (JSON, Tables, Lists)
Get consistent, parseable output by specifying the exact format, fields, and what to exclude.