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

# マージ前にPR内のバグを自動修正

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="マージ前にPRのバグを自動修正" description="DevinはすべてのPRをレビューし、バグを検出して修正を自動的にブランチにプッシュします。" category="コード品質" features="連携" type="review" />

<div className="uc-detail-wrapper">
  <Tip>手動で設定したくない場合は、このページへのリンクを Devin セッションに貼り付けて、すべて設定するよう依頼してください。</Tip>

  <Steps>
    <Step title="自動レビュー用にリポジトリとユーザーを登録する">
      Devin Review は、リポジトリ上のすべての PR を自動でレビューできます。手動でトリガーする必要はありません。まず、自動レビューの対象としたいリポジトリとユーザーを登録します。

      1. Devin のウェブアプリで [Settings > Review](https://app.devin.ai/settings/review?utm_source=docs\&utm_medium=use-case-gallery) に移動します
      2. **Repositories** セクションで、**Add repo** を使って、Devin に自動レビューさせたいリポジトリ (例: `acme/frontend`, `acme/api-server`) を検索して追加します
      3. **Users** セクションで、登録済みのユーザーを確認します — 各ユーザーは個人のレビュー トリガーを設定して自分自身を登録します

      一度登録すると、PR が作成されたとき、新しいコミットがプッシュされたとき、またはドラフトがレビュー準備完了に変更されたときに、Devin が自動で PR をレビューします。

      <Tip>
        GitHub アカウントを接続しているチームメンバーであれば、管理者権限がなくても自分で自動レビューに登録できます。[Settings > Preferences](https://app.devin.ai/settings/preferences?utm_source=docs\&utm_medium=use-case-gallery) に移動し、**Devin Review** の **Review trigger** を設定します。
      </Tip>
    </Step>

    <Step title="自動修正 を有効にして、コメントだけでなく修正もプッシュする">
      デフォルトでは、[Devin Review](/ja/work-with-devin/devin-review) はバグの検出結果をインラインコメントとして投稿します。自動修正 を使うとさらに踏み込んだ対応が可能になり、Devin がコード変更を提案し、修正コミットを直接 PR ブランチにプッシュできます。

      有効にするには、**Settings > Customization > Pull requests > Responding to bots** に移動し、次のいずれかを選択します:

      * **Selected only** — 許可リストに `devin-ai-integration[bot]` を追加します (推奨)
      * **All bots** — Devin が自分自身のコメントだけでなく、すべてのボットコメントに反応します

      自動修正 は、Devin が作成した任意の PR のレビューサイドバーにある **Auto-fix** セクションから有効にすることもできます (組織管理者のみ)。

      <Warning>
        **All bots** を有効にすると、他のボットも Devin の変更にコメントする場合、無限ループが発生する可能性があります。安全のため、**Selected only** モードを使用し、`devin-ai-integration[bot]` のみを追加してください。
      </Warning>
    </Step>

    <Step title="Devin が検出・修正する内容を確認する">
      登録済みリポジトリで PR が作成されると、Devin Review が自動で実行され、次のような結果が生成されます:

      * 重大度 (Severe または Non-severe) と確信度のラベル付きで Analysis サイドバーに表示される **バグ検出結果**
      * 必ずしも誤りとは限らないものの、調査する価値があるパターンに対する **フラグ**
      * 自動修正 がオンの場合、Devin が解決可能な問題について PR ブランチに直接プッシュされる **修正コミット**

      たとえば、新しいユーザー設定ページを追加する PR に対して、Devin Review が次のように検出する場合があります:

      ```
      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';
      ```

      各検出結果は diff ビューで確認でき、バグを解決済みとしてマークしたり、組み込みの [codebase-aware chat](/ja/work-with-devin/devin-review) を使ってフォローアップの質問を行ったりできます。Devin は diff だけでなく、リポジトリ全体のコンテキストを把握しています。
    </Step>

    <Step title="Devin Review にチームの標準を教える">
      Devin Review は、リポジトリ内の `AGENTS.md` と `REVIEW.md` を読み取り、チームのコンベンションを学習します。これらのファイルを使って、レビューの方針、監視したい一般的なバグパターン、適用したいコーディング規約を定義します:

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

      このファイルをリポジトリにコミットすると、Devin Review はすべての PR でこれらのガイドラインに従います。チームが新しいパターンを発見したら、その都度更新してください。たとえば本番障害が発生した場合、その障害を検知できたであろうパターンを追加しておけば、今後のレビューで Devin が類似の問題にフラグを立てるようになります。

      また、任意の PR で [Review chat](/ja/work-with-devin/devin-review) を使い、差分全体に対して特定のパターンをチェックするよう Devin に依頼することもできます。たとえば、「この PR にエラーケースをハンドリングしていない API 呼び出しはありますか？」といった質問が可能です。
    </Step>
  </Steps>
</div>
