All courses

Describing a task: goal, context, constraints, check

Write a task prompt that states the goal, the relevant files or background, the limits (don't touch X, keep the API) and how success will be checked. Explain which missing piece causes which typical failure.

Builds on: What the agent can and cannot see, The shape of a session: task to review, What agents do well and what they do badly

Read it card by card Start the whole course

“Fix the date bug” and three surprises

Your app exports a report as a CSV file. The dates in it come out as `03/04/2024` (4 March), and you want `2024-03-04`. You type: ▸ You: fix the date bug The agent reads several files. It edits the date code for the *on-screen* report, renames a few things along the way, and replies: ◂ Agent: Fixed the date formatting. You open the CSV. It still says `03/04/2024`. What went wrong?

Every gap you leave gets filled with a guess

The agent knows only what is in its context. Your four words left four gaps, and it filled each one with a guess. *Which bug?* It picked one. *Where?* It searched and found the screen code first. *What may change?* You didn't say, so tidying looked helpful. *When is it done?* When the code looked right, because you gave it no way to check. Each guess was plausible. Together they missed your intent.

Four parts, four typical failures

A task prompt has four parts. Each missing part causes its own failure: - **Goal**: the outcome you want, concrete and observable. *Missing:* it solves a different problem. - **Context**: the relevant files, error text and what you already know. *Missing:* it looks in the wrong place or acts on a wrong assumption. - **Constraints**: what must not change, e.g. “only edit this file”, “keep what this function returns”, “no new libraries”. *Missing:* extra changes you didn't want. - **Check**: how success will be shown. *Missing:* it stops when the change merely *looks* done.

Rebuilding the date request

Map each failure back to its gap. - It fixed the wrong dates, so the **goal** now names the CSV and the exact format. - It looked in the wrong place, so the **context** names the file and says the screen is already right. That rules out the wrong fix. - It renamed things, so the **constraints** limit edits to one file. - It said “fixed” without proof, so the **check** asks for real output that you can read too.

The same request, all four parts

A complete prompt can still be short. What matters is that none of the four parts is missing. Labels such as `Context:` are optional, but they make it easy to see that nothing was skipped.
▸ You: Goal: in the CSV export, dates
should be 2024-03-04, not 03/04/2024.
Context: the CSV rows are built by
format_row() in src/export.py. The
on-screen report already shows dates
correctly; only the CSV is wrong.
Constraints: only edit src/export.py.
Keep the column order. No new
libraries.
Check: run python src/export.py and
paste the first 3 rows it writes.

Goal, context, constraints, check

Each part you skip becomes a gap the agent fills with a guess. No goal: it solves the wrong problem. No context: it works in the wrong place. No constraints: it makes changes you didn't want. No check: you get a “done” you can't trust.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.