Environment Variables¶
Environment variables provide a flexible way to configure Cub without modifying config files. They are particularly useful for:
- CI/CD pipelines: Set configuration in your build environment
- Session overrides: Temporarily change settings without editing files
- Secrets: Pass sensitive values without storing them in config
Quick Reference¶
All environment variables at a glance:
| Variable | Type | Default | Description |
|---|---|---|---|
CUB_PROJECT_DIR | String | $(pwd) | Project directory |
CUB_MODEL | String | - | Claude model: haiku, sonnet, opus |
CUB_BUDGET | Number | 1000000 | Token budget limit |
CUB_MAX_ITERATIONS | Number | 100 | Max loop iterations |
CUB_DEBUG | Boolean | false | Enable debug logging |
CUB_STREAM | Boolean | false | Stream harness output |
CUB_BACKEND | String | auto | Task backend: auto, beads, json |
CUB_EPIC | String | - | Filter to epic ID |
CUB_LABEL | String | - | Filter to label name |
CUB_REQUIRE_CLEAN | Boolean | true | Enforce clean git state |
CUB_AUTO_CLOSE | Boolean | true | Auto-close tasks on success |
CUB_MAX_TASK_ITERATIONS | Number | 3 | Max attempts per task |
CUB_MAX_RUN_ITERATIONS | Number | 50 | Max iterations per run |
HARNESS | String | auto | Harness selection |
CLAUDE_FLAGS | String | - | Extra flags for Claude Code CLI |
CODEX_FLAGS | String | - | Extra flags for OpenAI Codex CLI |
GEMINI_FLAGS | String | - | Extra flags for Gemini CLI |
OPENCODE_FLAGS | String | - | Extra flags for OpenCode CLI |
Core Settings¶
CUB_PROJECT_DIR¶
Override the project directory.
| Property | Value |
|---|---|
| Type | String (path) |
| Default | Current working directory |
CUB_DEBUG¶
Enable verbose debug logging.
| Property | Value |
|---|---|
| Type | Boolean (true/false, 1/0) |
| Default | false |
Tip
Debug mode outputs detailed information about configuration loading, task selection, and harness execution.
CUB_STREAM¶
Stream harness output in real-time.
| Property | Value |
|---|---|
| Type | Boolean |
| Default | false |
When enabled, you see the AI's output as it generates, rather than waiting for task completion.
Budget & Limits¶
CUB_BUDGET¶
Set the token budget for the session.
| Property | Value |
|---|---|
| Type | Number (positive integer) |
| Default | 1000000 |
# Small budget for testing
CUB_BUDGET=50000 cub run --once
# Large budget for production
CUB_BUDGET=5000000 cub run
CUB_MAX_ITERATIONS¶
Set maximum loop iterations.
| Property | Value |
|---|---|
| Type | Number (positive integer) |
| Default | 100 |
CUB_MAX_TASK_ITERATIONS¶
Set maximum attempts per task.
| Property | Value |
|---|---|
| Type | Number (positive integer) |
| Default | 3 |
CUB_MAX_RUN_ITERATIONS¶
Set maximum total iterations per run.
| Property | Value |
|---|---|
| Type | Number (positive integer) |
| Default | 50 |
Task Selection¶
CUB_BACKEND¶
Force a specific task backend.
| Property | Value |
|---|---|
| Type | String |
| Default | auto |
| Allowed Values | auto, beads, json |
# Force beads backend
CUB_BACKEND=beads cub run
# Force JSON backend (legacy)
CUB_BACKEND=json cub run
CUB_EPIC¶
Filter tasks to a specific epic.
| Property | Value |
|---|---|
| Type | String (epic ID) |
| Default | - (no filter) |
CUB_LABEL¶
Filter tasks to a specific label.
| Property | Value |
|---|---|
| Type | String (label name) |
| Default | - (no filter) |
Clean State¶
CUB_REQUIRE_CLEAN¶
Enforce clean git state between tasks.
| Property | Value |
|---|---|
| Type | Boolean |
| Default | true |
CUB_AUTO_CLOSE¶
Automatically close tasks on successful completion.
| Property | Value |
|---|---|
| Type | Boolean |
| Default | true |
Harness Configuration¶
HARNESS¶
Select which AI harness to use.
| Property | Value |
|---|---|
| Type | String |
| Default | auto |
| Allowed Values | auto, claude, codex, gemini, opencode |
CUB_MODEL¶
Select Claude model variant.
| Property | Value |
|---|---|
| Type | String |
| Default | - |
| Allowed Values | haiku, sonnet, opus |
# Fast model for simple tasks
CUB_MODEL=haiku cub run
# Best model for complex tasks
CUB_MODEL=opus cub run
Note
This variable only affects the Claude harness. Other harnesses have their own model selection mechanisms.
Harness-Specific Flags¶
Pass additional flags to the underlying AI CLI tools.
CLAUDE_FLAGS¶
Extra flags for Claude Code CLI.
CODEX_FLAGS¶
Extra flags for OpenAI Codex CLI.
GEMINI_FLAGS¶
Extra flags for Google Gemini CLI.
OPENCODE_FLAGS¶
Extra flags for OpenCode CLI.
Usage Patterns¶
Development Testing¶
Quick testing with reduced limits:
export CUB_MODEL=haiku
export CUB_BUDGET=50000
export CUB_MAX_ITERATIONS=5
export CUB_REQUIRE_CLEAN=false
cub run --once
Debugging¶
Full debug output with streaming:
CI/CD Pipeline¶
Deterministic execution for continuous integration:
export CUB_BUDGET=2000000
export CUB_MAX_ITERATIONS=50
export CUB_BACKEND=beads
export CUB_REQUIRE_CLEAN=true
export HARNESS=claude
cub run
Epic-Focused Work¶
Target a specific epic with custom limits:
Boolean Values¶
For boolean environment variables, Cub accepts:
| True Values | False Values |
|---|---|
true, 1, yes, on | false, 0, no, off |
# All equivalent to true
CUB_DEBUG=true cub run
CUB_DEBUG=1 cub run
CUB_DEBUG=yes cub run
# All equivalent to false
CUB_DEBUG=false cub run
CUB_DEBUG=0 cub run
CUB_DEBUG=no cub run
Precedence¶
Environment variables override config files but are overridden by CLI flags:
Example: