Writing Prompts as Contracts
Understand how to write AI prompts not as open-ended messages but as precise contracts that define tasks, scope, and escalation triggers. This lesson helps you create prompts that produce consistent, structured responses essential for reliable AI feature development.
We’ve now scoped an AI feature end-to-end. This chapter moves to actually building it, and the first skill is writing the prompt itself. If we’ve never called a model API before, this is where that starts. If we have, the more useful shift is treating a prompt as something we design, not something we type into a chat box.
In this lesson, we will cover:
What a prompt is, and the two kinds of messages that make one up
Why a prompt written like a conversation breaks the code that depends on it
What actually belongs in a prompt written as a contract
How the support-summarizer’s own prompt, from earlier in this course, is built exactly this way
How the same precision shows up in real products
The three ways engineers get this wrong
What a prompt actually is
A prompt is the text we send a model; the response is the text it sends back. Here’s the smallest complete version of that exchange, running on Groq’s free API the way every code example in this course does:
Line 1: We import the Groq client. ... ...