core/skills/sw-plan/SKILL.md
Breaks a design into work units with testable specs. Reads design artifacts from sw-design and produces implementation-ready plans.
npx skillsauth add obsidian-owl/specwright sw-planInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Turn the approved design into implementation-ready specs with testable acceptance
criteria. Decompose into ordered work units if large. Operates autonomously,
applying protocols/decision.md for all decisions. Gate handoff at the end.
{worktreeStateRoot}/session.json -- selected work for this worktree{repoStateRoot}/work/{selectedWork.id}/workflow.json -- selected work state{workArtifactsRoot}/{selectedWork.id}/design.md -- approved solution design{workArtifactsRoot}/{selectedWork.id}/context.md -- research findings from sw-design{workArtifactsRoot}/{selectedWork.id}/decisions.md -- design-phase decisionsdata-model.md, contracts.md, testing-strategy.md, infra.md, migrations.md{projectArtifactsRoot}/CONSTITUTION.md -- practices to follow{projectArtifactsRoot}/config.json -- project configurationSingle-unit work: spec.md + plan.md in {workArtifactsRoot}/{selectedWork.id}/ (flat layout).
Multi-unit work: For each unit in {workArtifactsRoot}/{selectedWork.id}/units/{unit-id}/:
spec.md + plan.md + context.md. workUnits array in workflow.json.
Also: integration-criteria.md in the design-level directory ({workArtifactsRoot}/{selectedWork.id}/).
Also: {repoStateRoot}/work/{selectedWork.id}/stage-report.md for the planning handoff.
Also: decisions.md updated with planning-phase autonomous decisions.
Stage boundary (LOW freedom):
Follow protocols/stage-boundary.md. Produce specs and plans. NEVER implement, branch,
test, or commit. After gate handoff, STOP.
Pre-condition check (LOW freedom):
Resolve the selected work from the current worktree session. Check that
selectedWork.status is designing or planning and design.md exists.
sw-plan operates on the current worktree's attached work only.
If another live top-level worktree owns that selected work, STOP and require
explicit /sw-adopt guidance before mutating specs or plans here. Matching the
recorded branch alone must not imply takeover.
Design approval capture (LOW freedom) — on entry:
Use protocols/approvals.md and the shared helper to record the current design
artifact set in {workArtifactsRoot}/{selectedWork.id}/approvals.md.
Interactive /sw-plan runs may write an APPROVED design entry with source
classification command; headless runs must validate existing human approval
instead of fabricating one.
Decompose (MEDIUM freedom, only if large):
protocols/decision.md DISAMBIGUATION.sw-plan after a structural pivot or decomposition revision,
regenerate only the affected remaining-unit artifact set. Overwrite each
affected remaining unit's spec.md, plan.md, and context.md, but keep
shipped units as immutable baseline scope rather than rewriting their
artifacts or acceptance history.Integration criteria (MEDIUM freedom, multi-unit only):
integration-criteria.md in
the design-level directory ({workArtifactsRoot}/{selectedWork.id}/). Not generated for
single-unit work.integration-criteria.md: structural (IC-{n}) and behavioral
(IC-B{n}). Both types go to the same file.src/routes/index.ts imports handler from
src/handlers/payment.ts". Example (invalid): "The payment feature works
end-to-end" (too abstract — use a spec AC instead).
Format: - [ ] IC-{n}: {assertion with file paths or export names}.- [ ] IC-B1: calling checkout() returns an order ID after the payment and inventory units are both active.
Format: - [ ] IC-B{n}: {assertion referencing observable outputs}.
spec-review validates IC-B quality: each behavioral IC must name a concrete observable,
not restate implementation intent.sw-plan (replanning), regenerate integration-criteria.md
for the affected remaining units only. This uses
the same overwrite behavior as regenerated unit spec.md / plan.md /
context.md artifacts while preserving shipped units as immutable baseline
scope. If replanning reduces the remaining work to single-unit, delete
integration-criteria.md if it exists.integration-criteria.md may become
stale. sw-pivot should regenerate ICs when unit boundaries change. If it does not,
gate-wiring will WARN on unverifiable ICs rather than false-PASS.Spec writing (MEDIUM freedom):
protocols/decision.md#late-discovery-lifecycle. Auto-resolve per the
Type 1/2 rules in protocols/decision.md#autonomous-resolution.[tier: X]
annotation. Tier classification rules are defined in protocols/testing-strategy.md
— apply them declaratively; do not reproduce them here.Spec per-unit loop (MEDIUM freedom, multi-unit only): For each unit sequentially: create directory, write context.md (self-contained), plan.md (task breakdown + file change map), spec.md (unit-scoped ACs). Each unit's context.md must be sufficient for an agent reading only that directory. If the remaining work truly needs mutable concurrency, stop decomposing it into one shared workflow and instead create separate works with explicit integration criteria.
Spec pre-review (MEDIUM freedom):
specwright-architect per protocols/spec-review.md.Code budget (MEDIUM freedom): plan.md contains structure, not implementation. Allowed: signatures, types, contracts, directory structure, config examples. NOT allowed: function bodies, algorithm logic.
Gate handoff (LOW freedom):
On completion, emit the three-line handoff per the protocols/decision.md
Gate Handoff section. Write {repoStateRoot}/work/{selectedWork.id}/stage-report.md
before the handoff. The Artifacts line points at
Artifacts: {repoStateRoot}/work/{selectedWork.id}/stage-report.md. Detail
lives in the auditable artifact files under
{workArtifactsRoot}/{selectedWork.id}/ (spec.md / plan.md / context.md
for each unit, integration-criteria.md for multi-unit work). The Next line
remains machine-parseable: Next: /sw-build.
State mutations (LOW freedom):
Follow protocols/state.md. Mutate only the selected work's workflow.json and
the current worktree's session.json. Transition designing → planning.
targetRef and freshness metadata in
the selected work state and in any regenerated remaining-unit context that
depends on them. Replanning must not silently clear, downgrade, or rewrite
the recorded target or freshness policy when regenerating open work.baseBranch target.Multi-unit: populate the selected work's workUnits array, set the first unit
to building, transition the selected work to building, and hand off to
/sw-build. Do not clear or retarget unrelated active works owned by other
top-level worktrees.
protocols/stage-boundary.md -- scope, termination, and handoffprotocols/decision.md -- autonomous decision framework, gate handoff, late assumption capture and autonomous resolutionprotocols/state.md -- workflow state updates and lockingprotocols/context.md -- anchor doc and config loadingprotocols/recovery.md -- compaction recoveryprotocols/approvals.md -- design approval capture and validationprotocols/headless.md -- non-interactive approval behaviorprotocols/spec-review.md -- spec quality reviewprotocols/testing-strategy.md -- tier tagging for ACs crossing TESTING.md boundaries| Condition | Action |
|-----------|--------|
| Status not designing/planning | STOP: "Run /sw-design first" |
| Required artifact missing | STOP: "Run /sw-design first" |
| Selected work owned by another live top-level worktree | STOP with explicit /sw-adopt guidance |
| Design too vague for specs | Apply DISAMBIGUATION from design context. Record interpretation. Surface at gate if undetermined. |
| Active work in progress | Continue planning the current work. sw-plan always operates on existing design artifacts — it has no "start new" path. |
| Compaction during planning | Read workflow.json. Skip planned units, resume first pending. |
| Decomposition revision needed | /sw-status --reset and re-run /sw-plan. |
testing
Explicitly adopt an existing work into the current worktree after validating live ownership, stale sessions, and branch consistency.
testing
Orchestrates quality gates for the current work unit. Runs enabled gates in dependency order, produces an aggregate evidence report with gate handoff.
tools
Syncs the local repository by fetching all remotes, updating the base branch, and removing stale local branches that are not protected by live sessions or helper worktrees.
data-ai
Shows current Specwright state for this worktree, the attached work, repo-wide active works, gate results, and lock status. Supports --reset, --cleanup, and --repair {unitId}.