cub run¶
Execute the autonomous task loop. This is the primary command for running AI agents on your tasks.
Synopsis¶
Description¶
The run command executes the main cub loop:
- Find the highest-priority ready task
- Generate a prompt from the task details
- Invoke the AI harness (Claude, Codex, Gemini, etc.)
- Monitor execution and track token usage
- Loop until tasks complete or budget exhausts
The loop continues until one of these conditions is met:
- All tasks are complete
- Budget is exhausted (tokens or cost)
- Maximum iterations reached
- User interrupt (Ctrl+C)
--onceflag used (single iteration)
Options¶
Core Options¶
| Option | Short | Description |
|---|---|---|
--harness NAME | -h | AI harness to use (claude, codex, gemini, opencode) |
--once | -1 | Run a single iteration then exit |
--task ID | -t | Run specific task by ID |
--model NAME | -m | Model to use (e.g., sonnet, opus, haiku) |
--name NAME | -n | Session name for tracking |
Filtering Options¶
| Option | Short | Description |
|---|---|---|
--epic ID | -e | Only work on tasks in this epic |
--label LABEL | -l | Only work on tasks with this label |
--ready | -r | List ready tasks without running |
Budget Options¶
| Option | Short | Description |
|---|---|---|
--budget AMOUNT | -b | Maximum budget in USD |
--budget-tokens COUNT | Maximum token budget |
Output Options¶
| Option | Short | Description |
|---|---|---|
--stream | -s | Stream harness output in real-time |
--monitor | Launch with live dashboard in tmux split pane |
Isolation Options¶
| Option | Description |
|---|---|
--worktree | Run in isolated git worktree |
--worktree-keep | Keep worktree after run completes |
--sandbox | Run in Docker sandbox for isolation |
--sandbox-keep | Keep sandbox container after run |
--no-network | Disable network access (requires --sandbox) |
--parallel N | -p |
Direct Mode Options¶
| Option | Short | Description |
|---|---|---|
--direct TASK | -d | Run directly with provided task (string, @file, or - for stdin) |
--gh-issue NUM | Work on a specific GitHub issue by number |
Examples¶
Basic Usage¶
# Run with auto-detected harness
cub run
# Run with specific harness
cub run --harness claude
# Single iteration mode
cub run --once
# Run with streaming output
cub run --stream
Task Filtering¶
# Run specific task
cub run --task cub-123
# Work only on epic's tasks
cub run --epic backend-v2
# Work on labeled tasks
cub run --label priority
# List ready tasks without running
cub run --ready
Budget Control¶
# Set cost budget to $5
cub run --budget 5.0
# Set token budget
cub run --budget-tokens 100000
# Combine budget limits
cub run --budget 10.0 --budget-tokens 500000
Monitoring¶
# Stream output in real-time
cub run --stream
# Launch with tmux dashboard
cub run --monitor
# Named session for tracking
cub run --name "auth-feature"
Isolation¶
# Run in isolated git worktree
cub run --worktree
# Keep worktree after completion
cub run --worktree --worktree-keep
# Run in Docker sandbox
cub run --sandbox
# Sandbox without network access
cub run --sandbox --no-network
Parallel Execution¶
# Run 3 independent tasks in parallel
cub run --parallel 3
# Parallel with specific harness
cub run --parallel 4 --harness claude
Direct Mode¶
# Run with inline task description
cub run --direct "Add a logout button to the navbar"
# Read task from file
cub run --direct @task.txt
# Read task from stdin
echo "Fix the typo in README" | cub run --direct -
# Work on GitHub issue
cub run --gh-issue 123
Harness Selection¶
Cub auto-detects available harnesses in this priority order:
claude- Claude Codegemini- Google Geminicodex- OpenAI Codexopencode- OpenCode
Override with --harness or configure in .cub.json:
Model Selection¶
Specify models using the --model flag or task labels:
Tasks can specify a model via labels:
Exit Codes¶
| Code | Meaning |
|---|---|
0 | Run completed successfully |
1 | Run failed (task error, harness error, etc.) |
130 | Interrupted by user (Ctrl+C) |
Signal Handling¶
Cub handles SIGINT (Ctrl+C) gracefully:
- First interrupt: Finishes current task, then exits
- Second interrupt: Force exits immediately
Status File¶
Each run creates a status file at:
The status file contains:
- Current phase and iteration
- Task progress
- Budget usage (tokens, cost)
- Event log
Monitor with cub monitor or read directly.
Related Commands¶
cub status- View task progresscub monitor- Live dashboardcub artifacts- View run outputscub prep- Create tasks from vision
See Also¶
- Run Loop Guide - Understanding the execution loop
- Task Selection - How tasks are prioritized
- Budget Guide - Managing token and cost limits