All courses

Set up a task an agent can finish well

Decide whether and how to delegate a real request, then turn it into a well-sized task: a clear goal and acceptance test, the right context, a plan step, explicit guardrails and small checkable increments. Explain which failure mode each element prevents.

Builds on: Choose what to hand to an agent, Write a task the agent can finish, Give the context it can't find, Size tasks so each step is checkable, Ask for a plan before code, Give it an executable definition of done, Rule out shortcuts explicitly

Read it card by card Start the whole course

A ticket you're about to paste in

A ticket lands: *"Orders export: add a status filter so support can pull refunded orders. Also tidy up `export.py`, it's a mess."* You could paste it straight to the agent. Ten minutes later it would come back green, with a confident summary. What would you add or remove first, so the result is something you can check and trust?

Setup closes gaps before the agent guesses

The agent works toward what it can see: your words, the files it opens, and signals like *tests green*. It fills every gap in the ticket with a plausible guess: what "tidy" means, which helper to use, what counts as done. **Later cost:** one big mixed diff. A behaviour change hides inside the tidy-up, and the filter is checked only by tests the agent chose.

Six setup moves and what each prevents

1. **Decide:** rate each part on verify cost, unwritten context, reversibility and security. Keep or split the parts that rate badly → prevents *delegating what nobody can check*. 2. **Goal, reason, non-goals** → prevents *guessed intent*. 3. **Red, protected test** → prevents *gaming the proxy signal*. 4. **Context** (files, helpers, commands) → prevents *reinvented code and unrun checks*. 5. **Plan first** → prevents *wrong assumptions found late*. 6. **Guardrails + slices** → prevents *workarounds, drift and huge diffs*.

The ticket, set up

"Tidy up" has no check and could change the output, so you split it off and don't delegate it now. The filter is local, testable and reversible, so you delegate it. The brief gives: - the goal and why: support needs refunded-only exports - non-goals: no column changes, no refactor - context: reuse `parse_status()` in `orders/status.py`; run `pytest tests/export` - done: the red tests on the next card, which it must not edit - first a plan, then wait - slice 1 the function, slice 2 the CLI flag - stop and report if blocked

Done is written before the agent starts

These two tests are the definition of done. You write them before any code exists. - `test_filters_by_status`: done means only order 2, the refunded one, comes back. - `test_unknown_status_is_rejected`: a typo like `refundd` must fail loudly. Without this test, a typo could quietly return an empty export while the suite stays green. Then take three steps: 1. Run them and see red: `TypeError`, because `status` isn't a parameter yet. 2. Commit the file. 3. Tell the agent the file is read-only. **Afterwards, check:** `git diff <that commit> -- tests/export/test_status_filter.py` shows nothing.
// Python
# tests/export/test_status_filter.py
# db: test-database fixture the project already provides
import pytest
from orders.export import export_orders

def test_filters_by_status(db):
    db.add_order(id=1, status="paid")
    db.add_order(id=2, status="refunded")
    rows = export_orders(db, status="refunded")
    assert [r["id"] for r in rows] == [2]

def test_unknown_status_is_rejected(db):
    with pytest.raises(ValueError):
        export_orders(db, status="refundd")

Every element closes one gap

First decide what to hand over at all. Then give the agent: - a goal with its reason and non-goals - a red, protected test - the context it can't find - a plan checkpoint - explicit rules - small slices Each one closes a gap the agent would otherwise fill with a confident guess.

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.