FMTechnical notes
Portfolio
Back to the blog

AI & Agents · Beginner · Agentic

Your first agent on a real repo: work order, task, and proof

An agent is not useful because it writes code fast. It is useful when it gets a verifiable order, touches only what it should, and leaves proof that the result works.

After reading this
  • Write a work order an agent can execute without guessing
  • Tie every task to the exact command that proves it
  • Delimit which files the agent may touch
  • Close the loop with evidence, not with a promise
01 / 04

The work order

A chat saying “fix the bug” produces a plausible answer. A work order produces a reviewable change. The difference is that the order separates what is asked from how it will be checked.

The format I use has three blocks: numbered specs, tasks with their route, and a decision log. Specs quote the request verbatim; tasks link to the spec they cover.

markdown
# fix-checkout — the coupon is not applied on the second attempt

## Specs
S1. A valid coupon discounts the total once, even if the user submits
    the form twice in a row.
S2. An invalid coupon shows "Invalid coupon" and leaves the total untouched.

## Tasks
| ID | Specs | Route  | Status  |
|----|-------|--------|---------|
| T1 | S1    | inline | pending |
| T2 | S2    | inline | pending |

## Log
L1 (request): "if I hit apply twice, it discounts twice".
02 / 04

One task, one proof

If you cannot name the command that proves a task is done, the task is not defined. The agent will complete it anyway, with an opinion instead of a fact.

A TypeScript repo needs two commands: the type check and the suite. This site adds the build and a browser suite.

json
{
  "scripts": {
    "test": "vitest run",
    "lint": "eslint .",
    "build": "next build",
    "test:e2e": "playwright test"
  }
}

# The task is done when this is green:
npm test && npm run lint && npm run build && npm run test:e2e
03 / 04

The allowed surface

An agent with access to the whole repo will “improve” files nobody asked about. The edit surface is an explicit list of paths or globs, and the agent must refuse to write outside it.

It is not bureaucracy: it is what makes the diff reviewable in two minutes.

text
## Allowed edit surfaces
src/lib/coupon.ts
src/lib/coupon.test.ts
src/components/checkout/coupon-field.tsx

## Not allowed
- package.json
- src/app/**
- any file outside the paths above
04 / 04

The full loop

The agent does not start by writing: it starts by reproducing. If it cannot reproduce the failure, it does not understand the problem. Then it changes, verifies, and reports with evidence.

The close is not “done, it works”. The close is the diff and the command output.

bash
# 1. reproduce
npm test -- coupon
# fails: expected 100, received 0

# 2. change (only inside the surface)

# 3. verify
npm test -- coupon && npm run lint

# 4. leave evidence
git diff --stat
git diff src/lib/coupon.ts
Component tree● interactive

Layout-level composition. Owns the document structure and orchestrates which features render.

Practice

Write the order before the code

Pick a real bug in your repo and write the task file: two specs quoting the request, one task table, and the exact command that proves each one. Do not write code yet.

Show a hint

If the spec cannot become an assertion, it is describing an intention rather than a behaviour.