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
923 skills9 agents18 commands
Install
$ npx -y skills add Obsidian-Owl/specwright --skill sw-adopt --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/sw-adopt

Context preview

The summary Claude sees to decide when to auto-load this skill.

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

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
Ships withspecwright

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

Get the whole plugin

Other skills on specwright.