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

# Auto-fix

> Let cubic fix the issues it finds in your pull requests

cubic can automatically fix the issues from its review. It checks each issue, pushes fixes for the real ones to your pull request, and replies on every thread.

Instead of copying the **Prompt for AI agents** into your own coding agent, let cubic do the work. You only need to answer the questions it can't decide alone.

> [!NOTE]
>
> Auto-fix is in beta. Paid plans and trials include monthly auto-fix usage. See
> [Limits](#limits).

![cubic's Confirmed reply on a resolved review thread, naming its fix commit](https://mintcdn.com/cubic-2/6QrbJp8zZv4Iv9H1/ai-review/images/auto-fix-reply.png?fit=max\&auto=format\&n=6QrbJp8zZv4Iv9H1\&q=85\&s=6fd8ca1900f331d32cafe05040b77813)

## How it works

When cubic finishes reviewing your pull request, auto-fix:

1. **Checks each issue** - Reads the code to see if the issue is real
2. **Fixes the real ones** - Makes the change and runs your lint, type-check, and tests where it can
3. **Pushes the fix** - Commits to your PR branch
4. **Replies on each thread** - Explains what it decided and resolves the thread when it's done

With more than 10 issues, auto-fix works in batches of 10. Each batch's fixes and replies reach your pull request before it starts the next, and the run's progress comment counts the issues done so far.

Each of cubic's fix pushes gets a new review unless the PR is a draft and draft reviews are off. Auto-fix keeps going until a review finds no open issues. While auto-fix is on, cubic reviews its own fix pushes even when automatic reviews of new commits are off in the repository's [AI review settings](https://www.cubic.dev/ai-review?tab=setup\&card=ai-review-card-incremental-reviews) or with `reviews.incremental_commits: false` in `cubic.yaml`. Pushes by people and other bots follow that setting.

![cubic's fix commit in the pull request's commit list](https://mintcdn.com/cubic-2/6QrbJp8zZv4Iv9H1/ai-review/images/auto-fix-commit.png?fit=max\&auto=format\&n=6QrbJp8zZv4Iv9H1\&q=85\&s=a9b1c3cf064243205a5ea56584812e8f)

## What cubic replies

Each reply starts with cubic's decision:

| Reply starts with | Meaning | Thread |
| - | - | - |
| **Confirmed.** | The issue is real. cubic fixed it and names the commit. | Resolved |
| **Not an issue.** | The issue doesn't hold, or the change isn't worth the risk. | Resolved |
| **Kept as intended.** | Issue stands; your explanation says to keep the change. | Resolved |
| **Already fixed.** | A later commit fixed it. | Resolved |
| **No longer applies.** | The code it flagged is gone. | Resolved |
| **Needs your input.** | It needs a decision from you. cubic asks a question. | Open |

cubic keeps its fixes small and in line with your pull request's goal, as its title and description state it. When a fix would significantly change how the pull request is built, such as implementing a feature, taking a different approach or deleting a substantial part of your changes, or would undo part of that goal, cubic asks you instead.

Before cubic undoes or rewrites something a person changed in the pull request, it checks that commit's message and what people with write access said on the pull request when that context is available. If they explain the change, cubic leaves it as it is. The GitHub lookups are best-effort; when context is missing or intent remains unclear, cubic asks you.

Want a say before it runs? Reply on the thread. If you have write access, cubic follows your reply. For example, "leave it" means cubic won't change the code.

## Turn on auto-fix for a pull request

Anyone with write access to the repository can turn auto-fix on or off from:

* **GitHub** - Click **Turn on auto-fix** in the footer of cubic's review
* **PR description** - Click the **Auto-fix** switch next to **View guided diff**
* **cubic** - Use the **Auto-fix** switch on the PR page
* **Slack** - Click **Enable auto-fix** on cubic's review message
* **MCP** - Ask your coding agent to call `set_pr_auto_fix` on the [cubic MCP server](https://docs.cubic.dev/ide/mcp-server.md)

![Turn on auto-fix link in the footer of cubic's review](https://mintcdn.com/cubic-2/6QrbJp8zZv4Iv9H1/ai-review/images/auto-fix-toggle-pr.png?fit=max\&auto=format\&n=6QrbJp8zZv4Iv9H1\&q=85\&s=1285a9e3237f5daed58bae52765f7e2e)

Auto-fix starts right away on any open issues. cubic commits the fixes as its own GitHub app, not as the person who turned it on.

Turning it on from GitHub or Slack opens the pull request's fix session, where you can watch the run start. If there are no open issues yet, the session shows that auto-fix is waiting for the review cubic is running, or for its next review if none is in progress.

## Turn on auto-fix for a repository

Admins and members can set auto-fix for a repository in [AI review → Auto-fix](https://www.cubic.dev/ai-review?tab=auto-fix):

* **Off** - Auto-fix isn't available
* **On demand** (default) - Someone turns it on for each pull request
* **On** - Auto-fix turns on for every pull request that matches your rules. People can still turn it off on a pull request

![Auto-fix card set to On, with an Only auto-fix rule for one author and a Never auto-fix rule for bots](https://mintcdn.com/cubic-2/bMSkAUE9tCHFfqrK/ai-review/images/auto-fix-settings.png?fit=max\&auto=format\&n=bMSkAUE9tCHFfqrK\&q=85\&s=dc84bc6b9c2efb41b5e71562487dd326)

### Rules

When auto-fix is **On**, rules under **Advanced** pick which pull requests get auto-fix:

* **Only auto-fix when…** - A pull request must match each of these. For example, an **Author** rule with your GitHub username runs auto-fix on your pull requests only
* **Never auto-fix when…** - Any match skips the pull request. For example, skip `*[bot]` authors or PRs with a `no-auto-fix` label

Rules can match the author, label, title, head branch, or base branch. They only decide whether auto-fix starts. Once it's on, turn it off on the pull request.

You can also set the mode and rules in [cubic.yaml](https://docs.cubic.dev/configure/cubic-yaml.md), under `issues`. `auto_fix_rules` takes the same PR keys as `auto_approve_rules`: `only_` or `exclude_` followed by `authors`, `labels`, `titles`, `head_branches`, or `base_branches`.

```yaml theme={null}
issues:
  auto_fix: on # off | on_demand | on
  auto_fix_rules:
    only_authors:
      - alice
    exclude_labels:
      - no-auto-fix
```

If a rule in `cubic.yaml` has a whitespace-only list item, a value longer than 256 characters after trimming, or an empty `only_` list, cubic ignores all the rules and keeps auto-fix **On demand** until you fix them, or **Off** if the file sets `auto_fix: off`. An empty-string item (such as `""`) invalidates the entire YAML file and falls back to UI settings, which may still have auto-fix **On**.

## Follow a run

Each run opens as a fix session in [Fixes](https://www.cubic.dev/code/fix). You can watch the agent work and see what it fixed. You can't send it messages.

![An auto-fix run's fix session in cubic, showing the agent's steps and the pushed fix](https://mintcdn.com/cubic-2/bMSkAUE9tCHFfqrK/ai-review/images/auto-fix-session.png?fit=max\&auto=format\&n=bMSkAUE9tCHFfqrK\&q=85\&s=f95133309581b888bc8f1e92f739cdb9)

Open the session from:

* The **cubic · Auto-fix** check on the pull request
* cubic's comment on the pull request
* The cubic PR page

Click **Stop fix** to stop a run, or **Retry fix** to rerun a failed one.

## Stop auto-fix

* **Turn it off** - From any place you can turn it on. A run in progress finishes first
* **Push your own commits** - cubic stops the current run and picks up again after the next review
* **Close or merge the pull request** - Auto-fix turns off, and the pull request's fix sessions move to **Archived**

## Limits

Paid plans and trials include auto-fix usage per developer, pooled across your organization. Pro and Max include more than Team. [Settings → Usage](https://www.cubic.dev/settings?tab=usage) shows how much you've used.

Only fixes count, so runs that fix nothing are free. Usage resets monthly, and a trial's usage covers the whole trial.

When your usage is used up, auto-fix pauses until it resets. The PR page shows why it paused and when it resumes.

If auto-fix can't fix a failing check, for example because it's flaky, it stops retrying that check on the pull request, and keeps fixing the others. Click **Retry CI** on the PR page to try the failing checks again. If CI passes on a later push, auto-fix picks the check up again.

## Tell cubic how to fix

cubic reads your repository's `AGENTS.md`. Keep general guidance for coding agents there.

For guidance just for cubic's fixes, like which issues are worth fixing in your codebase, add [coding agent instructions](https://docs.cubic.dev/ai-review/coding-agents.md#coding-agent-instructions).

## Troubleshooting

> [accordion] Not seeing Turn on auto-fix?
>
> * In [AI review → Auto-fix](https://www.cubic.dev/ai-review?tab=auto-fix), make sure the **Fix with cubic button** is on, the coding agent provider is **Default** (cubic), and auto-fix isn't **Off**
> * Make sure you have write access to the repository
> * Pull requests from forks aren't supported, because cubic can't push to them

> [accordion] Auto-fix didn't turn on by itself?
>
> * Check that the repository is set to **On** and the pull request matches your rules
> * If someone turned auto-fix off on the pull request, it stays off there. Turn it back on from the pull request
> * With label rules, auto-fix turns on after the first review, not when the PR opens

> [accordion] Auto-fix paused?
>
> * Your organization used this month's auto-fix usage. See [Limits](#limits)
> * CI fixes are paused when auto-fix couldn't fix the checks still failing. Click **Retry CI** on the PR page to try again
> * After the reset date shown on the PR page, auto-fix resumes at cubic's next review. To resume right away, click **retry** next to **paused** on the PR page

> [accordion] Auto-fix stopped?
>
> * After three failed runs in a row, auto-fix stops. Click **Retry fix** in the fix session or push a commit
> * If you pushed commits, auto-fix picks up again after cubic reviews them

> [accordion] Installs from GitHub Packages failing?
>
> * GitHub Packages needs a token from your GitHub CLI or a classic personal access token with the `read:packages` scope. Fine-grained tokens don't work
> * When cubic's setup agent asks for the token, choose **Upload from your machine** so your coding agent uploads a token from your GitHub CLI, or paste a classic token with `read:packages`. See [Tokens for GitHub Packages](https://docs.cubic.dev/ide/mcp-server.md#tokens-for-github-packages)
> * cubic uses the token only to check it with GitHub and to install packages, from your repository's npm scopes when they're set, and never puts it in the sandbox

> [accordion] Want cubic to change a decision?
>
> * Auto-fix doesn't revisit an issue it already decided, but you can still ask for a fix. Comment `@cubic fix this` on the thread, and cubic starts a [separate fix](https://docs.cubic.dev/ai-review/coding-agents.md#tagging-cubic-in-github-or-cubic)
> * For **Needs your input.**, tag cubic with your answer, for example `@cubic keep three retries and fix this`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.