> ## Documentation Index
> Fetch the complete documentation index at: https://docs.therefrain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# generate

> Generate a runbook by AI-driven browser exploration.

## Synopsis

```bash theme={null}
npx @refrainai/cli generate -- \
  --url <url> \
  --goal <goal> \
  --output <path> \
  [options]
```

AI opens a browser, explores the target web app to accomplish the given goal, records each action, reviews the steps, and outputs a clean runbook.

## Required arguments

| Argument          | Description                                       |
| ----------------- | ------------------------------------------------- |
| `--url <url>`     | Starting URL to begin exploration                 |
| `--goal <goal>`   | Goal to accomplish (natural language description) |
| `--output <path>` | Output path for the generated runbook             |

## Optional arguments

### Exploration

| Argument                 | Default | Description                               |
| ------------------------ | ------- | ----------------------------------------- |
| `--max-iterations <num>` | `20`    | Maximum exploration loop iterations       |
| `--step-delay <ms>`      | `500`   | Wait time between steps (milliseconds)    |
| `--headless <bool>`      | `true`  | Set to `false` to show the browser window |

### Context & secrets

| Argument           | Default | Description                                                                            |
| ------------------ | ------- | -------------------------------------------------------------------------------------- |
| `--context <path>` | -       | Path to a supplemental context markdown file                                           |
| `--secrets <path>` | -       | Path to secrets JSON file (`{"key": "value"}` format, all values treated as sensitive) |

### Output & debugging

| Argument              | Default | Description                          |
| --------------------- | ------- | ------------------------------------ |
| `--screenshots <dir>` | -       | Directory to save screenshots        |
| `--video <dir>`       | -       | Directory for video recording output |

### AI model

| Argument                      | Default             | Description                                                                                     |
| ----------------------------- | ------------------- | ----------------------------------------------------------------------------------------------- |
| `--model <id>`                | `claude-sonnet-4-6` | AI model ID                                                                                     |
| `--model-provider <provider>` | `anthropic`         | AI provider: `anthropic`, `openai`, `openai-compatible`, `google`, `azure`, `bedrock`, `vertex` |
| `--model-base-url <url>`      | -                   | Base URL for OpenAI-compatible endpoints                                                        |

### Advanced

| Argument          | Default | Description                                                |
| ----------------- | ------- | ---------------------------------------------------------- |
| `--locale <code>` | `en`    | UI and AI prompt language: `en` or `ja`                    |
| `--stealth`       | `false` | Enable stealth mode (bot detection evasion)                |
| `--proxy <url>`   | -       | Proxy URL (e.g., `http://user:pass@host:port`)             |
| `--skill <names>` | -       | Comma-separated skill plugin names (e.g., `google-sheets`) |

<Note>
  `--stealth` and `--proxy` require Pro plan or higher. `--skill` requires Pro plan or higher.
</Note>

## Examples

### Basic generation

```bash theme={null}
npx @refrainai/cli generate -- \
  --url "https://app.example.com/login" \
  --goal "Log in with email and password, then navigate to the settings page" \
  --output ./login-settings.yaml \
  --context ./context.md \
  --secrets ./secrets.json \
  --model "claude-sonnet-4-6" \
  --model-provider anthropic
```

<Tip>
  Set default model and provider via environment variables instead of passing them on every command. See [default model configuration](/guides/ai-setup#default-model).
</Tip>

### With browser visible

```bash theme={null}
npx @refrainai/cli generate -- \
  --url "https://staging.example.com" \
  --goal "Create a new project named 'Test Project'" \
  --output ./create-project.yaml \
  --headless false
```

### With context file

Provide additional context to help AI understand your app:

```bash theme={null}
npx @refrainai/cli generate -- \
  --url "https://app.example.com" \
  --goal "Export the monthly report as CSV" \
  --output ./export-report.yaml \
  --context ./app-guide.md
```

### With secrets

```bash theme={null}
npx @refrainai/cli generate -- \
  --url "https://app.example.com/login" \
  --goal "Log in and view the dashboard" \
  --output ./login.yaml \
  --secrets ./secrets.json
```

Where `secrets.json`:

```json theme={null}
{
  "email": "admin@example.com",
  "password": "s3cret!"
}
```

### Using OpenAI

```bash theme={null}
export OPENAI_API_KEY="sk-..."

npx @refrainai/cli generate -- \
  --url "https://app.example.com" \
  --goal "Fill out the contact form" \
  --output ./contact-form.yaml \
  --model "gpt-4o" \
  --model-provider openai
```

### With screenshots and video

```bash theme={null}
npx @refrainai/cli generate -- \
  --url "https://app.example.com" \
  --goal "Complete the onboarding flow" \
  --output ./onboarding.yaml \
  --screenshots ./screenshots \
  --video ./videos
```

## Environment variables

| Variable            | Description                           |
| ------------------- | ------------------------------------- |
| `AI_MODEL_ID`       | Default for `--model`                 |
| `AI_MODEL_PROVIDER` | Default for `--model-provider`        |
| `REFRAIN_LOCALE`    | Default for `--locale` (`en` or `ja`) |
