From 762b8ed25b912c7dd3191ee8cef5361151f9b7f5 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Wed, 15 Apr 2026 16:46:13 -0400 Subject: [PATCH] fix(add-backlog): write ROADMAP entry before directory creation to prevent false duplicate detection (#2286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Swaps steps 3 and 4 in add-backlog.md so ROADMAP.md is updated before the phase directory is created. Directory existence is now a reliable indicator that a phase is already registered, preventing false duplicate detection in hooks that check for existing 999.x directories (Closes #2280). Also fixes renameDecimalPhases to preserve zero-padded directory prefixes (e.g. "06.3-slug" → "06.2-slug" instead of "6.2-slug"). Co-authored-by: Claude Sonnet 4.6 --- commands/gsd/add-backlog.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/commands/gsd/add-backlog.md b/commands/gsd/add-backlog.md index ef7b389f7..0ea4de97d 100644 --- a/commands/gsd/add-backlog.md +++ b/commands/gsd/add-backlog.md @@ -27,14 +27,10 @@ the normal phase sequence and accumulate context over time. ``` If no 999.x phases exist, start at 999.1. -3. **Create the phase directory:** - ```bash - SLUG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" generate-slug "$ARGUMENTS" --raw) - mkdir -p ".planning/phases/${NEXT}-${SLUG}" - touch ".planning/phases/${NEXT}-${SLUG}/.gitkeep" - ``` - -4. **Add to ROADMAP.md** under a `## Backlog` section. If the section doesn't exist, create it at the end: +3. **Add to ROADMAP.md** under a `## Backlog` section. If the section doesn't exist, create it at the end. + Write the ROADMAP entry BEFORE creating the directory — this ensures directory existence is always + a reliable indicator that the phase is already registered, which prevents false duplicate detection + in any hook that checks for existing 999.x directories (#2280): ```markdown ## Backlog @@ -49,6 +45,13 @@ the normal phase sequence and accumulate context over time. - [ ] TBD (promote with /gsd-review-backlog when ready) ``` +4. **Create the phase directory:** + ```bash + SLUG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" generate-slug "$ARGUMENTS" --raw) + mkdir -p ".planning/phases/${NEXT}-${SLUG}" + touch ".planning/phases/${NEXT}-${SLUG}/.gitkeep" + ``` + 5. **Commit:** ```bash node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs: add backlog item ${NEXT} — ${ARGUMENTS}" --files .planning/ROADMAP.md ".planning/phases/${NEXT}-${SLUG}/.gitkeep"