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.
| Location | Role today |
|---|---|
apps/sdlc/skills/task-work/SKILL.md | Lines 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.ts | sdlc 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.md | Owns the task/<basename> naming rule the new verb needs to encode. |
apps/sdlc/lib/services/project/ops/preflight-worktree.ts | With 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.ts | sdlc gate skill-prose — the SKILL.md lint the rewritten Step must still pass. |
Proposed
Section titled “Proposed”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 absolutepaths in tool calls; do NOT `cd` the parent session into theworktree.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 mainat entry, followed bygit worktree add ... -b task/<basename> origin/main— branching fromorigin/main, not from localmain. In parallel-tasks projects, localmainis regularly contaminated withchore(tasks): start <other-basename>commits from other in-flight work; branching fromorigin/maineliminates 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 emptyworktree_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.
Approach
Section titled “Approach”- Wait for T-ELV7-prototype-skill-refine-skill to ship. This task is gated on that skill being usable.
- Invoke
/skill-refine apps/sdlc/skills/task-work/SKILL.md "## 4. Create the worktree". Review the extraction proposal. - Confirm or adjust the proposal. Likely adjustments: noun placement (
task setup-worktreevs aprojectverb alongsidepreflight-worktree/teardown-worktree); hidden vs listed; what stays as prose vs what moves into the verb. - Let skill-refine generate the op and rewrite the Step. Verify the resulting
SKILL.mdpassessdlc gate skill-prose. - 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 whenworktree_init:is absent. - Update
docs/skills/task-work.mdif the flowchart needs to change to reflect the simplified Step 4.
Files to touch
Section titled “Files to touch”| Location | Kind | Change |
|---|---|---|
apps/sdlc/lib/model/entities/task/ops/setup-worktree.ts | new | The extracted op behind sdlc task setup-worktree. Owns fetch + git worktree add, branch naming, the quality run call. |
apps/sdlc/skills/task-work/SKILL.md | modify | Replace the ~44 lines under ## 4 with the one-line shell-out + short rationale. |
apps/sdlc/lib/model/entities/task/ops/tests/setup-worktree.test.ts | new | Regression test for the new op. |
docs/skills/task-work.md | modify | Update the flowchart if needed to reflect the simplified Step 4. |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1:
${CLAUDE_PLUGIN_ROOT}cli/sdlc task setup-worktree <basename>creates.sdlc/worktrees/<basename>on a newtask/<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’sworktree_init:key is absent or empty, the verb runs the executor with--allow-emptyand 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.mdStep 4 body is ≤10 lines (a shell-out + a short rationale), and the file still passessdlc 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 mainand branches the worktree fromorigin/main, not from localmain. A repo whose localmainis severalchore(tasks): start <other-basename>commits ahead oforigin/mainstill produces a worktree whose branch HEAD sits onorigin/main’s tip — verified bygit log --oneline <branch>..origin/mainbeing empty after worktree creation.
Out of scope
Section titled “Out of scope”- 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-workor other skills. Each is its own task;/skill-refinewill 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.
Dependencies
Section titled “Dependencies”- T-ELV7-prototype-skill-refine-skill — the skill-refine prototype must exist and be usable; this task is its first canonical user.
Discovery context
Section titled “Discovery context”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.
Depends on
Section titled “Depends on”T-ELV7-prototype-skill-refine-skill