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

# Autofix

> Let CodeRabbit implement fixes for unresolved review findings.

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"
    },
    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"
    }
  };
  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 ProPlanBadge = ({tip = "This feature is available as part of the Pro, Pro+ and Enterprise plans. 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-check" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

export const GitLabBadge = ({tip = "This feature is available on GitLab.", title = "GitLab", cta, href, disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="gitlab" 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 /> <GitLabBadge /> | <ProPlanBadge /> <OpenBetaBadge />

Autofix helps you resolve review feedback faster by applying code changes for unresolved CodeRabbit findings in your pull request. Use Autofix when you want CodeRabbit to implement fixes automatically, then review the resulting commit or stacked PR.

## Usage

You can trigger Autofix from a review comment on a GitHub pull request or GitLab <Tooltip tip="GitLab merge requests are referred to as pull requests throughout this documentation">merge request</Tooltip>. On supported GitHub pull-request flows, you can also use the `Finishing Touches` Autofix checkbox in CodeRabbit's PR <Hint type="walkthrough" />.

```text Open a separate stacked PR with fixes theme={null}
@coderabbitai autofix stacked pr
```

```text Apply fixes to your current PR branch theme={null}
@coderabbitai autofix
```

<Info>
  GitHub and GitLab both support the comment commands on this page. The interactive **Autofix** checkbox is currently available on supported GitHub pull-request flows only.
</Info>

### GitHub checkbox triggers

On supported GitHub PR flows, CodeRabbit renders an expanded **Autofix** section with interactive checkboxes in the pull request review comment (alongside actionable comments).

* **Push a commit to this branch:** Runs Autofix and commits fixes to the current PR branch.
* **Create a new PR with the fixes:** Runs Autofix and opens a stacked PR with the generated changes.

These checkbox actions map to the same Autofix execution paths as the PR comment commands.

## How it works

<Steps>
  <Step title="Trigger autofix">
    Comment `@coderabbitai autofix` or `@coderabbitai autofix stacked pr` in the pull request thread. On supported GitHub pull-request flows, you can also use the **Autofix** checkbox section in the pull request review comment.
  </Step>

  <Step title="Collect fix instructions">
    CodeRabbit scans unresolved review threads started by CodeRabbit and gathers fix instructions from the **Prompt for AI Agents** blocks.
  </Step>

  <Step title="Generate and verify fixes">
    The coding agent applies fixes, then runs a repository setup + build verification step. Even if verification fails, the generated changes are still delivered so you can continue iterating.
  </Step>

  <Step title="Deliver the result">
    CodeRabbit either pushes a commit to the current branch or opens a stacked PR, depending on which command or checkbox option you selected.
  </Step>
</Steps>

## Output options

<Card title="Commit to current branch" icon="git-commit-vertical" horizontal>
  Use `@coderabbitai autofix` to push a commit directly to your current branch. This is the fastest path when you want fixes in the same review.
</Card>

<Card title="Create stacked PR" icon="git-pull-request-create-arrow" horizontal>
  Use `@coderabbitai autofix stacked pr` to open a new branch off your working branch and submit a separate stacked pull request, which lets you review the generated changes independently.
</Card>

## Scope and limitations

* Autofix runs only on pull request events.
* Autofix only processes unresolved CodeRabbit review threads with valid fix instructions.
* When the pull request has merge conflicts, Autofix exits without making changes. [Resolve the conflicts](/finishing-touches/resolve-merge-conflict) against the base branch, then trigger Autofix again.
* If no valid unresolved instructions are found, Autofix skips execution and reports that no fixes were applied.
* Autofix may be rate-limited. If limits are exceeded, CodeRabbit responds with a wait time before retrying.

## Command reference

```text theme={null}
@coderabbitai autofix
@coderabbitai autofix stacked pr
```

Also supported aliases include `auto-fix` and `auto fix` forms, with or without `stacked pr`.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Autofix says no fixes were found" icon="circle-alert">
    Autofix only acts on unresolved CodeRabbit review comments that include structured fix instructions. Resolve state, missing instruction blocks, or non-CodeRabbit threads can lead to no-op runs.
  </Accordion>

  <Accordion title="Autofix completed but verification failed" icon="triangle-alert">
    Build/verification can fail after code edits. In this case, CodeRabbit still keeps and delivers the generated autofix changes so you can continue iteration.
  </Accordion>

  <Accordion title="Autofix says the review has merge conflicts" icon="git-merge">
    Autofix stops before cloning or generating changes when the platform reports that the pull request is not mergeable. Resolve the conflicts with the base branch, then run Autofix again.

    CodeRabbit will also suggest running `@coderabbitai resolve merge conflict` from the Autofix reply. See [Resolve merge conflicts](/finishing-touches/resolve-merge-conflict) for details.
  </Accordion>

  <Accordion title="Stacked PR creation failed" icon="git-pull-request-closed">
    Stacked PR creation may fail due to platform or API limitations. If this happens, use `@coderabbitai autofix` to apply the fixes as a direct commit to your current branch instead. Note that stacked follow-up pull requests are not supported on Azure DevOps.
  </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="Custom recipes" href="/finishing-touches/custom-finishing-touches" icon="scroll" horizontal>
    Define reusable, named recipes that encode your team's repeated tasks into one-click agentic actions
  </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>
