Skip to main content

Install

npm install -g @refrainai/cli

Commands

CommandDescription
generateGenerate a runbook by AI-driven browser exploration
executeExecute a runbook
fix-runbookApply repair suggestions from an execution report to a runbook
composeMerge multiple runbooks into a single branching runbook
runnerStart a remote browser runner
serveStart the API server for remote execution and Web Console

Global options

OptionDescription
--version, -vShow version number
--help, -hShow help

Basic usage

Generate a runbook

npx @refrainai/cli generate -- \
  --url "https://app.example.com/login" \
  --goal "Log in and export dashboard data" \
  --output ./login-export.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.

Execute a runbook

npx @refrainai/cli execute -- \
  --runbook ./login-export.yaml \
  --context ./context.md \
  --secrets ./secrets.json \
  --headless false \
  --model "claude-sonnet-4-6" \
  --model-provider anthropic

Self-heal mode

Validate a runbook with aggressive retry and generate repair suggestions:
npx @refrainai/cli execute -- \
  --runbook ./login-export.yaml \
  --self-heal

Apply fixes

Apply AI-generated repair suggestions to update a broken runbook:
npx @refrainai/cli fix-runbook -- \
  --runbook ./login-export.yaml \
  --report ./report.md

AI provider configuration

By default, Refrain uses Anthropic Claude. Set the API key:
export ANTHROPIC_API_KEY="sk-ant-..."
For other providers (OpenAI, Google, Azure, Bedrock, Vertex), see the AI provider setup guide for required environment variables and flags.

API key (Plan tiers)

Unlock advanced features by setting an API key:
export REFRAIN_API_KEY="rfn-eyJ..."
Or pass it per-command:
npx @refrainai/cli execute -- --runbook ./flow.yaml --api-key "rfn-eyJ..."
See Plan tiers for feature details.