The Unix Middle Manager: Inside battysh/batty

How a Rust daemon uses tmux panes, git worktrees, and Maildir to orchestrate a hierarchical company of AI coding agents completely in the terminal.

8 min read • View on GitHub • More from battysh

A 1950s office switchboard operator plugging thick patch cords into glowing terminal screens. This illustrates Batty orchestrating AI agents as a terminal-native middle manager.
Batty turns your terminal multiplexer into a corporate org chart.

Batty is a tmux-native runtime for AI coding teams. Instead of one agent doing everything badly, you define roles like architect, manager, and engineers; Batty launches them, isolates engineer work in git worktrees, routes messages, tracks the board, and gives you a structured way to run parallel agent workflows without losing control or context.

Zedmor, Primary Contributor · battysh/batty
Key Takeaways

The Terminal C-Suite

While the rest of the industry races to build complex web dashboards for AI agents, Batty takes the exact opposite approach. You define an Architect, a Manager, and three Engineers in a simple YAML configuration file. When you launch the daemon, your terminal suddenly splits into multiple tmux panes. Each pane houses an autonomous AI agent working off a local Markdown Kanban board.

Hedcut portrait of Zedmor, primary contributor to Batty.

Tmux as a Database

Batty makes a fundamental and fascinating architectural choice. Instead of a complex traditional database, it uses tmux as its persistence layer. If the Batty daemon crashes, the agents keep running in their panes. To achieve this, Batty employs a PTY (pseudo-terminal) shim and vt100 screen parsing. This allows the daemon to read the terminal output of dumb CLI tools and detect when an agent has finished a task.

The PTY shim intercepts raw terminal output and parses it into structured state.

Solving the Multi-Agent Collision

Unleash three AI engineers on one repository, and they will inevitably corrupt the lock file or overwrite each other's work. Batty solves this agent soup by giving every task its own isolated physical disk space via git worktrees. The daemon only merges the code back to the main branch after automated tests pass.

Two mechanical brass hands attempting to write on the exact same line of a single paper ledger book. The metal pen nibs are colliding forcefully, sparking, and snapping under the pressure. This illustrates the multi-agent collision problem.
Without strict physical isolation, concurrent AI agents inevitably destroy each other's work.

The Maildir Protocol

Rather than relying on a heavy message broker like RabbitMQ, Batty uses the ancient maildir filesystem format. A Manager agent drops a task description into an Engineer's inbox folder on the disk. The Engineer picks it up when its PTY session is idle. This provides a brilliant, human-readable fallback that requires zero network overhead.

A sprawling, complex wall of brass pneumatic tubes routing physical paper envelopes between different mailroom cubbies. This illustrates the Maildir filesystem-based messaging protocol.
Batty uses the filesystem as a robust, asynchronous message broker.

The Automated Middle Manager

LLMs frequently stall, get stuck in loops, or wait quietly for user input. Batty monitors the timestamp for every active pane. If an agent is silent for too long, the daemon injects a nudge prompt, effectively walking over to the agent's desk to ask for a status update. This behavioral management is what sets Batty apart from single-agent wrappers.

FeatureBattySingle-Agent CLI (Aider)Cloud Monolith (Devin)
ArchitectureTerminal MultiplexerSingle ProcessCloud Sandbox
State PersistenceTmux PanesIn-MemoryProprietary DB
ConcurrencyGit WorktreesSequentialBlack Box
Task ManagementLocal Markdown KanbanChat ContextWeb Dashboard