This document outlines the implementation plan for the AI Fleet MVP - a CLI tool to manage multiple AI coding agents in parallel using git worktrees and tmux sessions.
- Simplicity First: Start with the minimal viable features
- No Over-Engineering: Flat files (JSON/TOML) instead of databases
- Unix Philosophy: Do one thing well, compose with other tools
- Fast Iteration: Get basic commands working, then enhance
ai-fleet/
├── src/aifleet/
│ ├── __init__.py # Package initialization
│ ├── cli.py # Click CLI entry point
│ ├── config.py # Configuration management (TOML)
│ ├── state.py # Agent state tracking (JSON)
│ ├── agent.py # Agent lifecycle management
│ ├── worktree.py # Git worktree operations
│ ├── tmux.py # Tmux session management
│ ├── commands/ # CLI command implementations
│ │ ├── __init__.py
│ │ ├── create.py # fleet create
│ │ ├── fanout.py # fleet fanout
│ │ ├── multi.py # fleet multi
│ │ ├── control.py # prompt, attach, logs, kill
│ │ └── list.py # fleet list
│ └── utils.py # Shared utilities
# Key features:
- Load/save config from ~/.ai_fleet/config.toml
- Default values with override capability
- Validate configuration
- Create config directory structure on first runTasks:
- Create ConfigManager class
- Implement TOML loading/saving
- Define default configuration schema
- Add validation logic
- Create
fleet config editcommand
# Key features:
- Track active agents in ~/.ai_fleet/state.json
- Atomic updates to prevent corruption
- Query agents by branch, batch_id, etc.
- Reconcile with actual tmux sessionsTasks:
- Create StateManager class
- Implement JSON persistence with file locking
- Add CRUD operations for agent records
- Implement state reconciliation with tmux
- Add query/filter methods
# Key features:
- Create worktrees with new or existing branches
- Copy credential files from main repo
- Run setup commands
- Clean up worktreesTasks:
- Create WorktreeManager class
- Implement worktree creation
- Add credential file copying
- Implement setup command execution
- Add worktree deletion with safety checks
# Key features:
- Create tmux sessions with consistent naming
- Send commands to sessions
- Capture output/logs
- Monitor session status
- Clean up sessionsTasks:
- Create TmuxManager class using libtmux
- Implement session creation
- Add command sending functionality
- Implement log capture
- Add session monitoring (PID, status)
- Add session cleanup
fleet create fix-auth --prompt "Fix the authentication bug"Tasks:
- Parse arguments (branch, prompt)
- Create worktree
- Copy credentials
- Run setup commands
- Create tmux session
- Launch agent with prompt
- Update state
fleet fanout 3 --prompt "Refactor auth module"
fleet fanout 3 auth-refactor --prompt "Refactor auth module"Tasks:
- Generate batch ID if not provided
- Create N branches with naming pattern
- Parallel worktree creation
- Launch N agents with same prompt
- Track as batch in state
fleet multi fix-auth:"Fix login" add-tests:"Add test coverage"Tasks:
- Parse branch:prompt pairs
- Create worktrees for each task
- Launch agents with different prompts
- Track as batch in state
fleet prompt fix-auth "Run the tests"
fleet attach fix-auth
fleet logs fix-auth -n 100
fleet kill fix-authTasks:
- Implement prompt sending via tmux
- Add interactive attach functionality
- Implement log tailing
- Add kill with cleanup (tmux + worktree)
fleet list
fleet list --groupedTasks:
- Query active agents from state
- Reconcile with actual tmux sessions
- Get CPU/RAM metrics via psutil
- Format as table
- Add grouping by batch_id
- Add proper error messages
- Implement rollback on partial failures
- Add --force flags where appropriate
- Handle edge cases (branch exists, session exists, etc.)
- Add progress indicators
- Implement --verbose flag
- Add confirmation prompts for destructive actions
- Improve command output formatting
- Unit tests for core modules
- Integration tests for commands
- Test credential file handling
- Test parallel operations
- Test error scenarios
-
Week 1: Foundation
- config.py (Day 1-2)
- state.py (Day 2-3)
- tmux.py (Day 3-4)
- worktree.py (Day 4-5)
-
Week 2: Core Commands
- create command (Day 1-2)
- fanout command (Day 2-3)
- multi command (Day 3-4)
- Basic list command (Day 4-5)
-
Week 3: Management & Polish
- Control commands (Day 1-2)
- Enhanced list with metrics (Day 2-3)
- Error handling (Day 3-4)
- Testing & bug fixes (Day 4-5)
- Use
subprocessfor git operations (simple, reliable) - Use
libtmuxfor tmux integration (better control) - Use
psutilfor process metrics
- Use Python's
threadingfor parallel worktree setup - Limit parallelism to avoid resource exhaustion
- Show progress for long operations
- Use file locking for atomic updates
- Reconcile state on every list operation
- State file is advisory, not authoritative
- Each command should be idempotent where possible
- Partial failures should clean up resources
- Clear error messages with suggested fixes
- Can create and manage 5+ agents simultaneously
- Worktree setup completes in <10s per agent
- No orphaned resources after kill
- Commands feel responsive (<1s for most operations)
- Clear error messages when things go wrong
- Configuration Templates: Project-specific setup templates
- Agent Templates: Pre-configured prompts for common tasks
- Metrics Dashboard: Web UI for monitoring agents
- Cost Tracking: Track token usage per agent
- Integration: Linear/GitHub issue fetching
- Advanced Features: Winner picking, auto-merge
- Start with CLI skeleton using Click
- Implement one module at a time with tests
- Manual testing with real git repos
- Document each command with examples
- Package and test installation via pip
- Keep dependencies minimal (click, psutil, toml, libtmux)
- Make operations resumable (handle Ctrl+C gracefully)
- Log operations for debugging (--verbose flag)
- Consider Windows compatibility (tmux alternatives)