Write AI prompt/workflow steps as deterministic contracts: remove ambiguity, force required lookups, gate behavior by mode, and make unattended/automation outputs schema-correct.
Apply these rules:
{mode} (e.g., skip greeting in autonomous mode) so the first emitted content is always the artifact or next action.Example pattern:
## Output Contract
- If `{mode}` == `autonomous`, do **not** output conversational text.
- Always load reference docs in this order before step 1:
1) `references/guide-contract.md`
2) `references/evidence.md`
## Automation Mode (unattended)
After applying patches:
- Write `$AUTO_DIR/tasks/$TASK_ID/result.json` with:
- `workflow`: "code-review"
- `patched`: true iff patch-items were applied on disk
- `deferred`: list iff deferred-work file append occurred
- `dismissed`: count set aside to review ledger
- `clean`: true iff status on disk is `done` and no escalations
If you follow the contract rules above, you prevent the common production failures: skipped lookups, wrong behavior in autonomous runs, schema ambiguity, and inconsistent classification across subagents.