The AI Daemon: Unpacking gsd-build/gsd-2

How a TypeScript state machine and a native Rust core turned conversational coding agents into deterministic, headless subprocesses.

8 min read • View on GitHub • More from gsd-build

A classic pocket watch where the internal gears are replaced by a miniature, highly organized filing cabinet, representing the structured, deterministic state machine replacing chaotic LLM loops.
GSD-2 replaces the unpredictable nature of conversational LLMs with a rigid, filesystem-backed state machine.

Apologies on this - I've been trying to fix this serious foundational problems that will be ideally shipped this evening.

glittercowboy, Maintainer · Issue #528 · gsd-build/gsd-2
Key Takeaways

The Autonomy Paradox

Leaving an artificial intelligence coding agent alone for an hour usually results in one of two outcomes. You either return to a destroyed repository, or you find the agent stuck in an infinite loop of failing tests. This is the autonomy paradox. The more freedom you give an agent, the faster it spirals into a hallucinated state.

GSD-2 solves this with a surprisingly simple concept: knowing when to stop. Instead of guessing how to fix a complex block of code, a mature agent must know how to fail gracefully. The orchestrator uses specific process exit codes, like Exit Code 10 for 'Blocked', to pause execution and request human input rather than destroying the codebase.

A tightly wound spring mechanism that has deliberately disengaged a single gear to prevent overheating, with a small mechanical flag raised.
Exit Code 10 acts as a designed safety mechanism, deliberately breaking the execution loop when confidence drops.

The Filesystem as the Program Counter

The original version of GSD was a prompt framework for Claude Code. It failed because it relied on the LLM to remember what it was doing. GSD-2 pivots entirely. It treats the filesystem as the brain.

The `.gsd/STATE.md` directory acts as a literal program counter. If the Node.js process crashes or the LLM times out, the agent simply reads the markdown file to resume exactly where it left off. The prompt is dead. The markdown specification is the new database.

One command. Walk away. Come back to a built project with clean git history.

GSD Documentation, Project README · gsd-build/gsd-2

The Branchless Worktree architecture isolates LLM hallucinations from the main codebase until verification passes.

Forging the Rust Core

A TypeScript state machine is elegant, but relying on `execSync` for shell commands kills agent performance. Latency is the enemy of autonomy. To solve this, the maintainers built a native Rust core.

Using `napi-rs`, GSD-2 binds Node.js directly to a Rust workspace for AST parsing and native `libgit2` operations. This enables the 'Branchless Worktree' architecture. The agent can carve out invisible Git worktrees, experiment, and fail without ever touching the main branch or spawning expensive subshells.

Portrait of glittercowboy, lead maintainer of GSD-2.

Engineering Amnesia

Context rot is a phenomenon where agents forget the overarching architecture after executing too many terminal commands. They get lost in the weeds of a specific compiler error and forget the system design.

GSD-2 combats this with aggressive context resets. It uses a Runtime ToolKit (RTK) to compress shell output. When a new task starts, the orchestrator spins up a fresh subagent context, injecting only the necessary files like `DECISIONS.md`. It forces the LLM to read the architectural constraints fresh every time.

Execution Over Ceremony

The Spec-Driven Development landscape is diverging. On one side are enterprise tools built for organizational standardization and phase gates. On the other side is GSD-2, built explicitly for raw execution speed and solo creators.

Other spec-driven development tools exist—BMAD, Speckit… But they all seem to make things way more complicated than they need to be. Sprint ceremonies, story points, stakeholder syncs, retrospectives, Jira workflows. I’m not a 50-person software company. I don’t want to play enterprise theater.

Unknown, Quoted Creator (via Prahlad Menon's blog) · Solving Context Rot: GSD vs BMAD vs Taskmaster for AI Coding Agents
FeatureGSD-2Spec KitOpenSpec
Core PhilosophyExecution-layer orchestrationStructured organizational phasesLightweight change isolation
Context StrategyAggressive resets and fresh contextsAgent-agnostic portabilityBrownfield-first adaptation
Primary LanguageTypeScript / RustN/AN/A