Full reference for all index.js command-line flags.
node index.js --goal="<description>" [--type=<type>] [options]
| Flag | Type | Description |
|---|---|---|
--goal |
string | What the AI should build or fix. This is the natural-language project goal passed directly to the planner. |
| Flag | Type | Default | Description |
|---|---|---|---|
--type |
string | node |
Project type. Affects system prompts and planning strategy. See full type list below. |
Allowed types: embedded | cli | node | web | htmlcss | python | react | api | rust | docker | arduino | nextjs | go | fastapi | bash | svelte | tauri | vscode-ext | terraform | platformio | dotnet | cpp | c |
| --build | string | (none) | Shell command to run after each applied patch. E.g. "npm test", "pytest", "cargo test", "dotnet test", "make" |
| --target | string | cwd | Absolute or relative path to the project directory. All source file reads, patch writes, and build commands run relative to this directory. |
| --max-budget | number | 5.00 | Maximum USD spend before APE halts. Checked before every API call. |
| --max-tokens | number | 500000 | Maximum cumulative prompt + completion tokens before APE halts. |
| --resume | boolean | false | Continue from an existing ape-state.json. Restores task queue, budget counters, and iteration index. |
| --no-git | boolean | false | Skip all git operations (branch creation, staging, commits). Useful for non-git projects or CI pipelines. |
These flags override the automatic risk-based mode selection.
| Flag | Type | Default | Description |
|---|---|---|---|
--lite-only |
boolean | false |
Force LITE mode (single OpenAI pass) for every task. Fastest and cheapest. No adversarial review. |
--debate-only |
boolean | false |
Force DEBATE mode (4-phase GPT↔Claude) for every task. Slowest but highest confidence. |
Default behaviour (no flag):
riskClassifier.jsscores each change set on a 0–100 scale. Low/medium risk → LITE. High/critical risk → DEBATE. See risk-gated-debate.md.
--lite-only and --debate-only are mutually exclusive. If both are set, --debate-only wins.
| Flag | Type | Default | Description |
|---|---|---|---|
--apply |
boolean | false |
Actually write patches to disk via git apply. Without this flag, APE runs in dry-run mode — plans, reviews, and shows the diff, but never modifies files. |
--dry-run |
boolean | (implied) | No-op flag provided for explicitness. APE is always in dry-run mode unless --apply is set. |
Safe default: omitting
--applyis intentional. Run APE without it first to review what it would do.
| Flag | Type | Default | Description |
|---|---|---|---|
--allow-protected |
boolean | false |
Allow APE to propose changes inside src/protocol, src/radio, and src/routing. Without this flag, patches touching these paths are logged as warnings and the risk score is elevated. |
--allow-isr |
boolean | false |
Allow patches containing ISR, IRAM_ATTR, or interrupt handler code. Without this, such patches trigger automatic escalation to DEBATE mode. |
--confidence-threshold |
number | 70 |
Minimum consensus confidence score (0–100) required to pass. Tasks scoring below this are blocked and reported as failed. Raise for critical firmware; lower for experimental work. |
| Flag | Type | Default | Description |
|---|---|---|---|
--auto-commit |
boolean | false |
After each successful apply + build, automatically propose a commit (human still sees a Y/N prompt). Without this, APE asks explicitly before staging files. |
| Flag | Type | Default | Description |
|---|---|---|---|
--verbose |
boolean | false |
Print full raw model JSON responses after each debate phase. Useful for diagnosing unexpected AI outputs or tuning prompts. Only affects DEBATE mode (LITE mode has no per-phase viewer). |
node index.js \
--goal="Add input validation to the user registration endpoint" \
--type=node \
--build="npm test"APE plans, reviews, and shows the diff. Nothing written to disk.
node index.js \
--goal="Add input validation to the user registration endpoint" \
--type=node \
--build="npm test" \
--apply \
--max-budget=3.00node index.js \
--goal="Refactor the payment transaction rollback handler" \
--type=node \
--debate-only \
--allow-protected \
--apply \
--max-budget=10.00All tasks go through the 4-phase GPT↔Claude debate, regardless of risk score.
node index.js \
--goal="Refactor routing layer" \
--type=embedded \
--debate-only --apply --verbosePrints raw model JSON after each debate phase. Useful for debugging model behaviour.
node index.js \
--goal="Update the app version in package.json" \
--type=node \
--lite-only \
--confidence-threshold=90 \
--applynode index.js \
--goal="Add JWT authentication to the FastAPI backend" \
--type=python \
--build="pytest" \
--resume \
--applynode index.js \
--goal="Add async file processing with a progress bar" \
--type=node \
--target=./my-api \
--build="npm test" \
--no-git \
--apply \
--max-budget=2.00Set in .env (copy from .env.example):
| Variable | Default | Description |
|---|---|---|
PROPOSER_PROVIDER |
openai |
Provider for Phases 1 & 3 (proposal + rebuttal). Values: openai, claude, opencode |
PROPOSER_MODEL |
gpt-4.1 |
Model name passed to the proposer provider |
CRITIC_PROVIDER |
claude |
Provider for Phases 2 & 4 (challenge + final audit). Values: openai, claude, opencode |
CRITIC_MODEL |
claude-opus-4-5 |
Model name passed to the critic provider |
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY |
✅ | — | OpenAI API key |
OPENAI_MODEL |
❌ | gpt-4.1 |
Default GPT model (used if PROPOSER_MODEL / CRITIC_MODEL not set) |
OPENAI_TIMEOUT_MS |
❌ | 120000 |
Per-request timeout |
OPENAI_MAX_RETRIES |
❌ | 3 |
Retry attempts on transient errors |
| Variable | Required | Default | Description |
|---|---|---|---|
ANTHROPIC_API_KEY |
✅ | — | Anthropic API key |
ANTHROPIC_MODEL |
❌ | claude-opus-4-5 |
Default Claude model |
ANTHROPIC_TIMEOUT_MS |
❌ | 120000 |
Per-request timeout |
ANTHROPIC_MAX_RETRIES |
❌ | 3 |
Retry attempts on transient errors |
OpenCode exposes an OpenAI-compatible endpoint (/zen/v1/chat/completions). Free models require no API key.
| Variable | Required | Default | Description |
|---|---|---|---|
OPENCODE_ZEN_BASE_URL |
✅ (if using opencode) | — | Base URL, e.g. https://opencode.ai |
OPENCODE_ZEN_API_KEY |
❌ | — | API key (leave blank for free-tier models) |
OPENCODE_DEFAULT_MODEL |
❌ | glm-5-free |
Default model when PROPOSER_MODEL/CRITIC_MODEL is not set |
OPENCODE_ALLOW_ANY_MODEL |
❌ | 0 |
Set to 1 to bypass the built-in model allowlist |
Built-in allowlist (free models, accepted without OPENCODE_ALLOW_ANY_MODEL=1):
glm-5-freeminimax-m2.5-freekimi-k2.5-freebig-pickle
| Variable | Default | Description |
|---|---|---|
MAX_BUDGET |
5.00 |
USD cap before APE halts |
APE_MAX_TOKENS |
500000 |
Token cap before APE halts |
RISK_THRESHOLD |
55 |
Risk score (0-100) above which DEBATE mode is forced |
DEBATE_ROUNDS |
4 |
Max phases per debate session |
DEBUG |
❌ | Set to 1 for full stack traces on fatal errors |
# .env additions
OPENCODE_ZEN_BASE_URL=https://opencode.ai
PROPOSER_PROVIDER=opencode
PROPOSER_MODEL=glm-5-free
CRITIC_PROVIDER=opencode
CRITIC_MODEL=kimi-k2.5-freenode index.js \
--goal="Refactor the data pipeline error handling" \
--type=python \
--build="pytest" \
--debate-only \
--applyCost: $0.00 (both models are free-tier on OpenCode).
# .env additions
OPENCODE_ZEN_BASE_URL=https://opencode.ai
PROPOSER_PROVIDER=openai
PROPOSER_MODEL=gpt-4.1
CRITIC_PROVIDER=opencode
CRITIC_MODEL=minimax-m2.5-freenode index.js \
--goal="Add pagination to the REST API" \
--type=api \
--build="npm test" \
--apply