Methodology · Prompt Engineeringprovenpartial

Structured Prompt Construction

also known as CO-STAR, component-based prompting, prompt scaffolding

Applies to: llm-appagentcoding-agentextraction-task

Tags: prompt-engineeringstructuretemplates

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 definitionWhat the prompt must accomplish, stated plainly enough to put in one slot.
  • Context and constraintsThe background, audience, and rules the model needs but should not have to guess.
  • Two or three examplesWorked input-output pairs that show the format and tone better than instructions can.
  • Output contractThe exact shape the downstream code or reader expects, ideally a schema.

Outputs

  • Slotted promptA prompt split into labelled, tagged sections: role, context, task, examples, output format.
  • Reusable templateThe structure left behind, ready to be re-filled for the next similar task.

Steps (6)

  1. Name the role

    Open with a one-line role that frames the task, for example a contracts analyst or a senior reviewer.

  2. State the task and context

    Put the task in its own slot and the background, audience, and constraints in another. Do not mix them.

  3. Show two or three examples

    Give worked input-output pairs. Examples teach format and tone faster than prose rules.

    usesChain of Thought

  4. Pin the output format

    State the exact output shape the downstream consumer needs, as a schema where possible.

    usesStructured Output

  5. 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.

  6. 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)

Related methodologies (1)

Sources (2)

Provenance

  • Added to catalog:
  • Last updated:
  • Verification status: partial