Skip to content
Development
Skill

/sw-adopt

Explicitly adopt an existing work into the current worktree after validating live ownership, stale sessions, and branch consistency.

From plugin
specwright
1023 skills9 agents18 commands

Claude Code

$ npx -y skills add Obsidian-Owl/specwright --skill sw-adopt --agent claude-code

SKILL.md

sw-adopt.SKILL.md
name: sw-adopt
description: >-
  Explicitly adopt an existing work into the current worktree after validating
  live ownership, stale sessions, and branch consistency.
argument-hint: "<work-id>"
allowed-tools:
  - Read
  - Write
  - Bash
  - Glob

Specwright Adopt

Goal

Attach an existing work to the current worktree without creating split-brain ownership. This skill attaches only the current worktree session.

Inputs

  • target work ID from the argument, or the current worktree session's

`attachedWorkId` when re-adopting the already-selected work

  • `{worktreeStateRoot}/session.json` for the current worktree
  • `{repoStateRoot}/work/{workId}/workflow.json`
  • repo-wide `session.json` files discovered via `git worktree list --porcelain`

Outputs

  • updated `{worktreeStateRoot}/session.json` for the current worktree only
  • updated selected work `workflow.json.attachment` pointing at the current

worktree when adoption succeeds

  • concise outcome explaining whether the work was adopted, blocked by a live

owner, or blocked by branch mismatch

Constraints

**Scope (LOW freedom):**

  • `/sw-adopt` is the explicit same-work adoption flow. It must not silently run

during `/sw-design`, `/sw-plan`, `/sw-build`, `/sw-verify`, or `/sw-ship`.

  • `/sw-adopt` never rewrites another worktree's `session.json`.
  • Subordinate sessions must not run `/sw-adopt`.

**Target resolution (LOW freedom):**

  • Resolve the target work from the argument first, then the current worktree's

`session.json.attachedWorkId` as a fallback.

  • Validate that the target work exists under `{repoStateRoot}/work/{workId}`.
  • If no target work resolves, STOP and tell the operator to pass a work ID or

run `/sw-design`.

**Ownership validation (LOW freedom):**

  • Use live-versus-dead session state as the adoption authority.
  • Inspect repo-wide `session.json` files to determine live-versus-dead session

state for the target work.

  • Treat live top-level sessions as authoritative owners.
  • Treat dead top-level sessions as stale attachments that may be superseded.
  • Treat subordinate sessions as non-owners even when they reference the same

`workId`.

  • If another live top-level worktree owns the target work, STOP and tell the

operator to continue there or make that owner stale first. `/sw-adopt` does not perform remote session surgery.

**Branch consistency (LOW freedom):**

  • When the target work is already in `building`, `verifying`, or `shipping`,

validate branch consistency against `workflow.json.branch`.

  • Matching the recorded branch is necessary for in-flight adoption, but it is

never sufficient to seize ownership on its own.

  • If the current worktree branch is inconsistent with the recorded branch,

STOP and tell the operator to check out the recorded branch first.

**Mutation boundary (LOW freedom):**

  • On success, mutate only the current worktree's `session.json` and the target

work's `workflow.json`.

  • Update the target work's `workflow.json.attachment` to the current worktree,

refresh `workflow.json.branch` from the current worktree branch, and refresh liveness timestamps.

  • Never clear or rewrite another worktree's session file as part of adoption.

Protocol References

  • `protocols/state.md` -- live ownership, attachment validation, subordinate rules
  • `protocols/context.md` -- logical roots and session discovery
  • `protocols/git.md` -- recorded branch context

Failure Modes

| Condition | Action | |-----------|--------| | No target work resolves | STOP: "Pass a work ID or run /sw-design first." | | Target work does not exist | STOP with a missing-work error | | Current session is subordinate | STOP: "Subordinate helper sessions cannot adopt work." | | Another live top-level worktree owns the target work | STOP with live-owner guidance | | Recorded branch mismatch for in-flight work | STOP with branch-consistency guidance |

Read more
@obsidian-owl
Ships withspecwright

Craft quality software with AI discipline. Spec-driven development plugin for Claude Code and Opencode — quality gates, adversarial testing, and evidence capture.

1023 skills9 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
10
Star history of Obsidian-Owl/specwright on GitHub, a chart by star-history.com

Other skills on specwright.

gate-build

gate-build

Runs configured build and test commands in tiered order. Captures output as evidence per tier. Returns PASS, FAIL, WARN, or SKIP…

gate-security

gate-security

Detects leaked secrets, injection patterns, and sensitive data exposure across changed files. Uses real tooling when configured,…

gate-semantic

gate-semantic

Tiered semantic analysis of changed code (rg → ast-grep → OpenGrep). Detects error-path bugs structural gates miss. Findings…

gate-spec

gate-spec

Maps every acceptance criterion from the spec to implementation evidence and test evidence. Criteria without evidence fail. The…

gate-tests

gate-tests

Audits test quality — assertion strength, boundary coverage, mock discipline, error path testing. Delegates to the tester agent…

gate-wiring

gate-wiring

Detects unused exports, orphaned files, architecture layer violations, and circular dependencies across changed files. Delegates…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills12d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about sw-adopt.

Which coding agents can use sw-adopt?
sw-adopt installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.