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

# Auto-Fix PR Bugs Before Merge

> Set up Devin Review to auto-review every pull request, flag bugs by severity, and push Auto-Fix commits to the PR branch before merge.

# Auto-Fix PR Bugs Before Merge

Devin reviews every PR for bugs and pushes fixes to the branch automatically.

[Set Up Devin Review ↗](https://app.devin.ai/review?utm_source=docs\&utm_medium=use-case-gallery\&utm_campaign=hero-cta)

Author
Cognition

Category
Code Quality

> [!TIP]
>
> Don't want to set this up manually? Paste a link to this page into a Devin session and ask it to set everything up for you.

**1. Add an automatic review rule**

Devin Review can automatically review every PR on your repositories — no manual triggering needed. Start by adding a rule for the repositories you want covered.

1. Go to [Settings > Review](https://app.devin.ai/settings/review?utm_source=docs\&utm_medium=use-case-gallery) in the Devin webapp
2. Under **Automatic review**, add a rule and choose the repository or organization you want Devin to auto-review (e.g., `acme/frontend`, `acme/api-server`). You can narrow the rule with conditions such as author, label, or changed files
3. Choose when the rule starts (**PR is created** or **PR is ready**) and its cadence (**Only once** or **Every push**), then save

Once a rule matches, Devin automatically reviews PRs when they're opened or marked ready for review and, with the **Every push** cadence, when new commits are pushed. See [Auto-Review](https://docs.devin.ai/work-with-devin/devin-review.md#auto-review) for the full list of rule conditions.

> [!TIP]
>
> Team members can self-enroll for auto-reviews without an admin. Go to [Settings > Preferences](https://app.devin.ai/settings/preferences?utm_source=docs\&utm_medium=use-case-gallery) and, in the **Devin Review** section, set **Review trigger** to **Auto review PRs created** or **Auto review PRs ready for review**, then set **Review cadence** to **Every push** so Devin reviews on every subsequent push, or **Only once** for a single review.
>
> The **Review trigger** dropdown is locked until you connect a Git account, and it only lists the trigger modes your role has permission to use.

**2. Enable Auto-Fix so Devin pushes fixes, not just comments**

[Devin Review](https://docs.devin.ai/work-with-devin/devin-review.md) posts bug findings as inline comments. On PRs from Devin sessions, Auto-Fix goes further — Devin proposes code changes and can push fix commits directly to the PR branch.

Auto-Fix follows the **Automatically fix Devin Review findings** setting:

* **For the account** — Account Review managers turn it on or off in [**Settings > Review**](https://app.devin.ai/settings/review?utm_source=docs\&utm_medium=use-case-gallery) under **Git provider interaction**. As the row says, "This option configures the default for all users."
* **For yourself** — Turn it on or off for PRs from your own sessions in [**Settings > Preferences**](https://app.devin.ai/settings/preferences?utm_source=docs\&utm_medium=use-case-gallery) under **Devin sessions**. A choice that differs from the account default shows a **Reset to account default** pill; click it to follow the account again. Your own choice wins over the account default.

If it is off for you, you can also turn it on for yourself with **Enable auto-fix** in the **Auto-fix** section of the review sidebar on any Devin-authored PR.

**Responding to bots** in Settings > Devin still governs comments from other bots; it no longer controls Auto-Fix.

**3. See what Devin catches and fixes**

When a PR is opened on an enrolled repo, Devin Review runs automatically and produces:

* **Bug findings** in the Analysis sidebar, labeled by severity (Severe or Non-severe) and confidence
* **Flags** for patterns worth investigating but not necessarily wrong
* **Fix commits** pushed directly to the PR branch for issues Devin can resolve (when Auto-Fix is on)

For example, on a PR that adds a new user settings page, Devin Review might find:

```
Bug (Severe): Null reference in UserSettings.tsx:38

`user.preferences.theme` throws if `preferences` is undefined,
which happens for accounts created before v2.3.

Fix pushed — commit e4a1b2c:
  const theme = user.preferences?.theme ?? 'system';
```

You can review each finding in the diff view, mark bugs as resolved, or ask follow-up questions using the built-in [codebase-aware chat](https://docs.devin.ai/work-with-devin/devin-review.md) — Devin has context from the entire repo, not just the diff.

**4. Teach Devin Review your team's standards**

Devin Review reads `AGENTS.md` and `REVIEW.md` files in your repository to learn your team's conventions. Use these files to define review preferences, common bug patterns to watch for, and coding standards you want enforced:

```markdown theme={null}
<!-- REVIEW.md -->
## Review guidelines

- All API route handlers in src/routes/* must validate request body
  with zod schemas before accessing properties. Flag any handler
  that reads req.body fields without validation.
- The useUnsafeEffect hook in src/hooks/useUnsafeEffect.ts is
  intentional — do not flag it as a missing-deps issue.
- Check for unhandled error cases in API calls.
- Ensure new database queries have appropriate indexes.
```

Commit this file to your repo and Devin Review will follow these guidelines on every PR. Update it as your team discovers new patterns — for example, after a production bug, add the pattern that would have caught it so Devin flags similar issues in future reviews.

You can also use the [Review chat](https://docs.devin.ai/work-with-devin/devin-review.md) on any PR to ask Devin to check for specific patterns across the diff — for instance, "Are there any API calls in this PR that don't handle the error case?"


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