Prompt architecture: role, state, task

The three-part structure behind prompts that behave predictably, and the two failure modes that cause most bad output.

Prompt engineering gets mistaken for creative writing. In production it is closer to control flow: you are programming a non-deterministic system in natural language, and the parts that make it reliable are the parts that constrain it.

A robust prompt is not a sentence, it is a structured object with three jobs. It assigns a role, it defines state, and it specifies the task. Each one fails in a characteristic way when you skip it.

The role is a compute node, not a personality. "Act as a coder" is noise, because it narrows nothing. "You are a senior systems architect working in Rust, who prioritises memory safety and is hostile to technical debt" narrows a great deal: it tells the model which trade-offs to make when two valid answers are available. That is the only thing a role is for.

State is the context the model does not have. It has no knowledge of your business logic, your naming conventions, or the decision someone made six months ago that explains the odd shape of a module. Inject that deliberately, and inject it in a structure the model can parse. Delimited blocks - XML tags, fenced sections, labelled headings - stop context bleeding into instructions, which is the most common cause of a model answering a question you did not ask.

The task is where most prompts collapse, because they describe a thing rather than a finished state. "Write a login form" has no acceptance criteria, so the model invents them and you spend the next hour discovering which ones it chose. "Write a login form that validates on blur, shows one error at a time, keeps the submit button reachable by keyboard, and returns a typed result" can be checked. If you cannot write down how you would know the output is correct, the model cannot either.

Two failure modes account for most bad output. The first is a prompt with no stated standard, and a model given no standard produces an average one. The second is three requests in one sentence, where the model answers whichever it noticed first and silently drops the rest. Both are fixed by writing less ambiguously, not by writing more.

Treat prompts as artefacts rather than as messages. A prompt that works belongs in version control next to the code it produces, with a note on what it was for. Teams that do this stop rediscovering the same technique every few weeks, and start improving on it instead.

How this was tested

The structure was applied across repeated builds in the public prompt builder and checked against which prompts required the fewest corrective follow-ups.

Written by Rob Larry, reviewed by Vibe Editorial. Tested 2026-09-09.

Evidence

  • Applied structure: The role, state and task pattern is the one the public prompt builder asks its questions in.

Open the builder used for this page

Related