Skip to main content

Gastown/Beads Cleanup Commands Reference

A comprehensive catalog of all cleanup-related commands in the gastown/beads ecosystem, organized by scope and severity.


Process Cleanup

CommandWhat it does
gt cleanupKills orphaned Claude processes not tied to active tmux sessions
gt orphans procs listLists orphaned Claude processes (PPID=1)
gt orphans procs killKills orphaned Claude processes (--aggressive for tmux-verified)
gt deacon cleanup-orphansKills orphaned Claude subagent processes (no controlling TTY)
gt deacon zombie-scanFinds/kills zombie Claude processes not in active tmux sessions

Polecat (Agent Sandbox) Cleanup

CommandWhat it does
gt polecat remove <rig>/<polecat>Removes polecat worktree/directory (fails if session running)
gt polecat nuke <rig>/<polecat>Nuclear: kills session, deletes worktree, deletes branch, closes bead
gt polecat nuke <rig> --allNukes all polecats in a rig
gt polecat gc <rig>GC stale polecat branches (orphaned, old timestamped)
gt polecat stale <rig>Detects stale polecats; --cleanup auto-nukes them
gt polecat check-recoveryPre-nuke safety check (SAFE_TO_NUKE vs NEEDS_RECOVERY)
gt polecat identity remove <rig> <name>Removes a polecat identity
gt donePolecat self-cleaning: pushes branch, submits MR (by default), self-nukes worktree, kills own session. MR skipped for --status ESCALATED|DEFERRED or no_merge paths

Git Artifact Cleanup

CommandWhat it does
gt prune-branchesRemoves stale local polecat tracking branches (git fetch --prune + safe delete)
gt orphansFinds orphaned commits never merged (detection only)
gt orphans killPrunes orphaned commits (git gc --prune=now) + kills orphaned processes

Rig-Level Cleanup

CommandWhat it does
gt rig resetResets handoff content, stale mail, orphaned in_progress issues
gt rig reset --handoffClears handoff content only
gt rig reset --mailClears stale mail only
gt rig reset --staleResets orphaned in_progress issues
gt rig remove <name>Unregisters rig from registry, cleans up beads routes
gt rig shutdown <rig>Stops all agents: polecats, refinery, witness
gt rig stop <rig>...Stop one or more rigs
gt rig restart <rig>...Stop then start (stop phase cleans up)

Town-Wide Shutdown

CommandWhat it does
gt downStops all infrastructure (refinery, witness, mayor, boot, deacon, daemon, dolt)
gt down --polecatsAlso stops all polecat sessions
gt down --allFull shutdown with orphan cleanup and verification
gt down --nukeKills entire tmux server (DESTRUCTIVE - kills non-GT sessions too)
gt shutdown"Done for the day" - stops agents AND removes polecat worktrees/branches. Flags control aggressiveness (--graceful, --force, --nuclear, --polecats-only, etc.)

Crew Workspace Cleanup

CommandWhat it does
gt crew stop [name]Stops crew tmux sessions
gt crew restart [name]Kills and restarts crew fresh ("clean slate", no handoff mail)
gt crew remove <name>Removes workspace, closes agent bead
gt crew remove <name> --purgeFull obliteration: deletes agent bead, unassigns beads, clears mail
gt crew pristine [name]Syncs workspaces with remote (git pull)

Ephemeral Data / Event Cleanup

CommandWhat it does
gt compactTTL-based compaction: promotes/deletes wisps past their TTL
gt krc prunePrunes expired events from the KRC event store
gt krc config resetResets KRC TTL configuration to defaults
gt krc decayShows forensic value decay report (pruning guidance)

Dolt Database Cleanup

CommandWhat it does
gt dolt cleanupRemoves orphaned databases from .dolt-data/
gt dolt stopStops the Dolt SQL server
gt dolt rollback [backup-dir]Restores .beads from backup, resets metadata

Bead / Hook Cleanup

CommandWhat it does
gt close <bead-id>Closes beads (lifecycle termination)
gt unsling / gt unhookRemoves work from agent's hook, resets bead status to "open"
gt hook clearAlias for unsling

Dog (Infrastructure Worker) Cleanup

CommandWhat it does
gt dog remove <name>Removes worktrees and dog directory
gt dog remove --allRemoves all dogs
gt dog clear <name>Resets stuck dog to idle state
gt dog done [name]Marks dog as done, clears work field

Convoy Cleanup

CommandWhat it does
gt convoy close <id>Closes a convoy bead
gt convoy land <id>Closes convoy, cleans up polecat worktrees, sends completion notifications

Mail Cleanup

CommandWhat it does
gt mail delete <msg-id>Deletes specific messages
gt mail archive <msg-id>Archives messages (--stale for stale ones)
gt mail clear [target]Deletes all messages from an inbox (town quiescence)

Misc State Cleanup

CommandWhat it does
gt namepool resetReleases all claimed polecat names
gt checkpoint clearRemoves checkpoint file
gt issue clearClears issue from tmux status line
gt doctor --fixAuto-fixes: orphan sessions, wisp GC, stale redirects, worktree validity

System-Level Cleanup

CommandWhat it does
gt disable --cleanDisables gastown + removes shell integration
gt shell removeRemoves shell integration from RC files
gt config agent remove <name>Removes custom agent definition
gt uninstallFull removal: shell integration, wrapper scripts, state/config/cache dirs
make cleanRemoves compiled gt binary

Scripts

CommandWhat it does
scripts/migration-test/reset-vm.shRestores VM to pristine v0.5.0 state (test environments)

Internal (Automatic / Side-Effect)

FunctionWhereWhat it does
cleanupOrphanedProcesses()polecat.goAuto-runs after nuke/stale cleanup
selfNukePolecat()done.goSelf-destructs worktree during gt done
selfKillSession()done.goSelf-terminates tmux session
rollbackSlingArtifacts()sling.goCleans up partial sling failures
cleanStaleHookedBeads()unsling.goRepairs beads stuck in "hooked" state
gt signal stopsignal_stop.goClears stop-state temp files at turn boundaries
make installMakefileRemoves stale ~/go/bin/gt and ~/bin/gt binaries

Cleanup Layers (Low to High Severity)

LayerScopeKey Commands
L0Ephemeral datagt compact, gt krc prune (TTL-based lifecycle)
L1Processesgt cleanup, gt orphans procs kill, gt deacon cleanup-orphans
L2Git artifactsgt prune-branches, gt polecat gc, gt orphans kill
L3Agents/sessionsgt polecat nuke, gt done, gt shutdown, gt down
L4Workspacegt rig reset, gt doctor --fix, gt dolt cleanup
L5Systemgt uninstall, gt disable --clean

Total: ~62 commands/functions across the cleanup ecosystem.