Skip to main content

Synopsis

npx @refrainai/cli execute -- \
  --runbook <path> \
  [options]
Reads a runbook, resolves variables, and executes each step in a browser with self-healing selector resolution.

Required arguments

ArgumentDescription
--runbook <path>Path to the runbook file

Optional arguments

Execution

ArgumentDefaultDescription
--headless <bool>trueSet to false to show the browser window
--step-delay <ms>runbook valueOverride pauseBetweenSteps from the runbook
--output-dir <path>-Directory for download and export files
--merge-downloadsfalseMerge downloaded CSV files into one

Context & secrets

ArgumentDefaultDescription
--context <path>-Path to supplemental context markdown file
--secrets <path>-Path to secrets JSON file (all values treated as sensitive)

Output & debugging

ArgumentDefaultDescription
--screenshots <dir>-Directory to save screenshots
--video <dir>-Directory for video recording output
--reportfalseForce generate an execution report (Markdown)

Self-healing

ArgumentDefaultDescription
--self-healfalseEnable self-healing mode (aggressive retry + AI repair suggestions)
--self-heal enables all self-healing features and sets aggressive defaults. See self-heal mode for plan requirements.

Approval & notifications

ArgumentDefaultDescription
--approval-mode <mode>webApproval mode: web, slack, teams, or discord
--notify <mode>-Notification on completion: slack, teams, or discord
Slack/Teams/Discord approval requires Business plan or higher. Notifications require Team plan or higher.
Each platform requires specific environment variables (bot tokens, channel IDs, signing secrets). See Approval & Notifications for complete platform setup instructions.

AI model

ArgumentDefaultDescription
--model <id>claude-sonnet-4-6AI model ID
--model-provider <provider>anthropicAI provider
--model-base-url <url>-Base URL for OpenAI-compatible endpoints

Advanced

ArgumentDefaultDescription
--locale <code>enUI and AI prompt language: en or ja
--stealthfalseEnable stealth mode (bot detection evasion)
--proxy <url>-Proxy URL (e.g., http://user:pass@host:port)
--skill <names>-Comma-separated skill plugin names
--api-key <key>-API key for Pro/Team/Business/Enterprise features

Examples

Basic execution

npx @refrainai/cli execute -- \
  --runbook ./login-flow.yaml \
  --context ./context.md \
  --secrets ./secrets.json \
  --headless false \
  --model "claude-sonnet-4-6" \
  --model-provider anthropic
Set default model and provider via environment variables instead of passing them on every command. See default model configuration.

With screenshots

npx @refrainai/cli execute -- \
  --runbook ./login-flow.yaml \
  --screenshots ./screenshots

Self-heal mode

npx @refrainai/cli execute -- \
  --runbook ./login-flow.yaml \
  --self-heal

With Slack approval

export SLACK_BOT_TOKEN="xoxb-..."
export SLACK_CHANNEL_ID="C01234567"

npx @refrainai/cli execute -- \
  --runbook ./payment-flow.yaml \
  --approval-mode slack \
  --notify slack

With secrets

npx @refrainai/cli execute -- \
  --runbook ./login-flow.yaml \
  --secrets ./secrets.json

Using environment variables and secrets

Pass credentials securely using environment variables and the --secrets flag:
export APP_EMAIL="[email protected]"

npx @refrainai/cli execute -- \
  --runbook ./login-flow.yaml \
  --secrets '{"APP_PASSWORD": "s3cret!"}'

Environment variables

VariableDescription
AI_MODEL_IDDefault for --model
AI_MODEL_PROVIDERDefault for --model-provider
REFRAIN_LOCALEDefault for --locale (en or ja)
REFRAIN_API_KEYDefault for --api-key