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

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="Auto-Fix PR Bugs Before Merge" description="Devin reviews every PR for bugs and pushes fixes to the branch automatically." category="Code Quality" features="Integrations" type="review" />

<div className="uc-detail-wrapper">
  <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.</Tip>

  <Steps>
    <Step title="Enroll repos and users for auto-review">
      Devin Review can automatically review every PR on your repositories — no manual triggering needed. Start by enrolling the repos and users 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 **Repositories**, use **Add repo** to search for and add the repos you want Devin to auto-review (e.g., `acme/frontend`, `acme/api-server`)
      3. Under **Users**, view who's enrolled — each user enrolls themselves by setting their personal review trigger

      Once enrolled, Devin automatically reviews PRs when they're opened, when new commits are pushed, or when a draft is marked ready for review.

      <Tip>
        Any team member with a connected GitHub account can self-enroll for auto-reviews — no admin permissions needed. Go to [Settings > Preferences](https://app.devin.ai/settings/preferences?utm_source=docs\&utm_medium=use-case-gallery) and set your **Review trigger** under **Devin Review**.
      </Tip>
    </Step>

    <Step title="Enable Auto-Fix so Devin pushes fixes, not just comments">
      By default, [Devin Review](/work-with-devin/devin-review) posts bug findings as inline comments. Auto-Fix goes further — Devin proposes code changes and can push fix commits directly to the PR branch.

      To enable it, go to **Settings > Customization > Pull requests > Responding to bots** and choose one of:

      * **Selected only** — add `devin-ai-integration[bot]` to the allowlist (recommended)
      * **All bots** — Devin acts on all bot comments, not just its own

      You can also enable Auto-Fix from the **Auto-fix** section of the review sidebar on any Devin-authored PR (organization admins only).

      <Warning>
        "All bots" can cause infinite loops if other bots also comment on Devin's changes. Use the **Selected only** mode and add only `devin-ai-integration[bot]` to stay safe.
      </Warning>
    </Step>

    <Step title="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](/work-with-devin/devin-review) — Devin has context from the entire repo, not just the diff.
    </Step>

    <Step title="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](/work-with-devin/devin-review) 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?"
    </Step>
  </Steps>
</div>
