Architecture Overview

October 9, 2025 · View on GitHub

The multi-agent workflow combines git worktrees with tmux so that each agent receives:

  • an isolated working directory tied to a dedicated branch, and
  • a tmux pane anchored in that directory for real-time supervision.
Main repository (.git)
    ├── source files
    └── agents/
          ├── 1/ (worktree → branch agents/1)
          ├── 2/ (worktree → branch agents/2)
          └── 3/ (worktree → branch agents/3)

.tmux session
    ├── pane: agent 1 shell (cd agents/1)
    ├── pane: agent 2 shell (cd agents/2)
    └── pane: shared tools / orchestration

Key Components

ComponentLocationPurpose
Worktree registry.agents/agents.yamlMaps agent names to branches and worktree paths
Worktree manager.agents/scripts/agents.shCreates/list/removes worktrees using the registry
Bootstrapper.agents/scripts/setup.shInstalls TPM, provisions worktrees from registry
Tmux launcher.agents/scripts/start-agents.shSpins up layouts, naming sessions consistently
Session connector.agents/scripts/attach.shAttaches to existing tmux sessions by name or prefix
Layout profiles.agents/profiles/*.shParameterized pane geometries
Broadcast helper.agents/scripts/send-commands.shSends commands to each pane
Cleanup utility.agents/scripts/kill-all.shKills tmux sessions with shared prefix
Worktree remover.agents/scripts/remove.shDeletes agent worktrees and cleans up branches
Toolkit uninstaller.agents/scripts/uninstall.shRemoves toolkit assets from repository
Shared config.agents/config/tmux.confMouse support, theming, plugin config

Workflow

  1. Registry first – define the agents, branches, and paths.
  2. Provisionscripts/setup.sh creates branches/worktrees and ensures tmux plugins.
  3. Launchscripts/start-agents.sh reads the registry, builds a pane layout, and names the session <prefix?>-ai-<repo>.
  4. Operate – agents work in their panes; supervisors monitor output, broadcast commands, or open additional panes.
  5. Tear downscripts/kill-all.sh or git worktree remove resets the environment when the effort completes.

Strengths

  • Isolation: each agent has a branch + working directory with zero branch switching.
  • Observability: tmux panes expose command history for every agent in one screen.
  • Consistency: enforced directory structure and naming reduce coordination mistakes.
  • Speed: new agents can be provisioned quickly via scripts/agents.sh create.

Risks & Mitigations

RiskMitigation
Pane crash or accidental exitAdd tmux-resurrect / continuum or extend the toolkit with a watchdog script.
Disk usage from many worktreesPrune inactive branches (git worktree prune) and archive old agents.
Conflicting edits across agentsPair the toolkit with a constitution that assigns ownership and requires communication.
Secrets leaking into worktreesKeep credentials in env vars or secret managers; never commit generated configs with secrets.
Session naming collisionsUse --prefix (creates: <prefix>-ai-<repo>) or SESSION_PREFIX to namespace sessions per team or initiative.

Integration Tips

  • Store shared docs (constitutions, safety rules, checklists) alongside the toolkit so every agent inherits them automatically.
  • Combine with automated planners or task generators that output into dedicated panes to keep reasoning visible.
  • For larger teams, consider a dashboard that reads tmux list-clients / git status across panes to surface stalled agents.

Future Enhancements

  • Script to bootstrap new repositories (completed via uvx multi-agent-kit init)
  • Session attach helper (completed via attach.sh and maw attach)
  • Health monitor service that alerts when an agent pane exits unexpectedly
  • Optional CI workflow verifying agent branches fast-forward to main before merging (see README Advanced Usage)
  • Agent handoff protocol: structured message passing between panes for coordination
  • Metrics dashboard: track agent activity, commit frequency, and pane health
  • Auto-recovery: restart crashed panes with last known command context
  • Multi-repo support: coordinate agents across related repositories