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

# ubx fix

> Auto-fix validation errors using Claude.

`ubx fix` runs `ubx validate`, sends errors and source code to Claude, and proposes fixes as a unified diff with a confirmation prompt.

<Note>
  Requires `UBX_AI_API_KEY` or `ai.api_key` in `ubx.yaml`.
</Note>

## Usage

```bash theme={null}
ubx fix [path] [flags]
```

## Examples

```bash theme={null}
ubx fix                  # fix all errors in current directory
ubx fix main.iac         # fix specific file
ubx fix --dry-run        # show proposed diff without writing
ubx fix --yes            # apply fixes without confirmation
```

## Flags

| Flag        | Description                                  |
| ----------- | -------------------------------------------- |
| `--dry-run` | Show proposed diff without writing any files |
| `--yes`     | Apply all fixes without confirmation prompt  |

## Output

```
/path/to/main.iac
────────────────────────────────────────────────────────────
  1. Removed invalid 'ephemeral' attribute from unit block

--- a/main.iac
+++ b/main.iac
@@ -2,5 +2,4 @@
 unit "aws_s3_bucket_v2" "assets" {
-  ephemeral = true
   bucket    = "my-assets"
 }

Apply fixes to 1 file(s)? [y/N]
```

## Behaviour

* If no errors → exits 0 with "✓ no errors found"
* If errors → sends source + errors to Claude, shows diff, prompts
* `--dry-run` shows diff but never writes
* `--yes` applies without prompting (CI/CD)

## Setup

```bash theme={null}
export UBX_AI_API_KEY=sk-ant-...
ubx fix
```
