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

# Simplify code

> Automatically review changed code for opportunities to simplify, improve reuse, quality, and efficiency, then apply targeted improvements.

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>;
};

<OpenBetaBadge />

<ProPlusPlanBadge />

Simplify reviews the files changed in your pull request and applies targeted code improvements: extracting reusable functions, simplifying conditionals, removing redundant code — while preserving existing behavior. Use it when you want a quick code-quality pass after writing a feature or fix.

## Platform support

<CardGroup cols={1}>
  <Card title="GitHub" icon="github" horizontal>
    Simplify is currently available on GitHub pull requests. You can trigger it
    by PR comment or from the Walkthrough checkboxes.
  </Card>
</CardGroup>

## Usage

Trigger Simplify using the **✨ Simplify code** checkbox in the CodeRabbit PR Walkthrough (GitHub), or with a PR comment (any platform):

```text theme={null}
@coderabbitai simplify
```

## How it works

<Steps>
  <Step title="Trigger Simplify">
    Comment `@coderabbitai simplify` in your PR or check **✨ Simplify code** in
    the CodeRabbit Walkthrough.
  </Step>

  <Step title="Analyze changed files">
    CodeRabbit clones your repository into a sandbox and diffs the PR branch
    against the base to identify all changed files.
  </Step>

  <Step title="Apply improvements">
    An AI agent reads each changed file, identifies simplification opportunities,
    and applies targeted edits: extracting reusable functions, simplifying
    conditionals, and removing redundant code without changing behavior.
  </Step>

  <Step title="Verify with tests">
    The agent runs your existing test suite to confirm no regressions were
    introduced by the changes.
  </Step>

  <Step title="Deliver the result">
    CodeRabbit either opens a new PR with the simplified code or commits the
    changes directly to your branch, depending on the option you select.
  </Step>
</Steps>

<Info>
  Simplify may take up to 20 minutes depending on the size of the pull request.
</Info>

## Output options

<Card title="Create a PR with simplified code" icon="git-pull-request-create-arrow" horizontal>
  CodeRabbit opens a new pull request against your branch with the simplified
  changes. Review and merge it like any other PR.
</Card>

<Card title="Commit simplified code to branch" icon="git-commit-vertical" horizontal>
  CodeRabbit commits the simplified code directly to your existing PR branch.
  Not available for fork PRs.
</Card>

## Scope and limitations

* Simplify is a **Pro+ plan** feature.
* The agent preserves existing behavior — it will not change public APIs, rename exported symbols, or alter test assertions.
* If your test suite fails after simplification, CodeRabbit still delivers the changes so you can review and iterate.

## What's next

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

  <Card title="Generate unit tests" icon="test-tube" href="/finishing-touches/unit-test-generation" horizontal>
    Generate comprehensive unit tests for your changed functions and methods
  </Card>

  <Card title="Generate docstrings" icon="book" href="/finishing-touches/docstrings" horizontal>
    Add documentation to functions that are missing it
  </Card>
</CardGroup>
