# Loop contract

Use this to turn a recurring AI task into a loop that can make progress and stop safely.

## 1. Job

What measurable outcome should one run produce?

> Example: Review completed support calls and identify missing intake fields that caused avoidable transfers.

## 2. Trigger

What starts one run: a schedule, event, threshold, or person?

> Example: Every weekday at 9:00 a.m., after the prior day's call data is available.

## 3. Evidence

What source material or state may the loop inspect? Which source is authoritative?

> Example: Completed-call events, redacted transcripts, the current intake schema, and the approved escalation policy.

## 4. Action and authority

What may the agent do? What must it never do without approval?

> Example: It may classify failures and draft a proposed schema diff. It may not publish the new schema or change the live agent.

## 5. Budget

What is the maximum number of passes, elapsed time, model/tool calls, or spend?

> Example: One pass over at most 50 calls, one retry for a failed download, and a 15-minute total runtime.

## 6. Verifier

What independent check decides whether the result is correct or better?

> Example: Required-field coverage against a reviewed test set. The agent's own confidence is not the verifier.

## 7. Artifact and state

What will the loop save so a person or the next run can inspect what happened?

> Example: A dated Markdown report, a machine-readable JSON diff, the source version, and the score before and after.

## 8. Stop + human line

When does the loop stop successfully? When does it stop because the budget is used or the evidence is uncertain? Who approves high-impact changes?

> Example: Stop when all reviewed cases pass, the budget is exhausted, or the evidence conflicts. A support lead approves any production change.

## Suitability gate

Use a loop only when these are true:

- [ ] The work happens repeatedly.
- [ ] The result can wait long enough for a check.
- [ ] Progress or success can be verified with evidence independent of the agent's opinion.
- [ ] The first version can run with limited, reversible authority.
- [ ] A person or fixed workflow can handle uncertainty and high-impact decisions.

If the user is waiting in real time, prefer a bounded workflow. If success cannot be checked reliably, prefer a fixed workflow or a human decision.

## Claude Code starter prompt

```text
In Claude Code, turn the loop contract below into a one-run pilot in a new folder.

Requirements:
- Preserve the stated job, evidence, authority, budget, verifier, artifact, and stop conditions.
- Build only one manual run. Do not add scheduling, background services, credentials, or production writes.
- Include one small example input and one expected output.
- Make the independent check visible and reproducible.
- Record what happened in a human-readable run report.
- Stop and ask before expanding scope or authority.

[PASTE LOOP CONTRACT]

At the end, show me the files created, the check result, what would trigger a human review, and the smallest useful next step.
```
