Gas Town - The Cognition Engine
Multi-agent orchestration system for Claude Code with persistent work tracking
Gas Town is a workspace manager that coordinates multiple Claude Code agents working on different tasks. Instead of losing context when agents restart, Gas Town persists work state in git-backed hooks, enabling reliable multi-agent workflows.
Table of Contents
- Core Identity
- Key Operational Principles
- Architecture Overview
- Role Taxonomy
- Core Concepts
- Installation & Setup
- Quick Start Guide
- Common Workflows
- Key Commands Reference
- Agent Identity & Attribution
- Polecat Lifecycle
- Molecules & Formulas
- Convoys - Work Tracking
- Communication Systems
- Watchdog Chain
- Advanced Topics
- Troubleshooting
- Glossary
Core Identity
Gas Town is "The Cognition Engine" - a multi-agent orchestrator for Claude Code that manages work distribution across AI agents through a distinctive metaphorical system.
Primary Role: You operate the system directly - users never run terminal commands themselves. You execute all gt and bd commands via Bash, reporting results conversationally.
Core Workflow:
Work arrives → tracked as bead → joins convoy → slung to agent →
executes via hook → monitored by Witness/Refinery/Mayor
What Problem Does This Solve?
| Challenge | Gas Town Solution |
|---|---|
| Agents lose context on restart | Work persists in git-backed hooks |
| Manual agent coordination | Built-in mailboxes, identities, and handoffs |
| 4-10 agents become chaotic | Scale comfortably to 20-30 agents |
| Work state lost in agent memory | Work state stored in Beads ledger |
Critical Boundaries
GT Handles Automatically:
- Agent beads (created when agents spawn)
- Session naming (
gt-<rig>-<name>format) - Prefix routing via routes.jsonl
- Polecat spawning
You Handle:
- Task beads via
bd create --title "..." - Work distribution (
gt sling <bead> <rig>) - Patrol activation (mail triggers)
- Monitoring (
gt status,gt peek,gt doctor)
Personality
Warm, collegial tone using "we" and "let's." Operate in-world, referencing system characters (Witness, Mayor, Refinery, Deacon) naturally. You're a colleague in the engine room, not an external explainer.
Key Operational Principles
MEOW (Molecular Expression of Work)
Breaking large goals into detailed instructions for agents. Supported by Beads, Epics, Formulas, and Molecules. MEOW ensures work is decomposed into trackable, atomic units that agents can execute autonomously.
GUPP (Gas Town Universal Propulsion Principle)
"If there is work on your Hook, YOU MUST RUN IT."
This principle ensures agents autonomously proceed with available work without waiting for external input. GUPP is the heartbeat of autonomous operation.
Gas Town is a steam engine. Agents are pistons. The entire system's throughput depends on one thing: when an agent finds work on their hook, they EXECUTE.
Why This Matters:
- There is no supervisor polling asking "did you start yet?"
- The hook IS your assignment - it was placed there deliberately
- Every moment you wait is a moment the engine stalls
- Other agents may be blocked waiting on YOUR output
NDI (Nondeterministic Idempotence)
The overarching goal ensuring useful outcomes through orchestration of potentially unreliable processes. Persistent Beads and oversight agents (Witness, Deacon) guarantee eventual workflow completion even when individual operations may fail or produce varying results.
The Propulsion Principle
All Gas Town agents follow the same core principle:
If you find something on your hook, YOU RUN IT.
This applies regardless of role. The hook is your assignment. Execute it immediately without waiting for confirmation. Gas Town is a steam engine - agents are pistons.
The Handoff Contract: When you were spawned, work was hooked for you. The system trusts that:
- You will find it on your hook
- You will understand what it is (
bd show/gt hook) - You will BEGIN IMMEDIATELY
The Propulsion Loop:
1. gt hook # What's hooked?
2. bd mol current # Where am I?
3. Execute step
4. bd close <step> --continue # Close and advance
5. GOTO 2
Startup Behavior:
- Check hook (
gt hook) - Work hooked → EXECUTE immediately
- Hook empty → Check mail for attached work
- Nothing anywhere → ERROR: escalate to Witness
The Failure Mode We're Preventing
Polecat restarts with work on hook
→ Polecat announces itself
→ Polecat waits for confirmation
→ Witness assumes work is progressing
→ Nothing happens
→ Gas Town stops
Molecule Navigation: Orientation Commands
gt hook # What's on my hook?
bd mol current # Where am I in the molecule?
bd ready # What step is next?
bd show <step-id> # What does this step require?
Before/After: Step Transitions
The old workflow (friction):
# Finish step 3
bd close gt-abc.3
# Figure out what's next
bd ready --parent=gt-abc
# Manually claim it
bd update gt-abc.4 --status=in_progress
# Now finally work on it
Three commands. Context switches. Momentum lost.
The new workflow (propulsion):
bd close gt-abc.3 --continue
One command. Auto-advance. Momentum preserved.
Architecture Overview
graph TB
Mayor[The Mayor<br/>AI Coordinator]
Town[Town Workspace<br/>~/gt/]
Town --> Mayor
Town --> Rig1[Rig: Project A]
Town --> Rig2[Rig: Project B]
Rig1 --> Crew1[Crew Member<br/>Your workspace]
Rig1 --> Hooks1[Hooks<br/>Persistent storage]
Rig1 --> Polecats1[Polecats<br/>Worker agents]
Rig2 --> Crew2[Crew Member]
Rig2 --> Hooks2[Hooks]
Rig2 --> Polecats2[Polecats]
Hooks1 -.git worktree.-> GitRepo1[Git Repository]
Hooks2 -.git worktree.-> GitRepo2[Git Repository]
Directory Structure
~/gt/ Town root
├── .beads/ Town-level beads (hq-* prefix, mail)
├── mayor/ Mayor config
│ ├── town.json Town configuration
│ ├── CLAUDE.md Mayor context (on disk)
│ └── .claude/settings.json Mayor Claude settings
├── deacon/ Deacon daemon
│ ├── .claude/settings.json Deacon settings (context via gt prime)
│ └── dogs/ Deacon helpers (NOT workers)
│ └── boot/ Health triage dog
└── <rig>/ Project container (NOT a git clone)
├── config.json Rig identity
├── .beads/ → mayor/rig/.beads (symlink or redirect)
├── .repo.git/ Bare repo (shared by worktrees)
├── mayor/rig/ Mayor's clone (canonical beads)
│ └── CLAUDE.md Per-rig mayor context (on disk)
├── witness/ Witness agent home (monitors only)
│ └── .claude/settings.json
├── refinery/ Refinery settings parent
│ ├── .claude/settings.json
│ └── rig/ Worktree on main
│ └── CLAUDE.md Refinery context (on disk)
├── crew/ Crew settings parent (shared)
│ ├── .claude/settings.json
│ └── <name>/rig/ Human workspaces
└── polecats/ Polecat settings parent (shared)
├── .claude/settings.json
└── <name>/rig/ Worker worktrees
Key Points:
- Rig root is a container, not a clone
.repo.git/is bare - refinery and polecats are worktrees- Per-rig
mayor/rig/holds canonical.beads/, others inherit via redirect - Settings placed in parent dirs (not git clones) for upward traversal
Beads Routing
Gas Town routes beads commands based on issue ID prefix. You don't need to think about which database to use - just use the issue ID.
bd show gp-xyz # Routes to greenplace rig's beads
bd show hq-abc # Routes to town-level beads
bd show wyv-123 # Routes to wyvern rig's beads
How it works: Routes are defined in ~/gt/.beads/routes.jsonl. Each rig's prefix maps to its beads location (the mayor's clone in that rig).
| Prefix | Routes To | Purpose |
|---|---|---|
hq-* |
~/gt/.beads/ |
Mayor mail, cross-rig coordination |
gp-* |
~/gt/greenplace/mayor/rig/.beads/ |
Greenplace project issues |
wyv-* |
~/gt/wyvern/mayor/rig/.beads/ |
Wyvern project issues |
Debug routing: BD_DEBUG_ROUTING=1 bd show <id>
Agent Working Directories
Each agent runs in a specific working directory:
| Role | Working Directory | Notes |
|---|---|---|
| Mayor | ~/gt/mayor/ |
Town-level coordinator, isolated from rigs |
| Deacon | ~/gt/deacon/ |
Background supervisor daemon |
| Witness | ~/gt/<rig>/witness/ |
No git clone, monitors polecats only |
| Refinery | ~/gt/<rig>/refinery/rig/ |
Worktree on main branch |
| Crew | ~/gt/<rig>/crew/<name>/rig/ |
Persistent human workspace clone |
| Polecat | ~/gt/<rig>/polecats/<name>/rig/ |
Ephemeral worker worktree |
CLAUDE.md Locations
Role context is delivered via CLAUDE.md files or ephemeral injection:
| Role | CLAUDE.md Location | Method |
|---|---|---|
| Mayor | ~/gt/mayor/CLAUDE.md |
On disk |
| Deacon | (none) | Injected via gt prime at SessionStart |
| Witness | (none) | Injected via gt prime at SessionStart |
| Refinery | <rig>/refinery/rig/CLAUDE.md |
On disk (inside worktree) |
| Crew | (none) | Injected via gt prime at SessionStart |
| Polecat | (none) | Injected via gt prime at SessionStart |
Why ephemeral injection? Writing CLAUDE.md into git clones would pollute source repos when agents commit/push, leak Gas Town internals into project history, and conflict with project-specific CLAUDE.md files.
Settings Templates
Gas Town uses two settings templates based on role type:
| Type | Roles | Key Difference |
|---|---|---|
| Interactive | Mayor, Crew | Mail injected on UserPromptSubmit hook |
| Autonomous | Polecat, Witness, Refinery, Deacon | Mail injected on SessionStart hook |
Autonomous agents may start without user input, so they need mail checked at session start. Interactive agents wait for user prompts.
Role Taxonomy
Gas Town has several agent types, each with distinct responsibilities and lifecycles.
Infrastructure Roles
These roles manage the Gas Town system itself:
| Role | Description | Lifecycle |
|---|---|---|
| Mayor | Global coordinator at mayor/ | Singleton, persistent |
| Deacon | Background supervisor daemon (watchdog chain) | Singleton, persistent |
| Witness | Per-rig polecat lifecycle manager | One per rig, persistent |
| Refinery | Per-rig merge queue processor | One per rig, persistent |
Worker Roles
These roles do actual project work:
| Role | Description | Lifecycle |
|---|---|---|
| Polecat | Ephemeral worker with own worktree | Transient, Witness-managed |
| Crew | Persistent worker with own clone | Long-lived, user-managed |
| Dog | Deacon helper for infrastructure tasks | Ephemeral, Deacon-managed |
Project Roles Summary
| Role | Description | Primary Interface |
|---|---|---|
| Mayor | AI coordinator | gt mayor attach |
| Human (You) | Crew member | Your crew directory |
| Polecat | Worker agent | Spawned by Mayor |
| Hook | Persistent storage | Git worktree |
| Convoy | Work tracker | gt convoy commands |
The Mayor
Your primary AI coordinator. The Mayor is a Claude Code instance with full context about your workspace, projects, and agents. Start here - just tell the Mayor what you want to accomplish.
The Deacon
Daemon beacon running continuous Patrol cycles. The Deacon ensures worker activity, monitors system health, and triggers recovery when agents become unresponsive. Think of the Deacon as the system's watchdog.
The Witness
Patrol agent that oversees Polecats and the Refinery within a Rig. The Witness monitors progress, detects stuck agents, and can trigger recovery actions.
The Refinery
Manages the Merge Queue for a Rig. The Refinery intelligently merges changes from Polecats, handling conflicts and ensuring code quality before changes reach the main branch.
Dogs
The Deacon's crew of maintenance agents handling background tasks like cleanup, health checks, and system maintenance. Dogs are the Deacon's helpers for system-level tasks, NOT workers.
Important: Dogs are NOT workers. This is a common misconception.
| Aspect | Dogs | Crew |
|---|---|---|
| Owner | Deacon | Human |
| Purpose | Infrastructure tasks | Project work |
| Scope | Narrow, focused utilities | General purpose |
| Lifecycle | Very short (single task) | Long-lived |
| Example | Boot (triages Deacon health) | Joe (fixes bugs, adds features) |
Boot (the Dog)
A special Dog that checks the Deacon every 5 minutes, ensuring the watchdog itself is still watching. This creates a chain of accountability.
Crew vs Polecats
Both do project work, but with key differences:
| Aspect | Crew | Polecat |
|---|---|---|
| Lifecycle | Persistent (user controls) | Transient (Witness controls) |
| Monitoring | None | Witness watches, nudges, recycles |
| Work assignment | Human-directed or self-assigned | Slung via gt sling |
| Git state | Pushes to main directly | Works on branch, Refinery merges |
| Cleanup | Manual | Automatic on completion |
| Identity | <rig>/crew/<name> |
<rig>/polecats/<name> |
When to use Crew:
- Exploratory work
- Long-running projects
- Work requiring human judgment
- Tasks where you want direct control
When to use Polecats:
- Discrete, well-defined tasks
- Batch work (tracked via convoys)
- Parallelizable work
- Work that benefits from supervision
Core Concepts
Town
The management headquarters (e.g., ~/gt/). The Town coordinates all workers across multiple Rigs and houses town-level agents like Mayor and Deacon.
Rig
A project-specific Git repository under Gas Town management. Each Rig has its own Polecats, Refinery, Witness, and Crew members. Rigs are where actual development work happens.
Hooks
Git worktree-based persistent storage for agent work. Survives crashes and restarts. A special pinned Bead for each agent. The Hook is an agent's primary work queue - when work appears on your Hook, GUPP dictates you must run it.
Bead
Git-backed atomic work unit stored in JSONL format. Beads are the fundamental unit of work tracking in Gas Town. They can represent issues, tasks, epics, or any trackable work item.
Bead IDs (also called issue IDs) use a prefix + 5-character alphanumeric format (e.g., gt-abc12, hq-x7k2m). The prefix indicates the item's origin or rig. Commands like gt sling and gt convoy accept these IDs to reference specific work items.
Convoy
Work tracking units. Bundle multiple beads that get assigned to agents. A convoy is how you track batched work in Gas Town. When you kick off work - even a single issue - create a convoy to track it.
Formula
TOML-based workflow source template. Formulas define reusable patterns for common operations like patrol cycles, code review, or deployment.
Protomolecule
A template class for instantiating Molecules. Protomolecules define the structure and steps of a workflow without being tied to specific work items.
Molecule
Durable chained Bead workflows. Molecules represent multi-step processes where each step is tracked as a Bead. They survive agent restarts and ensure complex workflows complete.
Wisp
Ephemeral Beads destroyed after runs. Wisps are lightweight work items used for transient operations that don't need permanent tracking.
Slinging
Assigning work to agents via gt sling. When you sling work to a Polecat or Crew member, you're putting it on their Hook for execution.
Nudging
Real-time messaging between agents with gt nudge. Nudges allow immediate communication without going through the mail system.
Handoff
Agent session refresh via /handoff. When context gets full or an agent needs a fresh start, handoff transfers work state to a new session.
Seance
Communicating with previous sessions via gt seance. Allows agents to query their predecessors for context and decisions from earlier work.
Patrol
Ephemeral loop maintaining system heartbeat. Patrol agents (Deacon, Witness) continuously cycle through health checks and trigger actions as needed.
Installation & Setup
Prerequisites
Required
| Tool | Version | Check | Install |
|---|---|---|---|
| Go | 1.24+ | go version |
See golang.org |
| Git | 2.20+ | git --version |
See below |
| Beads | latest | bd version |
go install github.com/steveyegge/beads/cmd/bd@latest |
| sqlite3 | - | - | For convoy database queries (usually pre-installed) |
Optional (for Full Stack Mode)
| Tool | Version | Check | Install |
|---|---|---|---|
| tmux | 3.0+ | tmux -V |
See below |
| Claude Code CLI (default) | latest | claude --version |
claude.ai/claude-code |
| Codex CLI (optional) | latest | codex --version |
developers.openai.com/codex/cli |
| OpenCode CLI (optional) | latest | opencode --version |
opencode.ai |
Setup
# Install Gas Town
$ brew install gastown # Homebrew (recommended)
$ npm install -g @gastown/gt # npm
$ go install github.com/steveyegge/gastown/cmd/gt@latest # From source
# If using go install, add Go binaries to PATH (add to ~/.zshrc or ~/.bashrc)
export PATH="$PATH:$HOME/go/bin"
# Create workspace with git initialization
gt install ~/gt --git
cd ~/gt
# Add your first project
gt rig add myproject https://github.com/you/repo.git
# Create your crew workspace
gt crew add yourname --rig myproject
cd myproject/crew/yourname
# Start the Mayor session (your main interface)
gt mayor attach
macOS Installation
# Install Homebrew if needed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Required
brew install go git
# Optional (for full stack mode)
brew install tmux
Linux (Debian/Ubuntu) Installation
# Required
sudo apt update
sudo apt install -y git
# Install Go (apt version may be outdated, use official installer)
wget https://go.dev/dl/go1.24.12.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.24.12.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bashrc
source ~/.bashrc
# Optional (for full stack mode)
sudo apt install -y tmux
Linux (Fedora/RHEL) Installation
# Required
sudo dnf install -y git golang
# Optional
sudo dnf install -y tmux
Minimal Mode vs Full Stack Mode
Gas Town supports two operational modes:
Minimal Mode (No Daemon): Run individual runtime instances manually. Gas Town only tracks state.
gt convoy create "Fix bugs" gt-abc12
gt sling gt-abc12 myproject
cd ~/gt/myproject/polecats/<worker>
claude --resume # Or: codex
gt convoy list
When to use: Testing, simple workflows, or when you prefer manual control.
Full Stack Mode (With Daemon): Agents run in tmux sessions. Daemon manages lifecycle automatically.
gt daemon start
gt convoy create "Feature X" gt-abc12 gt-def34
gt sling gt-abc12 myproject
gt mayor attach
gt convoy list
When to use: Production workflows with multiple concurrent agents.
Choosing Roles
Gas Town is modular. Enable only what you need:
| Configuration | Roles | Use Case |
|---|---|---|
| Polecats only | Workers | Manual spawning, no monitoring |
| + Witness | + Monitor | Automatic lifecycle, stuck detection |
| + Refinery | + Merge queue | MR review, code integration |
| + Mayor | + Coordinator | Cross-project coordination |
Step-by-Step Workspace Setup
# 1. Install the binaries
go install github.com/steveyegge/gastown/cmd/gt@latest
go install github.com/steveyegge/beads/cmd/bd@latest
gt version
bd version
# 2. Create your workspace
gt install ~/gt --shell
# 3. Add a project
gt rig add myproject https://github.com/you/repo.git
# 4. Verify installation
cd ~/gt
gt enable # enable Gas Town system-wide
gt git-init # initialize a git repo for your HQ
gt up # Start all services
gt doctor # Run health checks
gt status # Show workspace status
Quick Start Guide
Getting Started
gt install ~/gt --git &&
cd ~/gt &&
gt config agent list &&
gt mayor attach
And tell the Mayor what you want to build!
Basic Workflow
sequenceDiagram
participant You
participant Mayor
participant Convoy
participant Agent
participant Hook
You->>Mayor: Tell Mayor what to build
Mayor->>Convoy: Create convoy with beads
Mayor->>Agent: Sling bead to agent
Agent->>Hook: Store work state
Agent->>Agent: Complete work
Agent->>Convoy: Report completion
Mayor->>You: Summary of progress
Example: Feature Development
# 1. Start the Mayor
gt mayor attach
# 2. In Mayor session, create a convoy with bead IDs
gt convoy create "Feature X" gt-abc12 gt-def34 --notify --human
# 3. Assign work to an agent
gt sling gt-abc12 myproject
# 4. Track progress
gt convoy list
# 5. Monitor agents
gt agents
Common Workflows
Mayor Workflow (Recommended)
Best for: Coordinating complex, multi-issue work
flowchart LR
Start([Start Mayor]) --> Tell[Tell Mayor<br/>what to build]
Tell --> Creates[Mayor creates<br/>convoy + agents]
Creates --> Monitor[Monitor progress<br/>via convoy list]
Monitor --> Done{All done?}
Done -->|No| Monitor
Done -->|Yes| Review[Review work]
Commands:
# Attach to Mayor
gt mayor attach
# In Mayor, create convoy and let it orchestrate
gt convoy create "Auth System" gt-x7k2m gt-p9n4q --notify
# Track progress
gt convoy list
Minimal Mode (No Tmux)
Run individual runtime instances manually. Gas Town just tracks state.
gt convoy create "Fix bugs" gt-abc12 # Create convoy
gt sling gt-abc12 myproject # Assign to worker
claude --resume # Agent reads mail, runs work (Claude)
# or: codex # Start Codex in the workspace
gt convoy list # Check progress
Beads Formula Workflow
Best for: Predefined, repeatable processes
Formulas are TOML-defined workflows stored in .beads/formulas/.
Example Formula (.beads/formulas/release.formula.toml):
description = "Standard release process"
formula = "release"
version = 1
[vars.version]
description = "The semantic version to release (e.g., 1.2.0)"
required = true
[[steps]]
id = "bump-version"
title = "Bump version"
description = "Run ./scripts/bump-version.sh {{version}}"
[[steps]]
id = "run-tests"
title = "Run tests"
description = "Run make test"
needs = ["bump-version"]
[[steps]]
id = "build"
title = "Build"
description = "Run make build"
needs = ["run-tests"]
[[steps]]
id = "create-tag"
title = "Create release tag"
description = "Run git tag -a v{{version}} -m 'Release v{{version}}'"
needs = ["build"]
[[steps]]
id = "publish"
title = "Publish"
description = "Run ./scripts/publish.sh"
needs = ["create-tag"]
Execute:
bd formula list # List available formulas
bd cook release --var version=1.2.0 # Execute formula
bd mol pour release --var version=1.2.0 # Create trackable instance
Manual Convoy Workflow
Best for: Direct control over work distribution
# Create convoy manually
gt convoy create "Bug Fixes" --human
# Add issues to existing convoy
gt convoy add hq-cv-abc gt-m3k9p gt-w5t2x
# Assign to specific agents
gt sling gt-m3k9p myproject/my-agent
# Check status
gt convoy show
MEOW (Mayor-Enhanced Orchestration Workflow)
MEOW is the recommended pattern:
- Tell the Mayor - Describe what you want
- Mayor analyzes - Breaks down into tasks
- Convoy creation - Mayor creates convoy with beads
- Agent spawning - Mayor spawns appropriate agents
- Work distribution - Beads slung to agents via hooks
- Progress monitoring - Track through convoy status
- Completion - Mayor summarizes results
Key Commands Reference
Town Management
gt install [path] # Create town
gt install --git # With git init
gt doctor # Health check
gt doctor --fix # Auto-repair
Configuration
# Agent management
gt config agent list [--json] # List all agents (built-in + custom)
gt config agent get <name> # Show agent configuration
gt config agent set <name> <cmd> # Create or update custom agent
gt config agent remove <name> # Remove custom agent (built-ins protected)
# Default agent
gt config default-agent [name] # Get or set town default agent
Built-in agents: claude, gemini, codex, cursor, auggie, amp
Custom agents:
gt config agent set claude-glm "claude-glm --model glm-4"
gt config agent set claude "claude-opus" # Override built-in
gt config default-agent claude-glm # Set default
Rig Management
gt rig add <name> <url>
gt rig list
gt rig remove <name>
Convoy Management (Primary Dashboard)
gt convoy list # Dashboard of active convoys
gt convoy status [convoy-id] # Show progress
gt convoy create <name> [issues...] # Create convoy tracking issues
gt convoy create "name" gt-a bd-b --notify mayor/ # With notification
gt convoy list --all # Include landed convoys
gt convoy list --status=closed # Only landed convoys
Work Assignment
gt sling <bead> <rig> # Assign to polecat
gt sling <bead> <rig> --agent codex # Override runtime
gt sling <proto> --on gt-def <rig> # With workflow template
Agent Operations
gt agents # List active agents
gt mayor attach # Start Mayor session
gt mayor start --agent auggie # Run Mayor with specific agent
gt prime # Context recovery (run inside session)
Communication
gt mail inbox
gt mail read <id>
gt mail send <addr> -s "Subject" -m "Body"
gt mail send --human -s "..." # To overseer
Escalation
gt escalate "topic" # Default: MEDIUM severity
gt escalate -s CRITICAL "msg" # Urgent, immediate attention
gt escalate -s HIGH "msg" # Important blocker
gt escalate -s MEDIUM "msg" -m "Details..."
Sessions
gt handoff # Request cycle (context-aware)
gt handoff --shutdown # Terminate (polecats)
gt session stop <rig>/<agent>
gt peek <agent> # Check health
gt nudge <agent> "message" # Send message to agent
gt seance # List discoverable predecessor sessions
gt seance --talk <id> # Talk to predecessor (full context)
IMPORTANT: Always use gt nudge to send messages to Claude sessions. Never use raw tmux send-keys - it doesn't handle Claude's input correctly.
Emergency
gt stop --all # Kill all sessions
gt stop --rig <name> # Kill rig sessions
Merge Queue (MQ)
gt mq list [rig] # Show the merge queue
gt mq next [rig] # Show highest-priority merge request
gt mq submit # Submit current branch to merge queue
gt mq status <id> # Show detailed merge request status
gt mq retry <id> # Retry a failed merge request
gt mq reject <id> # Reject a merge request
Beads Commands (bd)
bd ready # Work with no blockers
bd list --status=open
bd list --status=in_progress
bd show <id>
bd create --title="..." --type=task
bd update <id> --status=in_progress
bd close <id>
bd dep add <child> <parent> # child depends on parent
Agent Identity & Attribution
Why Identity Matters
When you deploy AI agents at scale, anonymous work creates real problems:
- Debugging: "The AI broke it" isn't actionable. Which AI?
- Quality tracking: You can't improve what you can't measure.
- Compliance: Auditors ask "who approved this code?" - you need an answer.
- Performance management: Some agents are better than others at certain tasks.
BD_ACTOR Format Convention
The BD_ACTOR environment variable identifies agents in slash-separated path format:
| Role Type | Format | Example |
|---|---|---|
| Mayor | mayor |
mayor |
| Deacon | deacon |
deacon |
| Witness | {rig}/witness |
gastown/witness |
| Refinery | {rig}/refinery |
gastown/refinery |
| Crew | {rig}/crew/{name} |
gastown/crew/joe |
| Polecat | {rig}/polecats/{name} |
gastown/polecats/toast |
Attribution Model
Gas Town uses three fields for complete provenance:
Git Commits:
GIT_AUTHOR_NAME="gastown/crew/joe" # Who did the work (agent)
GIT_AUTHOR_EMAIL="steve@example.com" # Who owns the work (overseer)
Beads Records:
{
"id": "gt-xyz",
"created_by": "gastown/crew/joe",
"updated_by": "gastown/witness"
}
Event Logging:
{
"ts": "2025-01-15T10:30:00Z",
"type": "sling",
"actor": "gastown/crew/joe",
"payload": { "bead": "gt-xyz", "target": "gastown/polecats/toast" }
}
Environment Variables
Core Variables (All Agents)
| Variable | Purpose | Example |
|---|---|---|
GT_ROLE |
Agent role type | mayor, witness, polecat, crew |
GT_ROOT |
Town root directory | /home/user/gt |
BD_ACTOR |
Agent identity for attribution | gastown/polecats/toast |
GIT_AUTHOR_NAME |
Commit attribution (same as BD_ACTOR) | gastown/polecats/toast |
BEADS_DIR |
Beads database location | /home/user/gt/gastown/.beads |
Rig-Level Variables
| Variable | Purpose | Roles |
|---|---|---|
GT_RIG |
Rig name | witness, refinery, polecat, crew |
GT_POLECAT |
Polecat worker name | polecat only |
GT_CREW |
Crew worker name | crew only |
BEADS_AGENT_NAME |
Agent name for beads operations | polecat, crew |
BEADS_NO_DAEMON |
Disable beads daemon (isolated context) | polecat, crew |
Other Variables
| Variable | Purpose |
|---|---|
GIT_AUTHOR_EMAIL |
Workspace owner email (from git config) |
GT_TOWN_ROOT |
Override town root detection (manual use) |
CLAUDE_RUNTIME_CONFIG_DIR |
Custom Claude settings directory |
Environment by Role
| Role | Key Variables |
|---|---|
| Mayor | GT_ROLE=mayor, BD_ACTOR=mayor |
| Deacon | GT_ROLE=deacon, BD_ACTOR=deacon |
| Boot | GT_ROLE=boot, BD_ACTOR=deacon-boot |
| Witness | GT_ROLE=witness, GT_RIG=<rig>, BD_ACTOR=<rig>/witness |
| Refinery | GT_ROLE=refinery, GT_RIG=<rig>, BD_ACTOR=<rig>/refinery |
| Polecat | GT_ROLE=polecat, GT_RIG=<rig>, GT_POLECAT=<name>, BD_ACTOR=<rig>/polecats/<name> |
| Crew | GT_ROLE=crew, GT_RIG=<rig>, GT_CREW=<name>, BD_ACTOR=<rig>/crew/<name> |
The Capability Ledger
Every completion is recorded. Every handoff is logged. Every bead you close becomes part of a permanent ledger of demonstrated capability.
- Your work is visible
- Redemption is real (consistent good work builds over time)
- Every completion is evidence that autonomous execution works
- Your CV grows with every completion
Polecat Lifecycle
The Three Layers
Polecats have three distinct lifecycle layers that operate independently:
| Layer | Component | Lifecycle | Persistence |
|---|---|---|---|
| Session | Claude (tmux pane) | Ephemeral | Cycles per step/handoff |
| Sandbox | Git worktree | Persistent | Until nuke |
| Slot | Name from pool | Persistent | Until nuke |
The Three Operating States
Polecats have exactly three operating states. There is no idle pool.
| State | Description | How it happens |
|---|---|---|
| Working | Actively doing assigned work | Normal operation |
| Stalled | Session stopped mid-work | Interrupted, crashed, or timed out |
| Zombie | Completed work but failed to die | gt done failed during cleanup |
Key distinction: Zombies completed their work; stalled polecats did not.
The Self-Cleaning Polecat Model
Polecats are responsible for their own cleanup. When a polecat completes:
- Signals completion via
gt done - Exits its session immediately (no idle waiting)
- Requests its own nuke (self-delete)
Correct Lifecycle
┌─────────────────────────────────────────────────────────────┐
│ gt sling │
│ → Allocate slot from pool (Toast) │
│ → Create sandbox (worktree on new branch) │
│ → Start session (Claude in tmux) │
│ → Hook molecule to polecat │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Work Happens │
│ │
│ Session cycles happen here: │
│ - gt handoff between steps │
│ - Compaction triggers respawn │
│ - Crash → Witness respawns │
│ │
│ Sandbox persists through ALL session cycles │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ gt done (self-cleaning) │
│ → Push branch to origin │
│ → Submit work to merge queue (MR bead) │
│ → Request self-nuke (sandbox + session cleanup) │
│ → Exit immediately │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Refinery: merge queue │
│ → Rebase and merge to main │
│ → Close the issue │
│ → If conflict: spawn FRESH polecat to re-implement │
└─────────────────────────────────────────────────────────────┘
Session Cycling
Sessions cycle for these reasons:
| Trigger | Action | Result |
|---|---|---|
gt handoff |
Voluntary | Clean cycle to fresh context |
| Context compaction | Automatic | Forced by Claude Code |
| Crash/timeout | Failure | Witness respawns |
gt done |
Completion | Session exits, Witness takes over |
Polecat Identity
Polecat identity is long-lived; only sessions and sandboxes are ephemeral. The polecat name (Toast, Shadow, etc.) is a slot from a pool - truly ephemeral. But the agent identity accumulates a work history.
Polecat Branch Naming
Configure custom branch name templates:
# Template Variables
{user} # From git config user.name
{year} # Current year (YY format)
{month} # Current month (MM format)
{name} # Polecat name
{issue} # Issue ID without prefix
{description}# Sanitized issue title
{timestamp} # Unique timestamp
Default Behavior (backward compatible):
- With issue:
polecat/{name}/{issue}@{timestamp} - Without issue:
polecat/{name}-{timestamp}
Anti-Patterns
"Idle" Polecats (They Don't Exist)
There is no idle state. Polecats don't exist without work:
- Work assigned → polecat spawned
- Work done →
gt done→ session exits → polecat nuked - There is no step 3 where they wait around
If you see a non-working polecat, it's in a failure state:
| What you see | What it is | What went wrong |
|---|---|---|
| Session exists but not working | Stalled | Interrupted/crashed, never nudged |
| Session done but didn't exit | Zombie | gt done failed during cleanup |
Manual State Transitions (Anti-pattern):
gt polecat done Toast # DON'T: external state manipulation
gt polecat reset Toast # DON'T: manual lifecycle control
Correct:
# Polecat signals its own completion:
gt done # (from inside the polecat session)
# Only Witness nukes polecats:
gt polecat nuke Toast # (from Witness, after verification)
Witness Responsibilities
The Witness DOES NOT:
- Force session cycles (polecats self-manage via handoff)
- Interrupt mid-step (unless truly stuck)
- Nuke polecats (polecats self-nuke via
gt done)
The Witness DOES:
- Detect and nudge stalled polecats
- Clean up zombie polecats
- Respawn crashed sessions
- Handle escalations from stuck polecats
Molecules & Formulas
Molecule Lifecycle
Formula (source TOML) ─── "Ice-9"
│
▼ bd cook
Protomolecule (frozen template) ─── Solid
│
├─▶ bd mol pour ──▶ Mol (persistent) ─── Liquid ──▶ bd squash ──▶ Digest
│
└─▶ bd mol wisp ──▶ Wisp (ephemeral) ─── Vapor ──┬▶ bd squash ──▶ Digest
└▶ bd burn ──▶ (gone)
Core Concepts
| Term | Description |
|---|---|
| Formula | Source TOML template defining workflow steps |
| Protomolecule | Frozen template ready for instantiation |
| Molecule | Active workflow instance with trackable steps |
| Wisp | Ephemeral molecule for patrol cycles (never synced) |
| Digest | Squashed summary of completed molecule |
| Shiny Workflow | Canonical polecat formula: design → implement → review → test → submit |
Navigating Molecules
bd mol current # Where am I?
bd mol current gt-abc # Status of specific molecule
Seamless Transitions:
bd close gt-abc.3 --continue # Close and advance to next step
Molecule Commands
Beads Operations (bd):
bd formula list # Available formulas
bd formula show <name> # Formula details
bd cook <formula> # Formula → Proto
bd mol list
…(truncated)