docs/ARCHITECTURE.md
System architecture for contributors and advanced users. For user-facing documentation, see Feature Reference or User Guide.
GSD is a meta-prompting framework that sits between the user and AI coding agents (Claude Code, Gemini CLI, OpenCode, Kilo, Codex, Copilot, Antigravity, Trae, Cline, Augment Code). It provides:
┌──────────────────────────────────────────────────────┐
│ USER │
│ /gsd-command [args] │
└─────────────────────┬────────────────────────────────┘
│
┌─────────────────────▼────────────────────────────────┐
│ COMMAND LAYER │
│ commands/gsd/*.md — Prompt-based command files │
│ (Claude Code custom commands / Codex skills) │
└─────────────────────┬────────────────────────────────┘
│
┌─────────────────────▼────────────────────────────────┐
│ WORKFLOW LAYER │
│ get-shit-done/workflows/*.md — Orchestration logic │
│ (Reads references, spawns agents, manages state) │
└──────┬──────────────┬─────────────────┬──────────────┘
│ │ │
┌──────▼──────┐ ┌─────▼─────┐ ┌────────▼───────┐
│ AGENT │ │ AGENT │ │ AGENT │
│ (fresh │ │ (fresh │ │ (fresh │
│ context) │ │ context)│ │ context) │
└──────┬──────┘ └─────┬─────┘ └────────┬───────┘
│ │ │
┌──────▼──────────────▼─────────────────▼──────────────┐
│ CLI TOOLS LAYER │
│ gsd-sdk query (sdk/src/query) + gsd-tools.cjs │
│ (State, config, phase, roadmap, verify, templates) │
└──────────────────────┬───────────────────────────────┘
│
┌──────────────────────▼───────────────────────────────┐
│ FILE SYSTEM (.planning/) │
│ PROJECT.md | REQUIREMENTS.md | ROADMAP.md │
│ STATE.md | config.json | phases/ | research/ │
└──────────────────────────────────────────────────────┘
Every agent spawned by an orchestrator gets a clean context window (up to 200K tokens). This eliminates context rot — the quality degradation that happens as an AI fills its context window with accumulated conversation.
Workflow files (get-shit-done/workflows/*.md) never do heavy lifting. They:
gsd-sdk query init.<workflow> (or legacy gsd-tools.cjs init <workflow>)All state lives in .planning/ as human-readable Markdown and JSON. No database, no server, no external dependencies. This means:
/clear)Workflow feature flags follow the absent = enabled pattern. If a key is missing from config.json, it defaults to true. Users explicitly disable features; they don't need to enable defaults.
Multiple layers prevent common failure modes:
commands/gsd/*.md)User-facing entry points. Each file contains YAML frontmatter (name, description, allowed-tools) and a prompt body that bootstraps the workflow. Commands are installed as:
/gsd-command-name)/gsd-command-name)$gsd-command-name)/gsd-command-name)Total commands: see docs/INVENTORY.md for the authoritative count and full roster.
get-shit-done/workflows/*.md)Orchestration logic that commands reference. Contains the step-by-step process including:
gsd-sdk query init handlers (or legacy gsd-tools.cjs init)Total workflows: see docs/INVENTORY.md for the authoritative count and full roster.
Workflow files are loaded verbatim into Claude's context every time the
corresponding /gsd-* command is invoked. To keep that cost bounded, the
workflow size budget enforced by tests/workflow-size-budget.test.cjs
mirrors the agent budget from #2361:
| Tier | Per-file line limit |
|---|---|
XL | 1700 — top-level orchestrators (execute-phase, plan-phase, new-project) |
LARGE | 1500 — multi-step planners and large feature workflows |
DEFAULT | 1000 — focused single-purpose workflows (the target tier) |
workflows/discuss-phase.md is held to a stricter <500-line ceiling per
issue #2551. When a workflow grows beyond its tier, extract per-mode bodies
into workflows/<workflow>/modes/<mode>.md, templates into
workflows/<workflow>/templates/, and shared knowledge into
get-shit-done/references/. The parent file becomes a thin dispatcher that
Reads only the mode and template files needed for the current invocation.
workflows/discuss-phase/ is the canonical example of this pattern —
parent dispatches, modes/ holds per-flag behavior (power.md, all.md,
auto.md, chain.md, text.md, batch.md, analyze.md, default.md,
advisor.md), and templates/ holds CONTEXT.md, DISCUSSION-LOG.md, and
checkpoint.json schemas that are read only when the corresponding output
file is being written.
agents/*.md)Specialized agent definitions with frontmatter specifying:
name — Agent identifierdescription — Role and purposetools — Allowed tool access (Read, Write, Edit, Bash, Grep, Glob, WebSearch, etc.)color — Terminal output color for visual distinctionTotal agents: 33
get-shit-done/references/*.md)Shared knowledge documents that workflows and agents @-reference (see docs/INVENTORY.md for the authoritative count and full roster):
Core references:
checkpoints.md — Checkpoint type definitions and interaction patternsgates.md — 4 canonical gate types (Confirm, Quality, Safety, Transition) wired into plan-checker and verifiermodel-profiles.md — Per-agent model tier assignmentsmodel-profile-resolution.md — Model resolution algorithm documentationverification-patterns.md — How to verify different artifact typesverification-overrides.md — Per-artifact verification override rulesplanning-config.md — Full config schema and behaviorgit-integration.md — Git commit, branching, and history patternsgit-planning-commit.md — Planning directory commit conventionsquestioning.md — Dream extraction philosophy for project initializationtdd.md — Test-driven development integration patternsui-brand.md — Visual output formatting patternscommon-bug-patterns.md — Common bug patterns for code review and verificationWorkflow references:
agent-contracts.md — Formal interface between orchestrators and agentscontext-budget.md — Context window budget allocation rulescontinuation-format.md — Session continuation/resume formatdomain-probes.md — Domain-specific probing questions for discuss-phasegate-prompts.md — Gate/checkpoint prompt templatesrevision-loop.md — Plan revision iteration patternsuniversal-anti-patterns.md — Common anti-patterns to detect and avoidartifact-types.md — Planning artifact type definitionsphase-argument-parsing.md — Phase argument parsing conventionsdecimal-phase-calculation.md — Decimal sub-phase numbering rulesworkstream-flag.md — Workstream active pointer conventionsuser-profiling.md — User behavioral profiling methodologythinking-partner.md — Conditional thinking partner activation at decision pointsThinking model references:
References for integrating thinking-class models (o3, o4-mini, Gemini 2.5 Pro) into GSD workflows:
thinking-models-debug.md — Thinking model patterns for debugging workflowsthinking-models-execution.md — Thinking model patterns for execution agentsthinking-models-planning.md — Thinking model patterns for planning agentsthinking-models-research.md — Thinking model patterns for research agentsthinking-models-verification.md — Thinking model patterns for verification agentsModular planner decomposition:
The planner agent (agents/gsd-planner.md) was decomposed from a single monolithic file into a core agent plus reference modules to stay under the 50K character limit imposed by some runtimes:
planner-gap-closure.md — Gap closure mode behavior (reads VERIFICATION.md, targeted replanning)planner-reviews.md — Cross-AI review integration (reads REVIEWS.md from /gsd-review)planner-revision.md — Plan revision patterns for iterative refinementget-shit-done/templates/)Markdown templates for all planning artifacts. Used by gsd-sdk query template.fill / phase.scaffold (and legacy gsd-tools.cjs template fill / top-level scaffold) to create pre-structured files:
project.md, requirements.md, roadmap.md, state.md — Core project filesphase-prompt.md — Phase execution prompt templatesummary.md (+ summary-minimal.md, summary-standard.md, summary-complex.md) — Granularity-aware summary templatesDEBUG.md — Debug session tracking templateUI-SPEC.md, UAT.md, VALIDATION.md — Specialized verification templatesdiscussion-log.md — Discussion audit trail templatecodebase/ — Brownfield mapping templates (stack, architecture, conventions, concerns, structure, testing, integrations)research-project/ — Research output templates (SUMMARY, STACK, FEATURES, ARCHITECTURE, PITFALLS)hooks/)Runtime hooks that integrate with the host AI agent:
| Hook | Event | Purpose |
|---|---|---|
gsd-statusline.js | statusLine | Displays model, task, directory, and context usage bar |
gsd-context-monitor.js | PostToolUse / AfterTool | Injects agent-facing context warnings at 35%/25% remaining |
gsd-check-update.js | SessionStart | Foreground trigger for the background update check |
gsd-check-update-worker.js | (helper) | Background worker spawned by gsd-check-update.js; no direct event registration |
gsd-prompt-guard.js | PreToolUse | Scans .planning/ writes for prompt injection patterns (advisory) |
gsd-read-injection-scanner.js | PostToolUse | Scans Read tool output for injected instructions in untrusted content |
gsd-workflow-guard.js | PreToolUse | Detects file edits outside GSD workflow context (advisory, opt-in via hooks.workflow_guard) |
gsd-read-guard.js | PreToolUse | Advisory guard preventing Edit/Write on files not yet read in the session |
gsd-session-state.sh | PostToolUse | Session state tracking for shell-based runtimes |
gsd-validate-commit.sh | PostToolUse | Commit validation for conventional commit enforcement |
gsd-phase-boundary.sh | PostToolUse | Phase boundary detection for workflow transitions |
See docs/INVENTORY.md for the authoritative 11-hook roster.
get-shit-done/bin/)Node.js CLI utility (gsd-tools.cjs) with domain modules split across get-shit-done/bin/lib/ (see docs/INVENTORY.md for the authoritative roster):
| Module | Responsibility |
|---|---|
core.cjs | Error handling, output formatting, shared utilities; compatibility re-exports for planning helpers |
planning-workspace.cjs | Planning seam (planningDir, planningPaths, active workstream routing, .planning/.lock) |
state.cjs | STATE.md parsing, updating, progression, metrics |
phase.cjs | Phase directory operations, decimal numbering, plan indexing |
roadmap.cjs | ROADMAP.md parsing, phase extraction, plan progress |
config.cjs | config.json read/write, section initialization |
verify.cjs | Plan structure, phase completeness, reference, commit validation |
template.cjs | Template selection and filling with variable substitution |
frontmatter.cjs | YAML frontmatter CRUD operations |
init.cjs | Compound context loading for each workflow type |
milestone.cjs | Milestone archival, requirements marking |
commands.cjs | Misc commands (slug, timestamp, todos, scaffolding, stats) |
model-profiles.cjs | Model profile resolution table |
security.cjs | Path traversal prevention, prompt injection detection, safe JSON parsing, shell argument validation |
uat.cjs | UAT file parsing, verification debt tracking, audit-uat support |
docs.cjs | Docs-update workflow init, Markdown scanning, monorepo detection |
workstream.cjs | Workstream CRUD, migration, session-scoped active pointer |
schema-detect.cjs | Schema-drift detection for ORM patterns (Prisma, Drizzle, etc.) |
profile-pipeline.cjs | User behavioral profiling data pipeline, session file scanning |
profile-output.cjs | Profile rendering, USER-PROFILE.md and dev-preferences.md generation |
Orchestrator (workflow .md)
│
├── Load context: gsd-sdk query init.<workflow> <phase> (or legacy gsd-tools.cjs init)
│ Returns JSON with: project info, config, state, phase details
│
├── Resolve model: gsd-sdk query resolve-model <agent-name>
│ Returns: opus | sonnet | haiku | inherit
│
├── Spawn Agent (Task/SubAgent call)
│ ├── Agent prompt (agents/*.md)
│ ├── Context payload (init JSON)
│ ├── Model assignment
│ └── Tool permissions
│
├── Collect result
│
└── Update state: gsd-sdk query state.update / state.patch / state.advance-plan (or legacy gsd-tools.cjs)
Conceptual spawn-pattern taxonomy for the 21 primary agents. For the authoritative 31-agent roster (including the 10 advanced/specialized agents such as gsd-pattern-mapper, gsd-code-reviewer, gsd-code-fixer, gsd-ai-researcher, gsd-domain-researcher, gsd-eval-planner, gsd-eval-auditor, gsd-framework-selector, gsd-debug-session-manager, gsd-intel-updater), see docs/INVENTORY.md.
| Category | Agents | Parallelism |
|---|---|---|
| Researchers | gsd-project-researcher, gsd-phase-researcher, gsd-ui-researcher, gsd-advisor-researcher | 4 parallel (stack, features, architecture, pitfalls); advisor spawns during discuss-phase |
| Synthesizers | gsd-research-synthesizer | Sequential (after researchers complete) |
| Planners | gsd-planner, gsd-roadmapper | Sequential |
| Checkers | gsd-plan-checker, gsd-integration-checker, gsd-ui-checker, gsd-nyquist-auditor | Sequential (verification loop, max 3 iterations) |
| Executors | gsd-executor | Parallel within waves, sequential across waves |
| Verifiers | gsd-verifier | Sequential (after all executors complete) |
| Mappers | gsd-codebase-mapper | 4 parallel (tech, arch, quality, concerns) |
| Debuggers | gsd-debugger | Sequential (interactive) |
| Auditors | gsd-ui-auditor, gsd-security-auditor | Sequential |
| Doc Writers | gsd-doc-writer, gsd-doc-verifier | Sequential (writer then verifier) |
| Profilers | gsd-user-profiler | Sequential |
| Analyzers | gsd-assumptions-analyzer | Sequential (during discuss-phase) |
During execute-phase, plans are grouped into dependency waves:
Wave Analysis:
Plan 01 (no deps) ─┐
Plan 02 (no deps) ─┤── Wave 1 (parallel)
Plan 03 (depends: 01) ─┤── Wave 2 (waits for Wave 1)
Plan 04 (depends: 02) ─┘
Plan 05 (depends: 03,04) ── Wave 3 (waits for Wave 2)
Each executor gets:
When the context window is 500K+ tokens (1M-class models like Opus 4.6, Sonnet 4.6), subagent prompts are automatically enriched with additional context that would not fit in standard 200K windows:
The orchestrator reads context_window from config (gsd-sdk query config-get context_window, or legacy gsd-tools.cjs config-get) and conditionally includes richer context when the value is >= 500,000. For standard 200K windows, prompts use truncated versions with cache-friendly ordering to maximize context efficiency.
When multiple executors run within the same wave, two mechanisms prevent conflicts:
--no-verify commits — Parallel agents skip pre-commit hooks (which can cause build lock contention, e.g., cargo lock fights in Rust projects). The orchestrator runs git hook run pre-commit once after each wave completes.writeStateMd() calls use lockfile-based mutual exclusion (STATE.md.lock with O_EXCL atomic creation). This prevents the read-modify-write race condition where two agents read STATE.md, modify different fields, and the last writer overwrites the other's changes. Includes stale lock detection (10s timeout) and spin-wait with jitter.User input (idea description)
│
▼
Questions (questioning.md philosophy)
│
▼
4x Project Researchers (parallel)
├── Stack → STACK.md
├── Features → FEATURES.md
├── Architecture → ARCHITECTURE.md
└── Pitfalls → PITFALLS.md
│
▼
Research Synthesizer → SUMMARY.md
│
▼
Requirements extraction → REQUIREMENTS.md
│
▼
Roadmapper → ROADMAP.md
│
▼
User approval → STATE.md initialized
discuss-phase → CONTEXT.md (user preferences)
│
▼
ui-phase → UI-SPEC.md (design contract, optional)
│
▼
plan-phase
├── Research gate (blocks if RESEARCH.md has unresolved open questions)
├── Phase Researcher → RESEARCH.md
├── Planner (with reachability check) → PLAN.md files
├── Plan Checker → Verify loop (max 3x)
├── Requirements coverage gate (REQ-IDs → plans)
└── Decision coverage gate (CONTEXT.md `<decisions>` → plans, BLOCKING — #2492)
│
▼
state planned-phase → STATE.md (Planned/Ready to execute)
│
▼
execute-phase (context reduction: truncated prompts, cache-friendly ordering)
├── Wave analysis (dependency grouping)
├── Executor per plan → code + atomic commits
├── SUMMARY.md per plan
└── Verifier → VERIFICATION.md
└── Decision coverage gate (CONTEXT.md decisions → shipped artifacts, NON-BLOCKING — #2492)
│
▼
verify-work → UAT.md (user acceptance testing)
│
▼
ui-review → UI-REVIEW.md (visual audit, optional)
Each workflow stage produces artifacts that feed into subsequent stages:
PROJECT.md ────────────────────────────────────────────► All agents
REQUIREMENTS.md ───────────────────────────────────────► Planner, Verifier, Auditor
ROADMAP.md ────────────────────────────────────────────► Orchestrators
STATE.md ──────────────────────────────────────────────► All agents (decisions, blockers)
CONTEXT.md (per phase) ────────────────────────────────► Researcher, Planner, Executor
RESEARCH.md (per phase) ───────────────────────────────► Planner, Plan Checker
PLAN.md (per plan) ────────────────────────────────────► Executor, Plan Checker
SUMMARY.md (per plan) ─────────────────────────────────► Verifier, State tracking
UI-SPEC.md (per phase) ────────────────────────────────► Executor, UI Auditor
~/.claude/ # Claude Code (global install)
├── commands/gsd/*.md # Slash commands (authoritative roster: docs/INVENTORY.md)
├── get-shit-done/
│ ├── bin/gsd-tools.cjs # CLI utility
│ ├── bin/lib/*.cjs # Domain modules (authoritative roster: docs/INVENTORY.md)
│ ├── workflows/*.md # Workflow definitions (authoritative roster: docs/INVENTORY.md)
│ ├── references/*.md # Shared reference docs (authoritative roster: docs/INVENTORY.md)
│ └── templates/ # Planning artifact templates
├── agents/*.md # Agent definitions (authoritative roster: docs/INVENTORY.md)
├── hooks/*.js # Node.js hooks (statusline, guards, monitors, update check)
├── hooks/*.sh # Shell hooks (session state, commit validation, phase boundary)
├── settings.json # Hook registrations
└── VERSION # Installed version number
Equivalent paths for other runtimes:
~/.config/opencode/ or ~/.opencode/~/.config/kilo/ or ~/.kilo/~/.gemini/~/.codex/ (uses skills instead of commands)~/.github/~/.gemini/antigravity/ (global) or ./.agent/ (local).planning/).planning/
├── PROJECT.md # Project vision, constraints, decisions, evolution rules
├── REQUIREMENTS.md # Scoped requirements (v1/v2/out-of-scope)
├── ROADMAP.md # Phase breakdown with status tracking
├── STATE.md # Living memory: position, decisions, blockers, metrics
├── config.json # Workflow configuration
├── MILESTONES.md # Completed milestone archive
├── research/ # Domain research from /gsd-new-project
│ ├── SUMMARY.md
│ ├── STACK.md
│ ├── FEATURES.md
│ ├── ARCHITECTURE.md
│ └── PITFALLS.md
├── codebase/ # Brownfield mapping (from /gsd-map-codebase)
│ ├── STACK.md # YAML frontmatter carries `last_mapped_commit`
│ ├── ARCHITECTURE.md # for the post-execute drift gate (#2003)
│ ├── CONVENTIONS.md
│ ├── CONCERNS.md
│ ├── STRUCTURE.md
│ ├── TESTING.md
│ └── INTEGRATIONS.md
├── phases/
│ └── XX-phase-name/
│ ├── XX-CONTEXT.md # User preferences (from discuss-phase)
│ ├── XX-RESEARCH.md # Ecosystem research (from plan-phase)
│ ├── XX-YY-PLAN.md # Execution plans
│ ├── XX-YY-SUMMARY.md # Execution outcomes
│ ├── XX-VERIFICATION.md # Post-execution verification
│ ├── XX-VALIDATION.md # Nyquist test coverage mapping
│ ├── XX-UI-SPEC.md # UI design contract (from ui-phase)
│ ├── XX-UI-REVIEW.md # Visual audit scores (from ui-review)
│ └── XX-UAT.md # User acceptance test results
├── quick/ # Quick task tracking
│ └── YYMMDD-xxx-slug/
│ ├── PLAN.md
│ └── SUMMARY.md
├── todos/
│ ├── pending/ # Captured ideas
│ └── done/ # Completed todos
├── threads/ # Persistent context threads (from /gsd-thread)
├── seeds/ # Forward-looking ideas (from /gsd-plant-seed)
├── debug/ # Active debug sessions
│ ├── *.md # Active sessions
│ ├── resolved/ # Archived sessions
│ └── knowledge-base.md # Persistent debug learnings
├── ui-reviews/ # Screenshots from /gsd-ui-review (gitignored)
└── continue-here.md # Context handoff (from pause-work)
After the last wave of /gsd-execute-phase commits, the workflow runs a
non-blocking codebase_drift_gate step (between schema_drift_gate and
verify_phase_goal). It compares the diff last_mapped_commit..HEAD
against .planning/codebase/STRUCTURE.md and counts four kinds of
structural elements:
(packages|apps)/<name>/src/index.*routes/ or api/If the count meets workflow.drift_threshold (default 3), the gate either
warns (default) with the suggested /gsd-map-codebase --paths … command,
or auto-remaps (workflow.drift_action = auto-remap) by spawning
gsd-codebase-mapper scoped to the affected paths. Any error in detection
or remap is logged and the phase continues — drift detection cannot fail
verification.
last_mapped_commit lives in YAML frontmatter at the top of each
.planning/codebase/*.md file; bin/lib/drift.cjs provides
readMappedCommit and writeMappedCommit round-trip helpers.
The installer (bin/install.js, ~3,000 lines) handles:
--claude, --opencode, --gemini, --kilo, --codex, --copilot, --antigravity, --cursor, --windsurf, --trae, --cline, --augment, --all)--global) or local (--local)AfterTool instead of PostToolUse)~/.trae / ./.trae with no settings.json or hook integration.clinerules for rule-based integration~/.claude/ paths with runtime-specific pathssettings.jsongsd-local-patches/ for /gsd-update --reapplygsd-file-manifest.json for clean uninstall--uninstall removes all GSD files, hooks, and settingswindowsHide on child processes, EPERM/EACCES protection on protected directories, path separator normalizationCLAUDE_CONFIG_DIR env var for custom config directory locationsRuntime Engine (Claude Code / Gemini CLI)
│
├── statusLine event ──► gsd-statusline.js
│ Reads: stdin (session JSON)
│ Writes: stdout (formatted status), /tmp/claude-ctx-{session}.json (bridge)
│
├── PostToolUse/AfterTool event ──► gsd-context-monitor.js
│ Reads: stdin (tool event JSON), /tmp/claude-ctx-{session}.json (bridge)
│ Writes: stdout (hookSpecificOutput with additionalContext warning)
│
└── SessionStart event ──► gsd-check-update.js
Reads: VERSION file
Writes: ~/.claude/cache/gsd-update-check.json (spawns background process)
| Remaining Context | Level | Agent Behavior |
|---|---|---|
| > 35% | Normal | No warning injected |
| ≤ 35% | WARNING | "Avoid starting new complex work" |
| ≤ 25% | CRITICAL | "Context nearly exhausted, inform user" |
Debounce: 5 tool uses between repeated warnings. Severity escalation (WARNING→CRITICAL) bypasses debounce.
Prompt Guard (gsd-prompt-guard.js):
.planning/ filessecurity.cjs) for hook independenceWorkflow Guard (gsd-workflow-guard.js):
.planning/ files/gsd- command or Task subagent)/gsd-quick or /gsd-fast for state-tracked changeshooks.workflow_guard: true (default: false)GSD supports multiple AI coding runtimes through a unified command/workflow architecture:
| Runtime | Command Format | Agent System | Config Location |
|---|---|---|---|
| Claude Code | /gsd-command | Task spawning | ~/.claude/ |
| OpenCode | /gsd-command | Subagent mode | ~/.config/opencode/ |
| Kilo | /gsd-command | Subagent mode | ~/.config/kilo/ |
| Gemini CLI | /gsd-command | Task spawning | ~/.gemini/ |
| Codex | $gsd-command | Skills | ~/.codex/ |
| Copilot | /gsd-command | Agent delegation | ~/.github/ |
| Antigravity | Skills | Skills | ~/.gemini/antigravity/ |
| Trae | Skills | Skills | ~/.trae/ |
| Cline | Rules | Rules | .clinerules |
| Augment Code | Skills | Skills | Augment config |
Bash → Copilot's execute)PostToolUse, Gemini uses AfterToolinherit profile lets GSD defer to runtime's model selectionThe installer handles all translation at install time. Workflows and agents are written in Claude Code's native format and transformed during deployment.