From 3e8c8f6f39c1b2b865b5bb5fed95db56a87a8840 Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Sat, 28 Mar 2026 01:21:04 -0700 Subject: [PATCH] feat(autonomous): add --only N flag for single-phase execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds --only N flag to /gsd:autonomous that restricts execution to a single phase, enabling safe parallel execution across terminals: Terminal 1: /gsd:autonomous --only 16 Terminal 2: /gsd:autonomous --only 17 Terminal 3: /gsd:autonomous --only 18 Changes: - Step 1: Parse --only N alongside --from N (also sets FROM_PHASE) - Step 2: Filter phase list to exact match when --only active - Step 4: Skip iteration — single phase does not loop - Step 5: Skip lifecycle — audit/complete/cleanup only for full runs - Step 6: Resume message uses --only when active - Success criteria updated with --only N requirements Parallel safety: each phase operates in its own .planning/phases/NN-* directory. ROADMAP.md and STATE.md are read-only during phase execution. Closes #1383 Co-Authored-By: Claude Opus 4.6 (1M context) --- get-shit-done/workflows/autonomous.md | 54 ++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/get-shit-done/workflows/autonomous.md b/get-shit-done/workflows/autonomous.md index b6e1f6448..c6363a32f 100644 --- a/get-shit-done/workflows/autonomous.md +++ b/get-shit-done/workflows/autonomous.md @@ -1,6 +1,6 @@ -Drive all remaining milestone phases autonomously. For each incomplete phase: discuss → plan → execute using Skill() flat invocations. Pauses only for explicit user decisions (grey area acceptance, blockers, validation requests). Re-reads ROADMAP.md after each phase to catch dynamically inserted phases. +Drive milestone phases autonomously — all remaining phases, or a single phase via `--only N`. For each incomplete phase: discuss → plan → execute using Skill() flat invocations. Pauses only for explicit user decisions (grey area acceptance, blockers, validation requests). Re-reads ROADMAP.md after each phase to catch dynamically inserted phases. @@ -16,15 +16,23 @@ Read all files referenced by the invoking prompt's execution_context before star ## 1. Initialize -Parse `$ARGUMENTS` for `--from N` flag: +Parse `$ARGUMENTS` for `--from N` and `--only N` flags: ```bash FROM_PHASE="" if echo "$ARGUMENTS" | grep -qE '\-\-from\s+[0-9]'; then FROM_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-from\s+[0-9]+\.?[0-9]*' | awk '{print $2}') fi + +ONLY_PHASE="" +if echo "$ARGUMENTS" | grep -qE '\-\-only\s+[0-9]'; then + ONLY_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-only\s+[0-9]+\.?[0-9]*' | awk '{print $2}') + FROM_PHASE="$ONLY_PHASE" +fi ``` +When `--only` is set, also set `FROM_PHASE` to the same value so existing filter logic applies. + Bootstrap via milestone-level init: ```bash @@ -48,7 +56,8 @@ Display startup banner: Phases: {phase_count} total, {completed_phases} complete ``` -If `FROM_PHASE` is set, display: `Starting from phase ${FROM_PHASE}` +If `ONLY_PHASE` is set, display: `Single phase mode: Phase ${ONLY_PHASE}` +Else if `FROM_PHASE` is set, display: `Starting from phase ${FROM_PHASE}` @@ -68,6 +77,16 @@ Parse the JSON `phases` array. **Apply `--from N` filter:** If `FROM_PHASE` was provided, additionally filter out phases where `number < FROM_PHASE` (use numeric comparison — handles decimal phases like "5.1"). +**Apply `--only N` filter:** If `ONLY_PHASE` was provided, additionally filter OUT phases where `number != ONLY_PHASE`. This means the phase list will contain exactly one phase (or zero if already complete). + +**If `ONLY_PHASE` is set and no phases remain** (phase already complete): + +``` +Phase ${ONLY_PHASE} is already complete. Nothing to do. +``` + +Exit cleanly. + **Sort by `number`** in numeric ascending order. **If no incomplete phases remain:** @@ -686,7 +705,9 @@ Decisions captured: {count} across {area_count} areas ## 4. Iterate -After each phase completes, re-read ROADMAP.md to catch phases inserted mid-execution (decimal phases like 5.1): +**If `ONLY_PHASE` is set:** Do not iterate. Proceed directly to lifecycle step (which exits cleanly per single-phase mode). + +**Otherwise:** After each phase completes, re-read ROADMAP.md to catch phases inserted mid-execution (decimal phases like 5.1): ```bash ROADMAP=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" roadmap analyze) @@ -715,7 +736,23 @@ If all phases complete, proceed to lifecycle step. ## 5. Lifecycle -After all phases complete, run the milestone lifecycle sequence: audit → complete → cleanup. +**If `ONLY_PHASE` is set:** Skip lifecycle. A single phase does not trigger audit/complete/cleanup. Display: + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + GSD ► AUTONOMOUS ▸ PHASE ${ONLY_PHASE} COMPLETE ✓ +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + Phase ${ONLY_PHASE}: ${PHASE_NAME} — Done + Mode: Single phase (--only) + + Lifecycle skipped — run /gsd:autonomous without --only + after all phases complete to trigger audit/complete/cleanup. +``` + +Exit cleanly. + +**Otherwise:** After all phases complete, run the milestone lifecycle sequence: audit → complete → cleanup. Display lifecycle transition banner: @@ -852,7 +889,7 @@ When any phase operation fails or a blocker is detected, present 3 options via A Skipped: {list of skipped phases} Remaining: {list of remaining phases} - Resume with: /gsd:autonomous --from {next_phase} + Resume with: /gsd:autonomous ${ONLY_PHASE ? "--only " + ONLY_PHASE : "--from " + next_phase} ``` @@ -888,4 +925,9 @@ When any phase operation fails or a blocker is detected, present 3 options via A - [ ] Frontend phases get UI review audit after successful execution (step 3d.5) if UI-SPEC exists - [ ] UI phase and UI review respect workflow.ui_phase and workflow.ui_review config toggles - [ ] UI review is advisory (non-blocking) — phase proceeds to iterate regardless of score +- [ ] `--only N` restricts execution to exactly one phase +- [ ] `--only N` skips lifecycle step (audit/complete/cleanup) +- [ ] `--only N` exits cleanly after single phase completes +- [ ] `--only N` on already-complete phase exits with message +- [ ] `--only N` handle_blocker resume message uses --only flag