sw-do — work an increment to done
One loop: pick a task, claim it, implement inside its Files:, prove it with a
test, record the evidence. Repeat until nothing is claimable, then verify and
close. State is the ledger (sw-task); the spec is the contract.
Run specweave --version: exit 0 → CLI path. Not found → manual path
(same files, appended by hand — see sw-task).
Pick the increment
No id given → the single increment whose metadata.json has status: active.
Several active → list them and ask which. None → run sw-increment first.
The loop
- Next —
specweave task next <inc>: the first open task whose deps are done and whoseFiles:no live claim holds. Manual: lowest openT-idintasks.mdwith no live claim inledger.jsonl. - Claim —
specweave task claim T-01 <inc>(exit 3 = someone owns it, pick another · 4 = Files overlap · 6 = deps unmet). Manual: append{"t":"T-01","e":"claim","by":"<agent>","at":"<ISO>"}. Never edit before claiming. - Read — the task's
AC:ids inspec.mdand itsFiles:. Read the Approach section for that scope only; do not re-read the whole repo. - Implement — inside that task's
Files:and nothing else. Need another file → claim the task that owns it, or add a task:### T-07 Title+- AC: AC-03 | Files: src/b.ts | Test: npm test -- b. - Prove — run the task's
Test:command. Red → fix; never continue past a failing test. - Commit — subject starts with the increment id:
git commit -m "0042: fold the ledger". - Done with evidence —
specweave task done T-01 <inc> --run "npm test -- a"(exit 5 = the command failed, task stays open). NoTest:→--evidence "<sha> + what you ran". Manual: append{"t":"T-01","e":"done","by":"<agent>","at":"<ISO>","evidence":"npm test -- a → exit 0 / <sha>"}. - Stuck / not needed —
task block T-01 --note "<what is missing>"ortask skip T-01 --note "<why>"(skip is terminal and needs a reason). - Back to 1.
No CLI? Same loop, appended by hand
ledger.jsonl is the only state; append one line per event (full protocol in sw-task):
printf '%s\n' '{"t":"T-01","e":"claim","by":"codex@mbp","at":"2026-09-02T10:00:00Z"}' \
>> .specweave/increments/0042-slug/ledger.jsonl
$L = '.specweave\increments\0042-slug\ledger.jsonl'
$line = '{"t":"T-01","e":"done","by":"codex@win","at":"2026-09-02T11:30:00Z","evidence":"npm test -- a → exit 0 / a1b2c3d"}'
[IO.File]::AppendAllText($L, $line + "`n", [Text.UTF8Encoding]::new($false))
PowerShell never uses >> here: it writes UTF-16 with a BOM and the line is unreadable to every other tool.
Finish (do not stop to ask)
When every task is done or skipped:
specweave verify <inc>— runs the project's test/lint/build commands (configtesting.commands, else auto-detected), checks the ACs inspec.md, writesreports/verify.md+reports/verify.json.verify.json.okis the only closure gate. Manual: run the same commands yourself and writereports/verify.mdwith the real output.- Tick the ACs you satisfied in
spec.md(- [x] AC-01 …) — only the ones the evidence supports. - Review before shipping user-facing work:
sw-review(fresh context, adversarial). specweave complete <inc>— refuses without a passingverify.jsonunless you pass--reason "<why>".
"All tasks are complete, should I close?" is the anti-pattern. Verify, then close.
Rules
- Claim before edit; edit only the task's
Files:; append-only ledger. - One worktree per agent when others share the increment; the branch name carries the increment id:
git worktree add ../0042-codex -b inc/0042-codex. - A claim older than 2h with no
doneis stale and may be taken over (task claim --force). - Stopping for any reason:
specweave task release --all-mine, thensw-handoff. - Sync between agents happens only through committed files — never assume another agent saw anything you did not commit.
Related
sw-task— the ledger protocol and the manual (no-CLI) forms.sw-increment— write the spec first. ·sw-review— adversarial pass before closing.