$npx -y skills add disler/mac-mini-agent --skill driveTerminal automation CLI for AI agents. Use drive to create tmux sessions, execute commands, send keystrokes, read output, poll for patterns, run commands in parallel across sessions, and manage processes. Always use --json for structured output.
| 1 | # Drive — Terminal Automation via tmux |
| 2 | |
| 3 | Run from: `cd apps/drive && uv run python main.py <command>` |
| 4 | |
| 5 | Drive gives you full programmatic control over tmux sessions — creating terminals, running commands, reading output, and orchestrating parallel workloads. |
| 6 | |
| 7 | ## Commands |
| 8 | |
| 9 | ### session — Manage tmux sessions |
| 10 | |
| 11 | ```bash |
| 12 | drive session create agent-1 --json # Opens a Terminal window (headed — default) |
| 13 | drive session create agent-1 --window build --json # Named window, headed |
| 14 | drive session create agent-1 --detach --json # Headless (no Terminal window) |
| 15 | drive session list --json # List all sessions |
| 16 | drive session kill agent-1 --json # Kill a session |
| 17 | ``` |
| 18 | |
| 19 | **Default is headed** — a new Terminal.app window opens attached to the session so you can watch live. Only use `--detach` when you explicitly need a headless session. |
| 20 | |
| 21 | ### run — Execute command and wait for completion |
| 22 | |
| 23 | Uses sentinel protocol (`__DONE_<token>:<exit_code>`) for reliable completion detection. |
| 24 | |
| 25 | ```bash |
| 26 | drive run agent-1 "npm test" --json # Run and wait |
| 27 | drive run agent-1 "make build" --timeout 120 --json # Custom timeout |
| 28 | drive run agent-1 "ls" --pane 1 --json # Target specific pane |
| 29 | ``` |
| 30 | |
| 31 | Returns: exit code, captured output between sentinels. |
| 32 | |
| 33 | ### send — Raw keystrokes (no completion waiting) |
| 34 | |
| 35 | For interactive tools (vim, ipython, etc.) where sentinel detection would interfere. |
| 36 | |
| 37 | ```bash |
| 38 | drive send agent-1 "vim file.txt" --json # Send command |
| 39 | drive send agent-1 ":wq" --json # Send vim command |
| 40 | drive send agent-1 "y" --no-enter --json # Send without Enter |
| 41 | ``` |
| 42 | |
| 43 | ### logs — Capture pane output |
| 44 | |
| 45 | ```bash |
| 46 | drive logs agent-1 --json # Current pane content |
| 47 | drive logs agent-1 --lines 500 --json # Last 500 lines of scrollback |
| 48 | drive logs agent-1 --pane 1 --json # Specific pane |
| 49 | ``` |
| 50 | |
| 51 | ### poll — Wait for pattern in output |
| 52 | |
| 53 | ```bash |
| 54 | drive poll agent-1 --until "BUILD SUCCESS" --json # Wait for pattern |
| 55 | drive poll agent-1 --until "ready" --timeout 60 --json # With timeout |
| 56 | drive poll agent-1 --until "error|success" --interval 2.0 --json # Custom interval |
| 57 | ``` |
| 58 | |
| 59 | Pattern is a regex. Returns matched text and full pane content. |
| 60 | |
| 61 | ### fanout — Parallel execution |
| 62 | |
| 63 | ```bash |
| 64 | drive fanout "npm test" --targets agent-1,agent-2,agent-3 --json # Same command, multiple sessions |
| 65 | drive fanout "git pull" --targets a1,a2,a3 --timeout 30 --json # With timeout |
| 66 | ``` |
| 67 | |
| 68 | Runs command in all target sessions concurrently using ThreadPoolExecutor. Returns ordered results. |
| 69 | |
| 70 | ## Key Patterns |
| 71 | |
| 72 | - **Create sessions first** — `drive session create` before running commands (headed by default — opens a Terminal window) |
| 73 | - **Use `run` for commands that complete** — It waits and gives you exit code + output |
| 74 | - **Use `send` for interactive tools** — vim, ipython, anything that doesn't "finish" |
| 75 | - **Use `poll` to wait for async events** — Watch for build completion, server startup, etc. |
| 76 | - **Use `logs` to inspect** — Check what happened in a pane |
| 77 | - **Use `fanout` for parallel work** — Run same command across multiple sessions |
| 78 | - **Use `proc` for process management** — List, kill, and inspect processes instead of raw ps/kill |
| 79 | - **Use `--json` always** — Structured output for reliable parsing |
| 80 | - **Write all files to /tmp** — Any JSON, logs, or other files you generate must go to `/tmp/`. Never write output files into the project directory. |
| 81 | |
| 82 | ### proc — Process management |
| 83 | |
| 84 | List, kill, inspect, and monitor processes. The agent's replacement for Activity Monitor. |
| 85 | |
| 86 | ```bash |
| 87 | drive proc list --json # All user processes |
| 88 | drive proc list --name claude --json # Filter by name |
| 89 | drive proc list --session job-abc123 --json # Processes in a tmux session |
| 90 | drive proc list --parent 12345 --json # Children of a PID |
| 91 | drive proc list --cwd /path/to/project --json # Processes running from a directory |
| 92 | drive proc kill 12345 --json # Kill by PID (SIGTERM → wait → SIGKILL) |
| 93 | drive proc kill --name "claude" --json # Kill all matching name |
| 94 | drive proc kill 12345 --tree --json # Kill PID and all children |
| 95 | drive proc kill 12345 --force --json # Force kill (SIGKILL, no grace period) |
| 96 | drive proc kill 12345 --signal 9 --json # Same as --force |
| 97 | drive proc tree 12345 --json # Show process tree from PID |
| 98 | drive proc top --session job-abc123 --json # Resource sn |