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

# Fix CI failures

> Automatically fix failing CI checks with a stacked pull request or a direct commit.

export const Hint = ({type, children, headline, tip, href, cta}) => {
  const TIPS = {
    learnings: {
      headline: "Learnings",
      tip: "Review preferences CodeRabbit learns from your chat conversations and applies automatically to future reviews.",
      cta: "Learn about Learnings",
      href: "/knowledge-base/learnings",
      content: "Learnings"
    },
    walkthrough: {
      headline: "PR Walkthrough",
      tip: "A structured comment posted by CodeRabbit at the top of every pull request, summarizing changes, sequence diagrams, review effort, and more.",
      cta: "Learn about PR Walkthroughs",
      href: "/pr-reviews/walkthroughs",
      content: "Walkthrough"
    },
    "finishing-touches": {
      headline: "Finishing Touches",
      tip: "Post-review agentic actions (Autofix, writing docstrings or unit tests, and more) you trigger from a PR comment or a checkbox in the Walkthrough.",
      cta: "See all Finishing Touches",
      href: "/finishing-touches",
      content: "Finishing Touches"
    },
    "coding-plan": {
      headline: "Coding Plan",
      tip: "A detailed, codebase-aware implementation plan CodeRabbit generates from an issue or description, ready to hand off to any coding agent.",
      cta: "Learn about Coding Plans",
      href: "/plan",
      content: "Coding Plan"
    },
    "knowledge-base": {
      headline: "Knowledge Base",
      tip: "The collected context sources CodeRabbit draws on during reviews: Learnings, Code Guidelines, issue trackers, connected MCP servers, and cross-repo analysis.",
      cta: "Explore the Knowledge Base",
      href: "/knowledge-base",
      content: "Knowledge Base"
    },
    "path-instructions": {
      headline: "Path Instructions",
      tip: "Custom review rules that only apply to files matching a glob pattern, e.g. 'src/controllers/**'.",
      cta: "Configure path instructions",
      href: "/configuration/path-instructions",
      content: "Path Instructions"
    },
    "change-stack": {
      headline: "Change Stack",
      tip: "An improved code inspection interface that reorganizes a pull request from a flat file list into a structured, layer-by-layer walkthrough with range-specific summaries and diagrams when useful.",
      cta: "Learn about Change Stack",
      href: "/pr-reviews/change-stack",
      content: "Change Stack"
    },
    scope: {
      headline: "Scope",
      tip: "A named set of repositories, connections, and spend limits that controls what CodeRabbit Agent can access in a given Slack conversation.",
      cta: "Learn about Scopes",
      href: "/slack-agent/scopes",
      content: "Scope"
    },
    "coderabbit-agent": {
      headline: "CodeRabbit Agent for Slack",
      tip: "An AI agent built into Slack that investigates issues, generates implementation plans, and opens pull requests right from the Slack threads.",
      cta: "Explore CodeRabbit Agent",
      href: "/slack-agent",
      content: "CodeRabbit Agent"
    },
    "configuration-inheritance": {
      headline: "Configuration Inheritance",
      tip: "A setting that merges configuration values across multiple levels — repository YAML, central YAML, and UI settings — instead of using only the highest-priority source.",
      cta: "Learn about Configuration Inheritance",
      href: "/configuration/configuration-inheritance",
      content: "Configuration Inheritance"
    }
  };
  const defaults = TIPS[type] || ({});
  return <Tooltip headline={headline ?? defaults.headline} tip={tip ?? defaults.tip} cta={cta ?? defaults.cta} href={href ?? defaults.href}>
      {children ?? defaults.content}
    </Tooltip>;
};

