Structured Prompt Construction
also known as CO-STAR, component-based prompting, prompt scaffolding
Build a prompt from named parts instead of one blob of text. Name the role, the context, the task, the examples, and the exact output format, and wrap each part in a tag so the model can tell them apart. A prompt with labelled parts is easier to read, test, and fix than a wall of instructions, and it is far easier to change one part without breaking the rest.
Methodology process overview
Intent. Compose a prompt from explicit, labelled slots so each part can be read, tested, and changed on its own.
When to apply. Use this when a prompt is doing real work and has grown past a sentence or two. It pays off most when output format matters, when several people edit the same prompt, or when the same prompt must run on varied inputs. Don't apply it to a trivial one-line ask; that does not need slots.
Inputs
- Task definition — What the prompt must accomplish, stated plainly enough to put in one slot.
- Context and constraints — The background, audience, and rules the model needs but should not have to guess.
- Two or three examples — Worked input-output pairs that show the format and tone better than instructions can.
- Output contract — The exact shape the downstream code or reader expects, ideally a schema.
Outputs
- Slotted prompt — A prompt split into labelled, tagged sections: role, context, task, examples, output format.
- Reusable template — The structure left behind, ready to be re-filled for the next similar task.
Steps (6)
Name the role
Open with a one-line role that frames the task, for example a contracts analyst or a senior reviewer.
State the task and context
Put the task in its own slot and the background, audience, and constraints in another. Do not mix them.
Show two or three examples
Give worked input-output pairs. Examples teach format and tone faster than prose rules.
usesChain of Thought
Pin the output format
State the exact output shape the downstream consumer needs, as a schema where possible.
Wrap each part in tags
Wrap role, context, task, examples, and output in named tags so the model and any tooling can tell the parts apart.
Ask for reasoning before the answer
When the task needs thought, request the reasoning in a separate tag that comes before the final, parseable answer.
Framework-specific instructions
Pick a framework and generate a framework-targeted rewrite of this methodology's steps.
Choose framework
AI-generated for Agent Development Kit (ADK) (Google) — verify against official docs.
Principles
- One slot holds one kind of thing; do not let context absorb everything.
- Show examples instead of writing longer instructions.
- Pin the output as a schema, not a polite request for JSON.
- Tags are for the model and for tooling; keep them consistent.
Known failure modes (2)
Related patterns (4)
- ★★Structured Output
Constrain the model's output to conform to a JSON Schema (or similar typed shape).
- ★★Chain of Thought
Elicit multi-step reasoning by prompting the model to produce intermediate steps before its final answer.
- ★★Prompt Chaining
Decompose a task into a fixed sequence of LLM calls where each step's output becomes the next step's input.
- ★Own Your Prompts (12-Factor Agents)
Every prompt in a production agent is versioned, tested, and owned by the team in the application repo — never inherited as a framework default.
Related methodologies (1)
Sources (2)
Provenance
- Added to catalog:
- Last updated:
- Verification status: partial