Skip to content

T-33C0-refactor-task-work-step-4-via-skill-refine

Status: closed/superseded · Impact: medium · Complexity: small

/sdlc:task-work Step 4 (“Create the worktree”) currently carries ~40 lines of orchestration prose for what is essentially git worktree add + a sdlc quality run --key worktree_init --allow-empty invocation. The deterministic parts (branch naming, worktree path, executor invocation, error surfacing) belong in a registry op on the CLI substrate (D-H7FS-op-substrate-surface); the SKILL.md should be a one-line shell-out plus a short rationale. This task is the first user of the /skill-refine skill being prototyped in T-ELV7-prototype-skill-refine-skill — the extraction itself is performed via that skill, exercising it on a real, motivating case.

LocationRole today
apps/sdlc/skills/task-work/SKILL.mdLines under ## 4. Create the worktree carry: (a) the git worktree add .sdlc/worktrees/<basename> -b task/<basename> main invocation — branching from local main; (b) prose on the branch-naming convention with reference to conventions/branch-naming.md; (c) an “Initialize the worktree” sub-section with background on why worktree init exists; (d) the ${CLAUDE_PLUGIN_ROOT}cli/sdlc quality run --config <yaml> --key worktree_init --project-root <worktree> --log --allow-empty invocation and its error contract; (e) a worked example. ~44 lines total. Most of it is deterministic operations dressed up as English.
apps/sdlc/lib/services/quality/ops/run.tssdlc quality run — the executor Step 4’s prose currently asks the LLM to invoke with the right flags. Becomes a callee of the new verb.
apps/sdlc/conventions/branch-naming.mdOwns the task/<basename> naming rule the new verb needs to encode.
apps/sdlc/lib/services/project/ops/preflight-worktree.tsWith teardown-worktree.ts, the existing worktree-lifecycle verbs on the project noun. Setup is the missing member; noun placement for it is settled during Approach step 3.
apps/sdlc/lib/services/gate/ops/skill-prose.tssdlc gate skill-prose — the SKILL.md lint the rewritten Step must still pass.

Step 4 of task-work/SKILL.md reduces to roughly:

## 4. Create the worktree
${CLAUDE_PLUGIN_ROOT}cli/sdlc task setup-worktree <basename>
This creates `.sdlc/worktrees/<basename>` on a new `task/<basename>`
branch off `origin/main` and runs any project-declared `worktree_init:`
verbs. See `conventions/branch-naming.md` for the prefix rationale.
All subsequent work happens in the worktree path — use absolute
paths in tool calls; do NOT `cd` the parent session into the
worktree.

The new verb — sdlc task setup-worktree, a registry op on the task noun (likely hidden, per D-H7FS-op-substrate-surface) — owns:

  • A git fetch origin main at entry, followed by git worktree add ... -b task/<basename> origin/main — branching from origin/main, not from local main. In parallel-tasks projects, local main is regularly contaminated with chore(tasks): start <other-basename> commits from other in-flight work; branching from origin/main eliminates the contamination at the source. Step 9’s rebase-onto-origin/main becomes a no-op in the common case.
  • The branch-naming convention (task/<basename>).
  • The worktree-init executor call: quality run --key worktree_init --allow-empty — a missing or empty worktree_init: key is exit 0; a failing declared verb is a hard error.
  • Clear exit-code contract: 0 on success, non-zero with a structured stderr message on failure.
  • Idempotency: refuses if the worktree or branch already exists; surfaces a clear error.

The extraction is performed by /skill-refine (from T-ELV7-prototype-skill-refine-skill). The implementer of this task invokes /skill-refine apps/sdlc/skills/task-work/SKILL.md "## 4. Create the worktree", reviews the proposed extraction, and confirms.

  1. Wait for T-ELV7-prototype-skill-refine-skill to ship. This task is gated on that skill being usable.
  2. Invoke /skill-refine apps/sdlc/skills/task-work/SKILL.md "## 4. Create the worktree". Review the extraction proposal.
  3. Confirm or adjust the proposal. Likely adjustments: noun placement (task setup-worktree vs a project verb alongside preflight-worktree/teardown-worktree); hidden vs listed; what stays as prose vs what moves into the verb.
  4. Let skill-refine generate the op and rewrite the Step. Verify the resulting SKILL.md passes sdlc gate skill-prose.
  5. Add a regression test for the new op. Alongside the op’s siblings under apps/sdlc/lib/model/entities/task/ops/tests/. Cover at minimum: worktree created + branch named correctly + no-op when worktree_init: is absent.
  6. Update docs/skills/task-work.md if the flowchart needs to change to reflect the simplified Step 4.
LocationKindChange
apps/sdlc/lib/model/entities/task/ops/setup-worktree.tsnewThe extracted op behind sdlc task setup-worktree. Owns fetch + git worktree add, branch naming, the quality run call.
apps/sdlc/skills/task-work/SKILL.mdmodifyReplace the ~44 lines under ## 4 with the one-line shell-out + short rationale.
apps/sdlc/lib/model/entities/task/ops/tests/setup-worktree.test.tsnewRegression test for the new op.
docs/skills/task-work.mdmodifyUpdate the flowchart if needed to reflect the simplified Step 4.
  • AC-1: ${CLAUDE_PLUGIN_ROOT}cli/sdlc task setup-worktree <basename> creates .sdlc/worktrees/<basename> on a new task/<basename> branch and exits 0; running it again with the same basename exits non-zero with a clear “already exists” error.
  • AC-2: When sdlc.yaml’s worktree_init: key is absent or empty, the verb runs the executor with --allow-empty and exits 0; when the key has verbs that succeed, the verb exits 0; when a declared verb fails, the verb exits non-zero with that verb’s stderr surfaced.
  • AC-3: apps/sdlc/skills/task-work/SKILL.md Step 4 body is ≤10 lines (a shell-out + a short rationale), and the file still passes sdlc gate skill-prose.
  • AC-4: A regression test alongside the op exercises at least: clean worktree creation, idempotency refusal, no-op worktree_init: path, and a failing verb path.
  • AC-5: A live /sdlc:task-work <some-basename> run end-to-end against a real task succeeds — Step 4 fires the new verb, the worktree is correctly created, and downstream Steps 5–7 still work.
  • AC-6: The verb runs git fetch origin main and branches the worktree from origin/main, not from local main. A repo whose local main is several chore(tasks): start <other-basename> commits ahead of origin/main still produces a worktree whose branch HEAD sits on origin/main’s tip — verified by git log --oneline <branch>..origin/main being empty after worktree creation.
  • Generalising applies_when: predicates for skill-step invariants. The motivating case is resolved by extraction; if a future Step needs predicate-based conditionality, that’s a fresh task.
  • Refactoring other Steps in task-work or other skills. Each is its own task; /skill-refine will be the tool used.
  • An advisory missing-binary probe during worktree setup (surfacing uninstalled tools before implementation starts). No such probe exists on the current CLI surface; if missing binaries discovered mid-implementation become a recurring problem, that’s a fresh task.

Spawned from the post-mortem of T-K7FR-task-work-worktree-init-language-agnostic. Step 4 is mostly script-shaped prose, not a conditional needing a predicate — extraction is the structural fix. Gating on T-ELV7-prototype-skill-refine-skill makes this task double as the first dogfood of /skill-refine.

T-ELV7-prototype-skill-refine-skill


← Back to Tasks