Skip to main content

Architecture Overview

Genie v4 is an agent orchestration system that turns wishes (structured plans) into pull requests through autonomous AI agents. The architecture is built around five subsystems that work together.
The Genie codebase internally uses “worker” in some identifiers (e.g., workerProfiles, workers.json). In these docs, the canonical term is agent — “worker” and “agent” refer to the same thing.

High-Level Component Map

Subsystems

Data Flow: Wish to PR

1

Plan

/brainstorm/wish creates a WISH.md with execution groups and acceptance criteria.
2

Decompose

/work reads WISH.md, creates PG tasks (parent = wish, children = groups), and resolves dependencies.
3

Dispatch

The team-lead spawns agents into tmux panes via genie spawn. Each agent gets a worktree clone and a group assignment.
4

Execute

Agents work autonomously. Hooks inject identity into messages, auto-spawn offline agents, and emit events to NATS.
5

Converge

As groups complete (genie done), the wish state machine recalculates dependent groups. Blocked groups become ready.
6

Review

/review validates all criteria. If issues are found, /fix loops until the reviewer returns SHIP.

State Fragmentation

Genie state is intentionally distributed across four scopes: Worktrees share the main repo’s .genie/ via git rev-parse --git-common-dir. The agent registry is global, not per-worktree.

Environment Variables