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

# Apply Fixes

> Apply AI repair suggestions from a self-heal report to your runbook.

## Overview

The `fix-runbook` command takes a self-heal diagnostic report and applies AI-generated repair suggestions to your runbook. Each suggestion is presented for review before applying.

## Prerequisites

* A self-heal diagnostic report (generated by `--self-heal`)
* The original runbook that was used during self-heal

## Workflow

<Steps>
  <Step title="Generate a self-heal report">
    Run the runbook with `--self-heal` to produce a diagnostic report:

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

    The report is saved as `{runbook-name}-report.md` (e.g., `login-flow-report.md`).
  </Step>

  <Step title="Run fix-runbook">
    ```bash theme={null}
    npx @refrainai/cli fix-runbook -- \
      --runbook ./login-flow.yaml \
      --report ./login-flow-report.md
    ```
  </Step>

  <Step title="Review each suggestion">
    For each AI suggestion, the command shows:

    * The error and its classification category
    * The proposed fix (selector change, step modification, etc.)

    For each suggestion, choose:

    * **Apply** — Generate a patch and preview the diff
    * **Skip** — Move to the next suggestion
    * **Abort** — Stop processing remaining suggestions
  </Step>

  <Step title="Verify the fixed runbook">
    After applying fixes, run a normal execution to verify:

    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./login-flow.yaml \
      --context ./context.md \
      --headless false
    ```
  </Step>
</Steps>

## CLI reference

| Argument                      | Required | Description                                                  |
| ----------------------------- | :------: | ------------------------------------------------------------ |
| `--runbook <path>`            |    Yes   | Path to the runbook to fix                                   |
| `--report <path>`             |    Yes   | Path to the self-heal report                                 |
| `--model <id>`                |    No    | AI model for patch generation (default: `claude-sonnet-4-6`) |
| `--model-provider <provider>` |    No    | AI provider (default: `anthropic`)                           |
| `--locale <code>`             |    No    | UI language: `en` or `ja`                                    |

## What's next

<CardGroup cols={2}>
  <Card title="Self-heal mode" icon="wrench" href="/guides/self-heal">
    How to generate diagnostic reports.
  </Card>

  <Card title="Error classification" icon="triangle-exclamation" href="/concepts/error-classification">
    How failures are categorized.
  </Card>
</CardGroup>
