Skip to content
Back to skills

Contract

ASecurity

Plan a large task (3+ milestones, over 30 minutes, spanning sessions or risky code) as work units with the cheapest capable model per unit, dispatched to subagents under hook enforcement. Also for --opus / --sonnet / --auto prompts, harness contract, halt or dispatch messages, and 'parallel agents on/off'. Never for small fixes.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentspythongobashnodeexpresssecurity

Works with

  • terminal
  • cli

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add alptugince/claude-code-ai-harness-kit --skill contract --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Contract?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Contract
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alptugince-contract/badge)](https://www.skillsdirectory.com/skills/alptugince-contract)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: contract
description: Plan a large task (3+ milestones, over 30 minutes, spanning sessions or risky code) as work units with the cheapest capable model per unit, dispatched to subagents under hook enforcement. Also for --opus / --sonnet / --auto prompts, harness contract, halt or dispatch messages, and 'parallel agents on/off'. Never for small fixes.
---

# Contract workflow

Opus sessions only. A session on Sonnet or Haiku (the `solo_models` setting) does even large tasks
directly, without subagents; the hooks refuse a new contract there.

Small work runs without a contract: the main session hands its implementation to a `worker` (Sonnet) and edits directly only trivial or critical code. A large task runs plan, then contract, then dispatch, gate
and `/ship`. While `.claude/state/contract.md` exists the hooks enforce this skill: the main session
edits no project files, each subagent edits only its unit's paths, and dispatches on the wrong model
are rejected.

`<hooks>` below is `.claude/hooks` when the project has `.claude/hooks/harness_workflow.py`,
otherwise `~/.claude/hooks`.

## 1. Plan (plan mode; with `model: opusplan` this runs on Opus)
- Start in a worktree for anything risky: `claude -w <task-name>`.
- Broad searches across many files or naming conventions go to the `explorer` agent (Haiku, returns `file:line` only); one or two lookups are done directly.
- Documents (specs, PDFs, long Markdown) go to `doc-reader` (Haiku) with a precise question; never
  read them whole in this conversation.
- The plan names: the work units, which files each owns, the acceptance criteria (each checkable by
  a test or a gate check), what is out of scope, and the riskiest assumption.
- Order units so each leaves the tree compiling and its tests green (data before UI, code before
  the docs that describe it). Express the order as a graph: a unit names the units it needs in
  `after:`; units with no path between them are independent and may run in parallel.

## 2. Model per unit (cost first, then capability)
Code units (`U<n>`) are `sonnet` by default; Opus is for the really important code only. Mark `opus`
only when one of these is true for its code:
- auth, security, permissions, payments, cryptography, personal data
- concurrency, async ordering or state machines where a mistake corrupts state
- persistence: schemas, migrations, sync, offline conflict resolution
- the plan's riskiest assumption lives here
Everything else is `sonnet`, including shared models, refactors, build configuration, native code
following an existing pattern, algorithms with tests that pin the edge cases, widgets, `.arb`
entries, CRUD, tests and renames; put the hard decisions in the unit's brief instead. When unsure,
pick `sonnet`: a failing unit escalates to Opus on its own. Split a mixed unit by file so only the
critical logic is `opus`, and split a unit spanning more than five files. A file belongs to exactly
one unit.

Document units (`D<n>`) are `haiku` unless the document is important; you are deciding as the Opus
planner, so apply the judge's DOC-TRIAGE rubric (`judge` agent): `sonnet` for customer-facing or
public documents where accuracy and tone carry weight and for documents that synthesize many
sources; `opus` only for legal, compliance, security, threat models and specs that drive
implementation. Pick the cheapest model that meets the bar and say why in `why:`.

A prompt starting with `--opus` or `--sonnet` forces every code unit onto that model until the task
is shipped; `--auto` returns the choice to you. Document units keep their own model.

## 3. Contract (first action after the plan is approved)
Write `.claude/state/contract.md`:
```
# Contract
## Goal
<one sentence>

## Work units
### U1 | opus | Token refresh queue
paths: lib/core/auth/**, test/core/auth/**
why: concurrent refresh calls must share one in-flight request

Queue concurrent refreshes behind one in-flight request in TokenRefresher; a failed refresh fails every waiter.

### U2 | sonnet | Session expired banner
paths: lib/features/session/ui/**, lib/l10n/*.arb, test/features/session/ui/**
after: U1
why: follows the existing banner widget pattern
Show SessionExpiredBanner when TokenRefresher reports expiry; strings in every app_*.arb.

### D1 | haiku | Auth section of the README
paths: README.md
after: U1, U2

## Acceptance criteria
- <behaviour> - <test or gate check that proves it>

## Out of scope
- <what must not change>
```
Saving validates it; an invalid contract is rejected with the reasons: unknown or cyclic `after:`
references, and two units claiming one file (a folder glob such as `lib/**` containing another
unit's path, or an existing file matched by two units). Doc unit paths must name text documents
(`.md`, `.rst`, `.adoc`, ...). Any other line under a unit is its brief: the plan notes the
subagent gets (files, functions, decisions, what the tests must show); the graph runner sends it
as the dispatch prompt, so write it there, not only in this conversation.
`python <hooks>/harness_workflow.py status` shows each unit's model, phase and state (done, ready,
waiting). If `PROGRESS.md` exists, its Next step points at the next unit; do not copy the units
into it.

## 4a. Run it as a graph (preferred for 3+ units)
Only when parallel agents are on (`python <hooks>/harness_graph.py status` shows it); otherwise use
step 4. The graph runner does steps 4 and 5 without this conversation re-reading its context for
every dispatch:
```bash
python <hooks>/harness_graph.py plan             # layers and parallel groups
python <hooks>/harness_graph.py run [--commit] [--wait-for-reset] [--max-parallel N]
```
Each node is a fresh headless session that dispatches one subagent under the same hooks; independent
units run in parallel worktrees. It stops for the user on a halt, REPLAN, a second FAIL or a node
failing twice (exit 3), and pauses at a usage limit with a PROGRESS.md record (exit 75). Headless
sessions cannot ask for permissions: the allow rules (`/bootstrap-harness` step 5) decide what units
may run.

**Turning parallel agents on or off.** "parallel agents on" runs `python <hooks>/harness_graph.py enable`
and relays its output. If it asks for a login, tell the user to run the command it shows in their own
terminal, then say "parallel agents on" again; never attempt the login yourself. "parallel agents off"
runs `python <hooks>/harness_graph.py disable`.

## 4. Dispatch in this conversation (one writing subagent at a time, in `after:` order)
The task moves through phases (`status` shows it): CONTRACT, EXECUTE, REVIEW (pack built, judge
next, no dispatch), FIX (ROUND 2 only), RECEIPT; HALTED and REPLAN wait for a new contract. A unit
whose `after:` units are not done is refused.
- Code: `Agent(subagent_type="implementer", model="<unit model>", prompt="UNIT: U1\n<plan notes: files, functions, decisions, what the tests must show>")`.
- Documents: `Agent(subagent_type="doc-writer", model="<unit model>", prompt="UNIT: D1\n<brief: audience, purpose, facts and sources, length>")`.
- Give each subagent what it needs in the prompt (plan notes, doc-reader extracts) so it does not
  re-explore. Wrong models are rejected with the right one named.
- Every edit is formatted and linted; an implementer cannot return until the project gate passes.
- Escalation is automatic: a unit that caused a halt runs on Opus next (documents one step up), and
  every code fix round from round 2 runs on Opus.
- `needs-outside-unit` in a reply: update the contract (new unit or path), then dispatch again.
- After 3 identical failures the harness halts. Tell the user, switch to plan mode, re-plan and save
  a new contract (saving it clears the halt). An interrupted subagent (Esc) keeps its slot; free it
  with `python <hooks>/harness_workflow.py release`.

## 5. Finish
When every unit is done, run `/ship`. Never claim tests pass unless the gate output says so.

## Documents outside a contract
Reading: `Agent(subagent_type="doc-reader", prompt="FILE: <path>\nQUESTION: <what you need>")`.
Writing more than a few lines: `Agent(subagent_type="doc-writer", prompt="DOC: <path>\n<brief>")` on
Haiku. When the document matters enough for Sonnet or Opus, ask the judge first:
`Agent(subagent_type="judge", prompt="DOC-TRIAGE\nDOC: <path>\n<audience, purpose, cost of an error>")`;
the harness records its decision and then accepts only that model for that document.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.