---
name: build-draft
description: Write a new Introspection agent (Recipe) from its approved cases, locally, and smoke-test each case with a local task until it works. Use when the cases in evals/cases/ are approved and the Recipe isn't written or doesn't pass yet.
metadata:
  min-cli-version: "0.89.0"
  next: "build-review"
---

# Build: draft

Write the Recipe and its design on `pr/<name>`, locally, then run each approved case as a local task until it works or each remaining failure is explained. Build writes no evals: improve writes the checks, from these cases and from real conversations.

The owner isn't needed here, except when a case itself turns out wrong or ambiguous: then propose the change and review it with the owner, as `eval-case` says. Never edit an approved case or clear its approval yourself.

## Before you start

- **Tools:** the `introspection` CLI and Pi. No login.
- **Work in brainstorm's repository,** on its `pr/<name>` branch. Read `docs/DESIGN.md` Part A and every case in `evals/cases/` first. If a case isn't approved, stop and go back to `build-brainstorm`.
- **Build only the agents with approved cases.** Another agent the brief names goes back to brainstorm for its own cases, or waits; don't ask about it or draft it here.

## 1. Choose capabilities

For each case, pick what it needs from [the capabilities that exist](references/capabilities.md); cases needing no tools, documents or connections skip this and step 2. Write custom code only where no capability covers a case, and say so in the design. A missing tool is fixed with a tool, not a longer prompt.

## 2. Give the agent its data without real credentials

Decide which servers to fake, how much, and what Part B reports, as [build's decisions about fakes](references/fakes.md) say. Build the fakes as `eval-simulate` says, write each as its `write` reference says, and bind them as [the Recipe layout](references/recipe-layout.md) says, so a local task reads them. Case inputs are read by hash; never commit a client's file.

## 3. Write the design and the Recipe

Write Part B of `docs/DESIGN.md` with [the design template](references/design-template.md): each behaviour cites the cases that need it, and anything no case needs is cut. Then write what it calls for as [the Recipe layout](references/recipe-layout.md) and [what every Recipe gets right](references/writing.md) say, including the owner's exact values and standing knowledge; for Word or PDF, [documents](references/documents.md).

- **The model:** replace the template's placeholder with the model brainstorm recorded, one this machine has credentials for, and record it in Part B.
- **Every tool you list must exist in the installed runtime.** `introspection check` doesn't verify tools; only a run does. If a capability isn't installed, use its fallback and say so in Part B.
- **Keep test details out:** nothing specific to a sample input (a party name, a file path).

Then check it and commit it:

```sh
introspection check
git add <the Recipe's files> && git commit -m "feat: <what the agent does>"
```

- **`check` still fails after one fix:** tell the owner what fails and what you tried. Never get past it by removing something the design approved (a skill, a tool, a case).

## 4. Smoke tests, review and deploy, at once

Once `check` passes and the Recipe is committed, in one turn and without waiting for any of them:

- **Smoke tests:** run every case as a local task, its request in its exact words, as [running the cases](references/running-cases.md) says: a `code` case with a `smoke-tester` subagent ([brief](../../agents/smoke-tester-brief.md)), all at once, and a `person` case with a `case-runner`, four at a time.
- **Review:** start it as `build-review`'s "Review with fresh context" says.
- **Deploy:** with the owner's go-ahead from brainstorm, go on with `deploy-connect` and `deploy-create` now: push and create the runtime before reading any result. Once the smoke tests and review pass, hand over the chat link: `introspection open --runtime <slug> --print`.

Never `sleep` to wait: deploy is the work meanwhile. Then collect each smoke tester's verdict, read any failing run yourself, and record each case as passing or failing with its reason.

- **Never produce the agent's output yourself.** A script you run is not the Recipe, and its result proves nothing about the agent.
- **The run fails before the agent runs:** stop and tell the owner what failed and what you need. Never fix the machine yourself: don't run `introspection setup` or `upgrade`, and don't change Pi's settings.

## 5. Fix what fails

Read what a run did before changing anything. **Name the cause before each fix,** from the run's events, and fix the part that owns it rather than adding instructions on top ([common failures](references/failures.md)). Don't reword instructions after each output to steer the next run.

- **One run per change.** Commit the fix, push it when deploy has, then run the failing cases once more, each in a new folder. Push a `docs/`-only commit with the next agent change. Never run an unchanged commit again to confirm a result.
- **Never weaken the agent to get a run through:** keep the designed model, thinking level and instructions. Speed and cost are optimize's job.
- **A partial result beats none.** When a tool refuses part of the work, the agent does the rest and reports what it couldn't do. Stopping with no output is a failure, unless a case says to stop.
- **A missing capability:** stop and say so in Part B and the pull request instead of spending fixes on settings.
- **Three fixes to the same problem** and the Recipe still can't run: stop and record why in Part B.

**The owner's real document must work;** synthetic excerpts lack its structure (fields, bookmarks, tracked changes, tables). Ask for a sample by naming its case and the input that case brings, in the owner's words. A different kind of input: say how it differs and ask for the right one; it becomes a new case only if the owner asks, approved as in brainstorm.

## 6. Show the owner

Show the result on the owner's sample with `show_artifact` in one line, and carry on without asking: what they say about it becomes cases. Never change the Recipe against the approved brief to improve how a result reads: that's the owner's call. Run what else they want to try, as [with the owner](references/running-cases.md#with-the-owner) says; never ask them to run a command.

For `person` cases, review the runs' transcripts with `review_artifacts`, labelled by case, before build-review: an approved transcript is the person's check. Ask only about a run of the Recipe as it is now; after a change, run the case again first.

## 7. Commit and hand over

Commit to `pr/<name>` with the case results in the commit message: passed, or failed with its reason.

## What not to do

- Don't change a case to make it pass. Raise one that looks wrong in build-review's summary; the owner decides.
- Don't connect real data here; that is deploy's.
- Don't write evals or start eval authors: improve writes the checks.

## Done when

- Every case has a result from its local task or case runner: it passes, or has a written reason in Part B (for example, it needs a real connection deploy will make). A case that hasn't run is recorded as planned, never as passing.
- The case on the owner's own sample produces a usable result; if it can't, that blocks the build, whatever the other cases show.
- Then hand over to `build-review`.