export const OpenBetaBadge = ({tip = "This feature is currently in open beta. We are actively improving it based on your feedback. If you encounter any issues or have suggestions, please share them on our Discord community or visit the support page.", title = "Open Beta", cta = "Contact support", href = "/support", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="badge-alert" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

export const ProPlusPlanBadge = ({tip = "This feature is available as part of the Pro+ plan and Enterprise plan. Please refer to our pricing page for more information about our plans and features.", title = "Pro+ Plan", cta = "Read more", href = "https://coderabbit.ai/pricing", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="shield-plus" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

export const GitHubBadge = ({tip = "This feature is available on GitHub and GitHub Enterprise.", title = "GitHub", cta, href, disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="github" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

<GitHubBadge /> | <ProPlusPlanBadge /> <OpenBetaBadge />

Failing CI checks stall a pull request and often send you digging through job logs to find what broke. When CI fails on a PR, you can ask CodeRabbit to investigate the failing checks and fix them for you. It reads the failing checks and their output, works through the fix in a sandbox, and opens a stacked pull request by default. You can instead request a direct commit to the current branch.

## Platform support

Fix CI failures is available on GitHub only.

<CardGroup cols={2}>
  <Card title="GitHub" icon="github" horizontal>
    GitHub Cloud and GitHub Enterprise Server (self-hosted).
  </Card>
</CardGroup>

## Usage

On supported GitHub pull requests, CodeRabbit can show two **Fix failing CI** delivery options in the **✨ Finishing Touches** section of the <Hint type="walkthrough" /> comment when it detects failing CI checks:

* **Create stacked PR:** Open a pull request containing the generated fixes, targeting the current pull request branch.
* **Commit on current branch:** Commit the generated fixes directly to the pull request branch.

The options are mutually exclusive; selecting either one starts a single Fix CI run.

You can also trigger either delivery mode by commenting on a pull request that has failing CI checks:

<Tabs>
  <Tab title="Stacked pull request">
    ```text theme={null}
    @coderabbitai fix-ci
    ```
  </Tab>

  <Tab title="Direct commit">
    ```text theme={null}
    @coderabbitai fix-ci commit
    ```
  </Tab>
</Tabs>

Both delivery modes run the same investigation and generation flow. Only the destination for the generated fixes changes.

You can also ask CodeRabbit to fix CI in natural language. CodeRabbit opens a stacked pull request by default; if you explicitly ask it to commit directly, commit to the current branch, or avoid a stacked pull request, it uses the direct-commit path instead.

<Info>
  The checkbox options appear only when CodeRabbit detects failing CI checks during or shortly after review. If they are not present and the commands are available, use `@coderabbitai fix-ci` or `@coderabbitai fix-ci commit` manually. If neither trigger is available, see [Troubleshooting](#troubleshooting).
</Info>

## How it works

<Steps>
  <Step title="Trigger">
    Choose **Create stacked PR** or **Commit on current branch** in the Walkthrough comment. You can also comment `@coderabbitai fix-ci` for a stacked pull request or `@coderabbitai fix-ci commit` for a direct commit. CodeRabbit collects the checks reported as failing on the PR's head commit.
  </Step>

  <Step title="Investigate">
    CodeRabbit clones the repository into a sandbox and gathers context for the failing checks: the available failure output and the relevant CI configuration for the jobs that ran. This tells the agent what failed and how each job is invoked, rather than guessing from the check name alone.
  </Step>

  <Step title="Fix">
    A coding agent works directly in the repository, reading files and editing code to address the failures. It focuses on the code under test: infrastructure and configuration files (CI and build config, lock files, and other dependency manifests) are left out of the change and surfaced separately so you can apply them yourself if they are genuinely needed.
  </Step>

  <Step title="Deliver">
    CodeRabbit either opens a stacked pull request targeting the current branch or commits the fix directly to that branch, based on the selected checkbox or command. The status comment lists the failing checks it addressed and the files it changed.
  </Step>
</Steps>

Your project's real CI runs against the resulting commit or stacked pull request. That run is the source of truth for whether the failures are actually resolved.

## Re-running the fix

Re-running Fix CI behaves like a retry, and where the changes land depends on which pull request you trigger it from:

* **Stacked pull request:** Use `@coderabbitai fix-ci` or **Create stacked PR** on the original pull request to open a separate pull request for the current failures.
* **Direct commit:** Use `@coderabbitai fix-ci commit` or **Commit on current branch** to add the next fix to the current pull request branch.
* **Retry on a CodeRabbit-created stacked pull request:** CodeRabbit commits the next fix directly to that pull request instead of creating an endlessly growing stack.

## Scope and limitations

* **GitHub only.** Fix CI failures is not available on GitLab, Azure DevOps, or Bitbucket.
* **Delivery options depend on repository access.** Direct commit requires permission to write to the pull request branch. Stacked delivery requires permission to create a branch and pull request.
* **Target-branch CI filters can affect stacked pull requests.** If your CI only runs on pull requests targeting specific branches (for example `main`), it may not run on the stacked pull request itself. Merge the stacked pull request into your branch so CI validates on the original pull request.
* **Infrastructure and dependency files are not committed.** Changes the agent makes to CI/build config, lock files, or other dependency manifests are excluded from the delivered changes and listed in the status comment so you can apply them manually.
* **Workflow files are excluded.** CodeRabbit cannot commit changes under `.github/workflows/`. If a fix requires editing a workflow file, it is surfaced in the status comment for you to apply.

## Command reference

```text theme={null}
@coderabbitai fix-ci
@coderabbitai fix-ci commit
```

The stacked-pull-request command also accepts `@coderabbitai fix ci` and `@coderabbitai fixci`. Add `commit` to any of these commands to request a direct commit.

## Configuration

Fix CI failures is enabled by default for eligible repositories. To turn it off, set the following in your `.coderabbit.yaml`:

```yaml theme={null}
reviews:
  finishing_touches:
    fix_ci:
      enabled: false
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="The fix-ci command or checkbox isn't available" icon="circle-alert">
    Fix CI failures requires a Pro Plus plan and is available on GitHub only. Confirm the repository is on a Pro Plus plan and that the pull request is on GitHub. If it was turned off in configuration, set `reviews.finishing_touches.fix_ci.enabled` to `true`. The checkbox options appear only when CodeRabbit detects failing CI checks during review or shortly after the review finishes. If your CI fails later, the options may not appear; use `@coderabbitai fix-ci` or `@coderabbitai fix-ci commit` manually if the commands are available.
  </Accordion>

  <Accordion title="The agent only changed configuration files" icon="triangle-alert">
    Infrastructure, CI/build config, and dependency files are intentionally left out of direct commits and stacked pull requests. If the only changes the agent produced were out of scope, no fix commit or pull request is created; the status comment lists the files it touched so you can apply them manually.
  </Accordion>

  <Accordion title="The stacked PR's CI still fails" icon="git-pull-request-closed">
    The stacked pull request runs your real CI, which may surface remaining or new failures. Trigger Fix CI on the stacked pull request to have CodeRabbit commit another fix directly to it, or use `@coderabbitai fix-ci` on your original pull request to open a fresh stacked pull request. You can also choose one of the **Fix failing CI** delivery options when available or resolve the remaining failures manually.
  </Accordion>
</AccordionGroup>

## What's next

<CardGroup cols={1}>
  <Card title="Finishing Touches overview" href="/finishing-touches" icon="sparkles" horizontal>
    See all available finishing touches and how to trigger them from any PR
  </Card>

  <Card title="Autofix" href="/finishing-touches/autofix" icon="wrench" horizontal>
    Automatically implement fixes for unresolved CodeRabbit review findings
  </Card>

  <Card title="Resolve merge conflicts" href="/finishing-touches/resolve-merge-conflict" icon="git-merge" horizontal>
    Let CodeRabbit analyze the intent behind conflicting changes and commit a clean resolution to your branch
  </Card>
</CardGroup>
