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

> ## Agent Instructions
> Search and read these docs from your coding agent with the [CodeRabbit documentation MCP server](https://docs.coderabbit.ai/mcp).
> Give your coding agent the [CodeRabbit Agent Skill](https://docs.coderabbit.ai/.well-known/agent-skills/index.json) for configuring reviews, running CLI reviews, coding tasks and API calls.

# Repair failing pull requests automatically

> Have the Coding Agent push fixes for failed CI checks and CodeRabbit findings to pull requests.

Set up an Auto-fix automation that pushes fixes to a pull request when a CI check fails or CodeRabbit posts findings.

## What you get

* When a CI check fails or CodeRabbit posts findings on a pull request that meets the automation's conditions, the Coding Agent pushes a fix commit to its branch.
* The automation acts on future matches only, after new activity arrives, such as a CI run or a review comment. A pull request that was already failing when you saved waits for its next activity.
* Each repair is a Coding Agent run and can cost money. See [Coding Agent access and billing](https://docs.coderabbit.ai/code/access-and-billing.md).

What CodeRabbit won't do:

* Repair a pull request that doesn't meet the conditions.
* Approve or merge the pull request. To merge it, see [Merge low-risk pull requests automatically](https://docs.coderabbit.ai/triage/guides/merge-low-risk-pull-requests.md).
* Act on reviewers' comments. The automation repairs failed CI checks and CodeRabbit findings only.

To stop, select **Pause** on the automation's row in [PR Automations](https://app.coderabbit.ai/triage/settings), or delete it. A repair already in progress can still push its commit. Commits the automation pushed stay on the branch, and you revert them like any other commit.

## Before you start

GitHub Cloud (This guide is written for GitHub Cloud (github.com). Other providers support fewer of its steps.) | Team Plan (This feature is available on Team (formerly Pro+), Advanced, and Enterprise. Please refer to our pricing page for more information about our plans and features.)

| Requirement | Who does it | Where |
| - | - | - |
| Permission to enable automations that push commits | CodeRabbit organization administrator | [PR Automations](https://app.coderabbit.ai/triage/settings) |
| Coding Agent access for the organization | CodeRabbit organization administrator | [Coding Agent access](https://docs.coderabbit.ai/code/access-and-billing.md#access) |
| Recommended for setup: a `triage-trial` label in the repository | Someone with write access to the repository | GitHub: **Issues** > **Labels** |

If your branch rule dismisses stale approvals, a fix commit pushed after an approval needs a fresh approval.

## 1. Create the Auto-fix automation

> [!WARNING]
>
> Once saved, this automation pushes commits to the branches of matching pull requests without asking first. The author and reviewers see each commit, and each run can cost money. Start with a test repository if you have one.

**1. Start from the template**

In [PR Automations](https://app.coderabbit.ai/triage/settings), select **Try now** on **Auto-fix PRs**. The editor opens with all repositories and the trigger condition **PR state** is **Open**.

**2. Optional: Repair only some pull requests**

To narrow the repairs, add a condition for each property a pull request must have, such as **Merge risk** or **Review depth**: under **Triggers**, select the **+** on the trigger card and set the condition. The conditions show **and** between them. Don't use **Add trigger**: it adds a separate trigger joined by OR. If you're following [Take low-risk pull requests from open to merged](https://docs.coderabbit.ai/triage/guides/low-risk-prs-open-to-merged), add **Merge risk** **is any of** **Minimal**, **Low** and **Review depth** **is** **Light**.

**3. Choose the repository**

Under **Repositories**, choose **Selected** and pick the repository. It gets its own card.

**4. Optional: Limit it to pull requests you opt in**

To keep repairs away from pull requests you didn't mean to include while you check the results, on the repository's card, select the **+**, set the new filter's property to **PR labels**, keep **has any of**, and choose `triage-trial`. Without this filter, once you save, the automation repairs every pull request in the repository that matches from then on.

**5. Choose what to fix**

In **Address**, keep **Failed CI checks** and **CodeRabbit findings** selected.

**6. Choose the timing**

Choose **Automatically** to repair as soon as a problem appears, or **After a set time** to give the author a chance to fix it first.

**7. Optional: Limit what repairs change**

To keep repairs inside the original change, describe the limits in **Additional instructions**, such as not changing public APIs or feature-flag defaults.

**8. Save and enable**

Select **Save automation**. This saves and enables it for future matches only. Without administrator access, the button reads **Save as paused**, and the automation doesn't run until an administrator turns it on.

## Test it

**1. Open a pull request**

In the repository you selected, open a small, contained pull request. If you set the label filter, add the `triage-trial` label.

**2. Break a check**

Push a commit that fails a CI check.

**3. Optional: Check the conditions you added**

If you narrowed the repairs, check that the pull request meets your conditions. For the low-risk ones, once CodeRabbit has reviewed the latest commit, the failing one, the **Merge Risk** line in CodeRabbit's summary comment shows **Minimal** or **Low** and the Triage card shows **Light review**. You can't force either rating. Until CodeRabbit has reviewed that commit, or if either shows anything else, the automation doesn't act. To show review depth on cards, see [What you can toggle](https://docs.coderabbit.ai/triage/your-triage-view.md#what-you-can-toggle).

**4. Check the outcome**

After the failed check reports, the Coding Agent pushes a fix commit to the branch, right away or after the delay you set. In PR Automations, select **View activity** to see the automation's run on the pull request.

## Widen the scope

If you set the label filter, remove it once **View activity** shows repairs only where you expect them, so the automation repairs every pull request in the repository that meets its conditions.

**1. Open the automation**

In PR Automations, select the pencil icon on the automation's row.

**2. Remove the label filter**

On the repository's card, select the **X** on the **PR labels** filter.

**3. Save**

Select **Save automation**.

## If something doesn't work

* **The automation didn't act.** Check that the pull request meets the automation's conditions, then check the automation's status and the pull request's outcome in **View activity**. See [An automation rule did not run](https://docs.coderabbit.ai/triage/troubleshooting.md#an-automation-rule-did-not-run).
* **A repair didn't arrive.** The organization may have lost Coding Agent access, or the repository may be on a provider or deployment that Auto-fix doesn't support. See [Coding Agent access](https://docs.coderabbit.ai/code/access-and-billing.md#access).

## Variations

* **Merge conflicts.** Select **Fix merge conflicts** on the pull request's Triage card. See [Repair a pull request](https://docs.coderabbit.ai/triage/actions.md#repair-a-pull-request).
* **Repair pull requests only just before the merge.** Use the merge automation's own auto fix in place of this automation. See [Merge low-risk pull requests automatically](https://docs.coderabbit.ai/triage/guides/merge-low-risk-pull-requests.md).
* **Other Git providers.** Auto-fix availability differs by provider and deployment. See [Provider availability](https://docs.coderabbit.ai/triage/rules.md#provider-availability).

## What's next

> [card] [Merge low-risk pull requests automatically](https://docs.coderabbit.ai/triage/guides/merge-low-risk-pull-requests.md)
>
> Merge low-risk pull requests once your conditions are met and the required checks pass.

> [card] [Remind reviewers in Slack](https://docs.coderabbit.ai/triage/guides/remind-reviewers-in-slack.md)
>
> Nudge authors and reviewers about pull requests that wait for review.

> [card] [Coding Agent access and billing](https://docs.coderabbit.ai/code/access-and-billing.md)
>
> Check who can use the Coding Agent and how its runs are counted.


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