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

# バグレポートをエンドツーエンドでデバッグする

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="バグレポートをエンドツーエンドでデバッグする" description="Datadog のログとデータベースへのアクセス権を含むバグレポートを Devin に渡すだけで、根本原因の分析と修正を行う PR が返ってきます。" prompt="Datadog MCP を使って、直近 24 時間の本番環境で最も頻発しているエラーを特定してください。完全なスタックトレースと関連ログを取得し、読み取り専用のデータベースレプリカに対して関連データをクエリし、コードベース内で根本原因を特定して、修正と回帰テストを含む PR を作成してください。" category="インシデント対応" features="MCP" />

<div className="uc-detail-wrapper">
  <Tip>Datadog 連携の詳細なガイドについては、[こちら](/ja/enterprise/integrations/datadog)をご覧ください。</Tip>

  <Steps>
    <Step title="Datadog と連携する">
      Devin がバグに関連するエラーを検索できるようにするには、Datadog ログへのアクセスが必要です。まだ有効化していない場合は、Datadog MCP を有効にしてください:

      1. **Settings > Connections > MCP servers** に移動し、**Datadog** を探します
      2. **Enable** をクリックし、Datadog のサイト/リージョンを選択して、次の 2 つのヘッダーを設定します:
         * `DD-API-KEY` — [Datadog API keys ページ](https://app.datadoghq.com/organization-settings/api-keys)から取得
         * `DD-APPLICATION-KEY` — [Datadog application keys ページ](https://app.datadoghq.com/organization-settings/application-keys)から取得

      接続が完了すると、Devin はセッション内からログの検索、エラートレースの取得、デプロイとの問題の関連付けをすべて実行できます。完全なセットアップ手順については、[MCP Marketplace](/ja/integrations/overview) を参照してください。
    </Step>

    <Step title="Devin にデータベースの読み取り専用権限を付与する">
      データ関連のバグ (値の誤り、フィールドの欠落、クエリの不具合など) の場合、Devin がデータの状態を直接検証できると、効果が飛躍的に高まります。読み取り専用の接続文字列を [Secret](/ja/product-guides/secrets) として設定します:

      1. **Settings > Secrets** に移動し、新しいシークレットを追加します:
         * **Name**: `DATABASE_READ_REPLICA_URL`
         * **Value**: `postgresql://readonly_user:password@read-replica.internal:5432/production`
      2. 次のようなメモを追加します: *「本番環境のリードレプリカへの読み取り専用接続。SELECT クエリ専用で安全。」*

      または、**Settings > Connections > MCP サーバー** でデータベース MCP (PostgreSQL、MySQL など) を接続します。Devin はどちらの方法でもデータに対してクエリを実行できます。

      <Tip>常にリードレプリカ、または SELECT のみが許可されたユーザーを使用してください。Devin がバグを調査する際に書き込み権限が必要になることはありません。高コストなクエリがパフォーマンスに与える影響が気になる場合は、Devin の接続先を本番データベースとは分離された専用のリードレプリカ、または既存の分析用レプリカに設定してください。</Tip>
    </Step>

    <Step title="Devin にバグレポートを送信する">
      バグレポートをそのまま Devin セッションに貼り付けてください。発生し始めた時期、誰に影響しているか、何が問題か、どこで発生しているかなど、報告者が提供しているコンテキストをできるだけ多く含めます。体系的に調査したい場合は、[`!triage` テンプレートプレイブック](https://app.devin.ai/settings/playbooks/14fed18b89d44713a26e673cf258f548?utm_source=docs\&utm_medium=use-case-gallery) を使い、複製して自分のスタック向けに手順をカスタマイズしてください。

      <PromptBlock>
        ```txt Debug billing page bug theme={null}
        Bug report from support: Pro plan users are seeing "undefined" instead of
        their company name on the billing page. This started after last Friday's
        deploy (around 2026-02-13 18:00 UTC).

        Steps to investigate:
        1. Use Datadog to pull error logs for the billing service since Friday —
           look for null reference errors or API response changes
        2. Query the read replica to check whether Pro plan users actually have a
           company_name value: SELECT id, company_name, plan FROM users WHERE plan = 'pro' LIMIT 20
        3. Check git log for Friday's deploy — what changed in the billing page
           or user API response?
        4. Identify the root cause and fix it
        5. Add a regression test that would catch this if it happened again
        6. Run the app locally and verify the billing page renders correctly
           using your browser
        7. Open a PR with the fix
        ```
      </PromptBlock>

      レポートが具体的であればあるほど、Devin はより早く答えを見つけられます。「金曜日のデプロイ以降」と書くことで、Devin は Datadog の時間範囲を絞り込めます。「Pro plan users」と指定することで、どのレコードをクエリすべきかを正確に指示できます。
    </Step>

    <Step title="Devin が調査し、修正します">
      Datadog とデータベースへの接続が完了すると、Devin は一連の詳細な調査を実行します:

      **Datadog のログを取得** — 金曜日以降の課金サービスのエラーを、サービス名とエラーステータスでフィルタリングして検索します。デプロイ当日の 18:12 UTC 以降に、`TypeError: Cannot read property 'name' of undefined` の発生が急増していることを突き止めます。

      **データベースをクエリ** — リードレプリカに対して `SELECT id, company_name, plan FROM users WHERE plan = 'pro' LIMIT 20` を実行します。Pro ユーザーには `company_name` の値が *存在する* ことを確認します。データ自体は正常なので、バグはコード側にあります。

      **コード変更をトレース** — `git log --since="2026-02-13"` を確認し、ユーザー API レスポンスをリファクタリングして `company` を `organization` にリネームしたコミット `a1b2c3d` を特定します。`src/pages/billing/BillingHeader.tsx` の課金ページは依然として `user.company.name` を参照しています。

      **修正を実装** — `BillingHeader.tsx` を更新して `user.organization?.name ?? 'Your Company'` を使用するようにし、古い API レスポンス形式と新しい形式の両方でコンポーネントをレンダーするリグレッションテストを追加します。

      **ブラウザで検証** — dev サーバーを起動し、Devin の組み込みブラウザで課金ページを開き、テストユーザーで会社名が正しく表示されることを確認します。

      **PR を作成** — 修正内容とテスト、そして根本原因と影響範囲 (すべての Pro と Enterprise ユーザー、約 350 アカウント) を説明する記述を含む PR を作成します。
    </Step>

    <Step title="フォローアップ">
      修正用の PR がマージされたら、Devin に関連する問題を洗い出したり、モニタリングを追加したりするよう依頼できます。

      <PromptBlock>
        ```txt Find other references to the old field theme={null}
        The root cause was user.company being renamed to user.organization in the
        API response. Search the entire frontend for other references to
        "user.company" and update them all.
        ```
      </PromptBlock>

      今回の調査でわかったことのうち、次回以降も Devin に覚えておいてほしいことがあれば、そのまま伝えてください。例：*"Remember that the user API uses `user.organization`, not `user.company`."*
      Devin は、あなたが確認して保存できる [Knowledge](/ja/product-guides/knowledge) エントリを提案します。こうしておくことで、今後のセッションは、あなたのチームがすでに学んだコンテキストを最初から持った状態で始められます。
    </Step>
  </Steps>
</div>
