Files
msd-core/get-shit-done/references/workstream-flag.md
Tom Boucher 0fbe1d899e chore(#191): retire the gsd-sdk shim — route everything at gsd-tools (#522)
* chore(#191): migrate gsd-sdk query call sites to gsd-tools query

Retiring the gsd-sdk shim. gsd-tools.cjs already accepts `query` as a
meta-prefix (gsd-tools query <command>), so this is a behavior-preserving 1:1
swap across the runtime reference prompts, the graphify hook's commit-detection
gate, and two bin/lib comment/message references.

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

* chore(#191): remove vestigial gsd-sdk shim code from installer + projection

The gsd-sdk shim was already not wired up (no gsd-sdk bin in package.json;
buildWindowsShimTriple had zero call sites). Remove the dead code:
- shell-command-projection.cjs: buildWindowsShimTriple + formatSdkPathDiagnostic
  (+ their now-unused PACKAGE_NAME import) and exports
- install.js: the re-export wrappers + imports, the #3406 stale-standalone-sdk
  detection (detectStaleStandaloneSdk/formatStaleStandaloneSdkWarning + its
  global-install call site), and the exports

Preserved (retained, not gsd-sdk): buildCodexHookWindowsShimIR (#3426) — only
its comments referenced the gsd-sdk pattern; reworded. Also kept the
homePathCoveredByRc 'reopen your shell' branch in maybeSuggestPathExport — its
logic is bin-dir-agnostic, only the message mentioned gsd-sdk; reworded to use
the actual bin dir.

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

* test(#191): update tests for retired gsd-sdk shim

- bug-3441/bug-3442: drop the formatSdkPathDiagnostic / buildWindowsShimTriple
  assertions (functions removed); retained PATH-action + drift-guard tests stay
- bug-505: remove the 'still exported' assertions for detectStaleStandaloneSdk /
  formatStaleStandaloneSdkWarning / the shim contract surface (#505 kept them;
  #191 removes them)
- graphify-auto-update: migrate the hook-dispatch inputs gsd-sdk query commit ->
  gsd-tools query commit to match the migrated commit hook

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

* docs(#191): point active docs at gsd-tools query (gsd-sdk shim retired)

Update the user/agent-facing docs (AGENTS, COMMANDS, CONFIGURATION, USER-GUIDE,
ship-pr-body-sections) that presented gsd-sdk query as a current command to
gsd-tools query. Historical docs (ADRs, PRDs, release notes) left untouched.

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

* docs(#191): correct state.load vs state.json description for gsd-tools query

Adversarial-review (codex) finding: the migrated USER-GUIDE line claimed both
'gsd-tools query state.json' and 'state.load' resolve to the frontmatter-rebuild
handler. Verified they don't — state.load returns the CJS load shape
(config + state_raw + flags), state.json returns the frontmatter shape. Both are
available via gsd-tools query; corrected the text to say so.

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

* chore(#191): add changeset for gsd-sdk shim retirement

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 19:19:14 -04:00

4.5 KiB

Workstream Flag (--ws)

Overview

The --ws <name> flag scopes GSD operations to a specific workstream, enabling parallel milestone work by multiple Claude Code instances on the same codebase.

Resolution Priority

  1. --ws <name> flag (explicit, highest priority)
  2. GSD_WORKSTREAM environment variable (per-instance)
  3. Session-scoped active workstream pointer in temp storage (per runtime session / terminal)
  4. .planning/active-workstream file (legacy shared fallback when no session key exists)
  5. null — flat mode (no workstreams)

Why session-scoped pointers exist

The shared .planning/active-workstream file is fundamentally unsafe when multiple Claude/Codex instances are active on the same repo at the same time. One session can silently repoint another session's STATE.md, ROADMAP.md, and phase paths.

GSD now prefers a session-scoped pointer keyed by runtime/session identity (GSD_SESSION_KEY, CODEX_THREAD_ID, CLAUDE_CODE_SSE_PORT, terminal session IDs, or the controlling TTY). This keeps concurrent sessions isolated while preserving legacy compatibility for runtimes that do not expose a stable session key.

Session Identity Resolution

When GSD resolves the session-scoped pointer in step 3 above, it uses this order:

  1. Explicit runtime/session env vars such as GSD_SESSION_KEY, CODEX_THREAD_ID, CLAUDE_SESSION_ID, CLAUDE_CODE_SSE_PORT, OPENCODE_SESSION_ID, GEMINI_SESSION_ID, CURSOR_SESSION_ID, WINDSURF_SESSION_ID, TERM_SESSION_ID, WT_SESSION, TMUX_PANE, and ZELLIJ_SESSION_NAME
  2. TTY or SSH_TTY if the shell/runtime already exposes the terminal path
  3. A single best-effort tty probe, but only when stdin is interactive

If none of those produce a stable identity, GSD does not keep probing. It falls back directly to the legacy shared .planning/active-workstream file.

This matters in headless or stripped environments: when stdin is already non-interactive, GSD intentionally skips shelling out to tty because that path cannot discover a stable session identity and only adds avoidable failures on the routing hot path.

Pointer Lifecycle

Session-scoped pointers are intentionally lightweight and best-effort:

  • Clearing a workstream for one session removes only that session's pointer file
  • If that was the last pointer for the repo, GSD also removes the now-empty per-project temp directory
  • If sibling session pointers still exist, the temp directory is left in place
  • When a pointer refers to a workstream directory that no longer exists, GSD treats it as stale state: it removes that pointer file and resolves to null until the session explicitly sets a new active workstream again

GSD does not currently run a background garbage collector for historical temp directories. Cleanup is opportunistic at the pointer being cleared or self-healed, and broader temp hygiene is left to OS temp cleanup or future maintenance work.

Routing Propagation

All workflow routing commands include ${GSD_WS} which:

  • Expands to --ws <name> when a workstream is active
  • Expands to empty string in flat mode (backward compatible)

This ensures workstream scope chains automatically through the workflow: new-milestone → discuss-phase → plan-phase → execute-phase → transition

Directory Structure

.planning/
├── PROJECT.md          # Shared
├── config.json         # Shared
├── milestones/         # Shared
├── codebase/           # Shared
├── active-workstream   # Legacy shared fallback only
└── workstreams/
    ├── feature-a/      # Workstream A
    │   ├── STATE.md
    │   ├── ROADMAP.md
    │   ├── REQUIREMENTS.md
    │   └── phases/
    └── feature-b/      # Workstream B
        ├── STATE.md
        ├── ROADMAP.md
        ├── REQUIREMENTS.md
        └── phases/

CLI Usage

# All gsd-tools query commands accept --ws
gsd-tools query state.json --ws feature-a
gsd-tools query find-phase 3 --ws feature-b

# Session-local switching without --ws on every command
GSD_SESSION_KEY=my-terminal-a gsd-tools query workstream.set feature-a
GSD_SESSION_KEY=my-terminal-a gsd-tools query state.json
GSD_SESSION_KEY=my-terminal-b gsd-tools query workstream.set feature-b
GSD_SESSION_KEY=my-terminal-b gsd-tools query state.json

# Workstream CRUD
gsd-tools query workstream.create <name>
gsd-tools query workstream.list
gsd-tools query workstream.status <name>
gsd-tools query workstream.complete <name>