From 609f7f3ede6dd084ed364885a50604ff950c0668 Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Tue, 3 Mar 2026 02:30:31 -0800 Subject: [PATCH] fix(workflows): prevent auto_advance config from persisting across sessions Introduce ephemeral `workflow._auto_chain_active` flag to separate chain propagation from the user's persistent `workflow.auto_advance` preference. Previously, `workflow.auto_advance` was set to true by --auto chains and only cleared at milestone completion. If a chain was interrupted (context limit, crash, user abort), the flag persisted in .planning/config.json and caused all subsequent manual invocations to auto-advance unexpectedly. The fix adds a "sync chain flag with intent" step to discuss-phase, plan-phase, and execute-phase workflows: when --auto is NOT in arguments, the ephemeral _auto_chain_active flag is cleared. The persistent auto_advance setting (from /gsd:settings) is never touched, preserving the user's deliberate preference. Closes #857 Co-Authored-By: Claude Opus 4.6 --- agents/gsd-executor.md | 5 +++-- get-shit-done/references/checkpoints.md | 2 +- get-shit-done/workflows/discuss-phase.md | 15 +++++++++++---- get-shit-done/workflows/execute-phase.md | 17 +++++++++++++---- get-shit-done/workflows/new-project.md | 4 ++-- get-shit-done/workflows/plan-phase.md | 11 +++++++++-- get-shit-done/workflows/transition.md | 4 ++-- 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/agents/gsd-executor.md b/agents/gsd-executor.md index 55c4f14c5..e5989f648 100644 --- a/agents/gsd-executor.md +++ b/agents/gsd-executor.md @@ -205,13 +205,14 @@ Do NOT continue reading. Analysis without action is a stuck signal. -Check if auto mode is active at executor start: +Check if auto mode is active at executor start (chain flag or user preference): ```bash +AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false") AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false") ``` -Store the result for checkpoint handling below. +Auto mode is active if either `AUTO_CHAIN` or `AUTO_CFG` is `"true"`. Store the result for checkpoint handling below. diff --git a/get-shit-done/references/checkpoints.md b/get-shit-done/references/checkpoints.md index 04db7ade2..232817480 100644 --- a/get-shit-done/references/checkpoints.md +++ b/get-shit-done/references/checkpoints.md @@ -8,7 +8,7 @@ Plans execute autonomously. Checkpoints formalize interaction points where human 2. **Claude sets up the verification environment** - Start dev servers, seed databases, configure env vars 3. **User only does what requires human judgment** - Visual checks, UX evaluation, "does this feel right?" 4. **Secrets come from user, automation comes from Claude** - Ask for API keys, then Claude uses them via CLI -5. **Auto-mode bypasses verification/decision checkpoints** — When `workflow.auto_advance` is true in config: human-verify auto-approves, decision auto-selects first option, human-action still stops (auth gates cannot be automated) +5. **Auto-mode bypasses verification/decision checkpoints** — When `workflow._auto_chain_active` or `workflow.auto_advance` is true in config: human-verify auto-approves, decision auto-selects first option, human-action still stops (auth gates cannot be automated) diff --git a/get-shit-done/workflows/discuss-phase.md b/get-shit-done/workflows/discuss-phase.md index d5fb5a67c..a82f36768 100644 --- a/get-shit-done/workflows/discuss-phase.md +++ b/get-shit-done/workflows/discuss-phase.md @@ -589,17 +589,24 @@ node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs(state): record Check for auto-advance trigger: 1. Parse `--auto` flag from $ARGUMENTS -2. Read `workflow.auto_advance` from config: +2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference): ```bash + if [[ ! "$ARGUMENTS" =~ --auto ]]; then + node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null + fi + ``` +3. Read both the chain flag and user preference: + ```bash + AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false") AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false") ``` -**If `--auto` flag present AND `AUTO_CFG` is not true:** Persist auto-advance to config (handles direct `--auto` usage without new-project): +**If `--auto` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct `--auto` usage without new-project): ```bash -node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow.auto_advance true +node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true ``` -**If `--auto` flag present OR `AUTO_CFG` is true:** +**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:** Display banner: ``` diff --git a/get-shit-done/workflows/execute-phase.md b/get-shit-done/workflows/execute-phase.md index 5149594ce..8d37e5994 100644 --- a/get-shit-done/workflows/execute-phase.md +++ b/get-shit-done/workflows/execute-phase.md @@ -26,6 +26,13 @@ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelizat **If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue. When `parallelization` is false, plans within a wave execute sequentially. + +**Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). Must happen before any config reads (checkpoint handling also reads auto-advance flags): +```bash +if [[ ! "$ARGUMENTS" =~ --auto ]]; then + node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null +fi +``` @@ -179,12 +186,13 @@ Plans with `autonomous: false` require user interaction. **Auto-mode checkpoint handling:** -Read auto-advance config: +Read auto-advance config (chain flag + user preference): ```bash +AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false") AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false") ``` -When executor returns a checkpoint AND `AUTO_CFG` is `"true"`: +When executor returns a checkpoint AND (`AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`): - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`. - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`. - **human-action** → Present to user (existing behavior below). Auth gates cannot be automated. @@ -405,12 +413,13 @@ STOP. Do not proceed to auto-advance or transition. **Auto-advance detection:** 1. Parse `--auto` flag from $ARGUMENTS -2. Read `workflow.auto_advance` from config: +2. Read both the chain flag and user preference (chain flag already synced in init step): ```bash + AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false") AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false") ``` -**If `--auto` flag present OR `AUTO_CFG` is true (AND verification passed with no gaps):** +**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true (AND verification passed with no gaps):** ``` ╔══════════════════════════════════════════╗ diff --git a/get-shit-done/workflows/new-project.md b/get-shit-done/workflows/new-project.md index c2d2e2ba8..0ccd254a9 100644 --- a/get-shit-done/workflows/new-project.md +++ b/get-shit-done/workflows/new-project.md @@ -191,10 +191,10 @@ mkdir -p .planning node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "chore: add project config" --files .planning/config.json ``` -**Persist auto-advance to config (survives context compaction):** +**Persist auto-advance chain flag to config (survives context compaction):** ```bash -node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow.auto_advance true +node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true ``` Proceed to Step 4 (skip Steps 3 and 5). diff --git a/get-shit-done/workflows/plan-phase.md b/get-shit-done/workflows/plan-phase.md index 4ac899b7e..bfa8d136c 100644 --- a/get-shit-done/workflows/plan-phase.md +++ b/get-shit-done/workflows/plan-phase.md @@ -441,12 +441,19 @@ Route to `` OR `auto_advance` depending on flags/config. Check for auto-advance trigger: 1. Parse `--auto` flag from $ARGUMENTS -2. Read `workflow.auto_advance` from config: +2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference): ```bash + if [[ ! "$ARGUMENTS" =~ --auto ]]; then + node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null + fi + ``` +3. Read both the chain flag and user preference: + ```bash + AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false") AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false") ``` -**If `--auto` flag present OR `AUTO_CFG` is true:** +**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:** Display banner: ``` diff --git a/get-shit-done/workflows/transition.md b/get-shit-done/workflows/transition.md index 553fc193b..5e8927dfd 100644 --- a/get-shit-done/workflows/transition.md +++ b/get-shit-done/workflows/transition.md @@ -451,9 +451,9 @@ Exit skill and invoke SlashCommand("/gsd:discuss-phase [X+1] --auto") **Route B: Milestone complete (all phases done)** -**Clear auto-advance** — milestone boundary is the natural stopping point: +**Clear auto-advance chain flag** — milestone boundary is the natural stopping point: ```bash -node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow.auto_advance false +node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false ```