Files
msd-core/get-shit-done/workflows/insert-phase.md
TÂCHES 1b317dec45 feat: extract repetitive bash patterns into gsd-tools commands (#472)
* feat(gsd-tools): add history-digest, atomic state operations, and summary variants

Adds new performance-focused commands to gsd-tools and introduces specialized
summary templates to reduce context tax:

- history-digest: Compiles phase summaries into structured JSON for JIT loading
- state get/patch: Enables atomic STATE.md operations instead of full rewrites
- template select: Automatically chooses optimal summary template based on plan complexity
- Adds minimal, standard, and complex summary templates

Part of the "Hydra" architecture for GSD context optimization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: add project config

* docs: define v1 requirements

* docs: create roadmap (6 phases)

* feat(history-digest): fix nested YAML parsing and add tests

- Fix extractFrontmatter() to handle nested YAML structures like
  dependency-graph.provides, tech-stack.added using stack-based parsing
- Add test infrastructure with Node test runner (npm test)
- Update gsd-planner to use digest fields directly instead of reading
  full SUMMARY.md files
- Add 6 schema validation tests covering nested fields, merging,
  malformed files, and backward compatibility

Closes: HIST-01, HIST-02, HIST-03, HIST-04

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(planner): use digest for selection, full SUMMARY for understanding

The previous commit went too far by eliminating full SUMMARY reads.
The digest is an index for smart selection, not a replacement for
understanding what actually happened.

Two-step approach:
1. Digest to score/select relevant phases (2-4 typically)
2. Full SUMMARY read for selected phases (implementation details)
3. Digest-level context retained for unselected phases

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(gsd-tools): add phases, roadmap, and phase commands

TDD implementation of three new commands to replace repetitive bash:

phases list [--type plans|summaries] [--phase N]
- Lists phase directories sorted numerically (handles decimals)
- Filter by file type or specific phase
- Replaces: ls -d .planning/phases/*/ | sort -V (22 occurrences)

roadmap get-phase <N>
- Extracts phase section from ROADMAP.md
- Returns name, goal, full section content
- Replaces: grep -A20 "Phase X:" ROADMAP.md (19 occurrences)

phase next-decimal <N>
- Calculates next decimal phase (06 → 06.1, 06.2 → 06.3)
- Handles gaps, normalizes input
- Replaces: complex bash math in insert-phase (3 occurrences)

16 new tests, all passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: migrate agents/workflows to use gsd-tools commands

Replace inline bash patterns with centralized gsd-tools commands:

phases list:
- audit-milestone.md: ls -d .planning/phases/*/ | sort -V
- plan-milestone-gaps.md: ls -d ... | sort -V | tail -1

roadmap get-phase:
- plan-phase.md: grep -A5 "Phase X:" ROADMAP.md (2 occurrences)
- research-phase.md: grep patterns (2 occurrences)
- verify-phase.md: grep -A5 pattern
- gsd-verifier.md: grep -A5 pattern
- gsd-plan-checker.md: grep -A10 pattern
- commands/gsd/research-phase.md: grep patterns (2 occurrences)

phase next-decimal:
- insert-phase.md: complex bash decimal calculation
- decimal-phase-calculation.md: reference doc rewritten

phase-argument-parsing.md: updated to reference gsd-tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-08 00:44:49 -06:00

5.6 KiB

Insert a decimal phase for urgent work discovered mid-milestone between existing integer phases. Uses decimal numbering (72.1, 72.2, etc.) to preserve the logical sequence of planned phases while accommodating urgent insertions without renumbering the entire roadmap.

<required_reading> Read all files referenced by the invoking prompt's execution_context before starting. </required_reading>

Parse the command arguments: - First argument: integer phase number to insert after - Remaining arguments: phase description

Example: /gsd:insert-phase 72 Fix critical auth bug -> after = 72 -> description = "Fix critical auth bug"

Validation:

if [ $# -lt 2 ]; then
  echo "ERROR: Both phase number and description required"
  echo "Usage: /gsd:insert-phase <after> <description>"
  echo "Example: /gsd:insert-phase 72 Fix critical auth bug"
  exit 1
fi

Parse first argument as integer:

after_phase=$1
shift
description="$*"

# Validate after_phase is an integer
if ! [[ "$after_phase" =~ ^[0-9]+$ ]]; then
  echo "ERROR: Phase number must be an integer"
  exit 1
fi
Load phase operation context:
INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js init phase-op "${after_phase}")

Check roadmap_exists from init JSON. If false:

ERROR: No roadmap found (.planning/ROADMAP.md)

Exit.

Read roadmap content for parsing.

Verify that the target phase exists in the roadmap:
  1. Search for "### Phase {after_phase}:" heading

  2. If not found:

    ERROR: Phase {after_phase} not found in roadmap
    Available phases: [list phase numbers]
    

    Exit.

  3. Verify phase is in current milestone (not completed/archived)

Calculate next decimal phase number:
DECIMAL_INFO=$(node ~/.claude/get-shit-done/bin/gsd-tools.js phase next-decimal "${after_phase}")

Extract from JSON:

  • next: The next available decimal (e.g., "06.1", "06.3")
  • existing: Array of existing decimals (e.g., ["06.1", "06.2"])
  • base_phase: Normalized base phase (e.g., "06")

Store the result:

decimal_phase=$(echo "$DECIMAL_INFO" | jq -r '.next')

Examples:

  • Phase 72 with no decimals -> next is 72.1
  • Phase 72 with 72.1 -> next is 72.2
  • Phase 72 with 72.1, 72.2 -> next is 72.3
Convert the phase description to a kebab-case slug.

Use generate-slug command (init phase-op provides phase_slug for existing phase, but this is a new phase):

slug=$(node ~/.claude/get-shit-done/bin/gsd-tools.js generate-slug "$description" --raw)

Phase directory name: {decimal-phase}-{slug} Example: 06.1-fix-critical-auth-bug (phase 6 insertion)

Create the phase directory structure:
phase_dir=".planning/phases/${decimal_phase}-${slug}"
mkdir -p "$phase_dir"

Confirm: "Created directory: $phase_dir"

Insert the new phase entry into the roadmap:
  1. Find insertion point: immediately after Phase {after_phase}'s content (before next phase heading or "---")

  2. Insert new phase heading with (INSERTED) marker:

    ### Phase {decimal_phase}: {Description} (INSERTED)
    
    **Goal:** [Urgent work - to be planned]
    **Depends on:** Phase {after_phase}
    **Plans:** 0 plans
    
    Plans:
    - [ ] TBD (run /gsd:plan-phase {decimal_phase} to break down)
    
    **Details:**
    [To be added during planning]
    
  3. Write updated roadmap back to file

The "(INSERTED)" marker helps identify decimal phases as urgent insertions.

Preserve all other content exactly (formatting, spacing, other phases).

Update STATE.md to reflect the inserted phase:
  1. Read .planning/STATE.md
  2. Under "## Accumulated Context" -> "### Roadmap Evolution" add entry:
    - Phase {decimal_phase} inserted after Phase {after_phase}: {description} (URGENT)
    

If "Roadmap Evolution" section doesn't exist, create it.

Add note about insertion reason if appropriate.

Present completion summary:
Phase {decimal_phase} inserted after Phase {after_phase}:
- Description: {description}
- Directory: .planning/phases/{decimal-phase}-{slug}/
- Status: Not planned yet
- Marker: (INSERTED) - indicates urgent work

Roadmap updated: {roadmap-path}
Project state updated: .planning/STATE.md

---

## Next Up

**Phase {decimal_phase}: {description}** -- urgent insertion

`/gsd:plan-phase {decimal_phase}`

<sub>`/clear` first -> fresh context window</sub>

---

**Also available:**
- Review insertion impact: Check if Phase {next_integer} dependencies still make sense
- Review roadmap

---

<anti_patterns>

  • Don't use this for planned work at end of milestone (use /gsd:add-phase)
  • Don't insert before Phase 1 (decimal 0.1 makes no sense)
  • Don't renumber existing phases
  • Don't modify the target phase content
  • Don't create plans yet (that's /gsd:plan-phase)
  • Don't commit changes (user decides when to commit) </anti_patterns>

<success_criteria> Phase insertion is complete when:

  • Phase directory created: .planning/phases/{N.M}-{slug}/
  • Roadmap updated with new phase entry (includes "(INSERTED)" marker)
  • Phase inserted in correct position (after target phase, before next integer phase)
  • STATE.md updated with roadmap evolution note
  • Decimal number calculated correctly (based on existing decimals)
  • User informed of next steps and dependency implications </success_criteria>