> ## 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.

# fix-runbook

> Apply AI-generated repair suggestions to update a broken runbook.

## Synopsis

```bash theme={null}
npx @refrainai/cli fix-runbook -- \
  --runbook <path> \
  --report <path> \
  [options]
```

Reads an execution report (generated by `--self-heal` or `--report`), extracts AI repair suggestions, and interactively applies them to the runbook YAML.

## Required arguments

| Argument           | Description                             |
| ------------------ | --------------------------------------- |
| `--runbook <path>` | Path to the runbook YAML file to patch  |
| `--report <path>`  | Path to the execution report (Markdown) |

## Optional arguments

### AI model

| Argument                      | Default             | Description                              |
| ----------------------------- | ------------------- | ---------------------------------------- |
| `--model <id>`                | `claude-sonnet-4-6` | AI model ID                              |
| `--model-provider <provider>` | `anthropic`         | AI provider                              |
| `--model-base-url <url>`      | -                   | Base URL for OpenAI-compatible endpoints |

### Advanced

| Argument          | Default | Description               |
| ----------------- | ------- | ------------------------- |
| `--locale <code>` | `en`    | UI language: `en` or `ja` |

## How it works

<Steps>
  <Step title="Extract suggestions">
    AI reads the report and extracts actionable repair suggestions.
  </Step>

  <Step title="Review each suggestion">
    For each suggestion, you can choose to apply, skip, or abort.
  </Step>

  <Step title="Generate patches">
    AI generates YAML patches and shows a diff preview.
  </Step>

  <Step title="Confirm and write">
    After confirmation, the patched runbook is written to disk.
  </Step>
</Steps>

## Examples

### Basic usage

First, run a self-heal execution to generate a report:

```bash theme={null}
npx @refrainai/cli execute -- \
  --runbook ./login-flow.yaml \
  --self-heal \
  --report
```

Then apply the repair suggestions:

```bash theme={null}
npx @refrainai/cli fix-runbook -- \
  --runbook ./login-flow.yaml \
  --report ./login-flow-report.md
```

## 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`) |
