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.

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.
- Batty treats tmux as a persistence layer, ensuring AI agents survive daemon crashes and remain inspectable at any time.
- By leveraging git worktrees, Batty physically isolates concurrent tasks to prevent file corruption and multi-agent collisions.
- The project revives the ancient Maildir format to act as a lightweight, filesystem-native message broker for inter-agent communication.
- Built-in management rituals like standups and nudges prevent LLMs from stalling out during long-running tasks.
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.
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.
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.
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.
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.
| Feature | Batty | Single-Agent CLI (Aider) | Cloud Monolith (Devin) |
|---|---|---|---|
| Architecture | Terminal Multiplexer | Single Process | Cloud Sandbox |
| State Persistence | Tmux Panes | In-Memory | Proprietary DB |
| Concurrency | Git Worktrees | Sequential | Black Box |
| Task Management | Local Markdown Kanban | Chat Context | Web Dashboard |