A six-part engineering guide: from individual prompts to specification-driven probabilistic software.
Read: Prompt engineering is becoming programming →Control flow: how work moves through a prompt system
Six control-flow patterns from chaining to agents, and a map of twenty programming principles translated into prompt systems.
How work moves through a prompt system
Six patterns cover most systems. The first five are workflows: paths controlled by code. The sixth hands the next-step decision to the model.
Use when a task has clear sequential stages, each step depends on the previous result, and intermediate results can be validated.
Use when different request types need different workflows, or a cheaper, safer path can be selected. Not every message requires an agent.
Use when subtasks are independent and results can be merged or compared.
Use when subtasks must be created dynamically and a central component coordinates ownership.
Use when quality can be measured, results can be repaired iteratively, and external tests or graders exist.
The model dynamically chooses what to do next, which tool to call, whether to decompose or repair, and when it believes the task is complete.
A predefined path controlled primarily by code. The model fills in steps; code decides what happens next.
A model-driven loop in which the model dynamically decides the next action within declared boundaries. Never use the two words as synonyms.
Six patterns cover almost every system, and five of them are ordinary workflows controlled by your own code. Agents hand the next-step decision to the model, which makes them the most flexible and the least predictable choice, with the widest spread in cost and latency. The same feature can differ by an order of magnitude in running cost depending on which pattern it uses, and the cheaper patterns are usually easier to test and explain to auditors.
Modern programming principles, transferred
Twenty established software-engineering concepts, and what each becomes in a prompt-based system.
Each row in this table maps an established engineering concept onto its prompt-system equivalent. Read together, they say something useful for staffing: reliable AI features are built by experienced engineers applying familiar ideas, such as types, contracts, transactions, idempotency and observability, to a probabilistic component. The failure pattern is the opposite, a team that treats prompting as a separate craft and rediscovers thirty years of software engineering the expensive way.
More articles
Design reliable UX for connected devices across hardware, apps, BLE, Wi-Fi, cloud, onboarding, errors, and recovery.
Read: UX for Connected Devices: Designing Experiences Across Hardware, Apps, Connectivity, and Cloud →Hardware companion apps: hard parts, partner skills, and questions that separate specialists from agencies.
Read: How to Choose the Right Companion App Partner for Your Hardware Product →