> ## 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="リリースが安定した後に、フィーチャーフラグとそのデッドコードを削除するための一度きりの Devin セッションをスケジュールします。" prompt="Next Friday at 9 AM, remove the feature flag 'enable_new_checkout' from our codebase. Delete the flag definition, keep the enabled code path, remove the disabled path, update tests, and open a PR." category="Automations" features="Schedules" type="schedule" />

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

  <Steps>
    <Step title="フラグをリリースしたときにクリーンアップを予約する">
      `enable_new_checkout` の裏側で新しいチェックアウトフローをデプロイしたところです。本番環境ではすでに有効になっていますが、古いコードを削除する前に 1 週間は監視したいと考えています。後で忘れてしまうチケットを作成する代わりに、今このタイミングで一度きりの Devin セッションをスケジュールしておきましょう — コンテキストを覚えているうちに行うのが最適です。

      [スケジュール作成ページ](https://app.devin.ai/settings/schedules/create?utm_source=docs\&utm_medium=use-case-gallery) を開き、タイプを **One-time** に設定します。監視期間が終わった後の日付 (例: 次の金曜日の午前 9 時) を選択します。セッションが実行されて PR が用意されたときにチームへ通知が届くよう、**Slack チャンネル** を選択します。次に、以下のプロンプトを貼り付けます:

      <PromptBlock type="schedule">
        ```txt Clean up feature flag after release theme={null}
        Remove the feature flag "enable_new_checkout" from the codebase:

        1. Delete the flag definition from src/config/featureFlags.ts
        2. Find every conditional that checks this flag (useFeatureFlag, isEnabled,
           if/else branches) and keep only the enabled path
        3. Delete the old checkout implementation that's now unreachable
        4. Remove or update any tests that mock this flag
        5. Run the test suite and open a PR with a summary of what was removed
        ```
      </PromptBlock>
    </Step>

    <Step title="プロンプトを十分に具体的にする">
      フィーチャーフラグは思わぬ場所に隠れていることがあります — 設定ファイル、テストフィクスチャ、コメント、環境変数などです。プロンプトにコンテキストを多く含めるほど、クリーンアップ結果の精度が上がります。次の内容を含めてください:

      * **フラグの仕組み** — どこで定義され、どのようにチェックされるか (例: React では `useFeatureFlag('name')`、バックエンドサービスでは `isEnabled('name')`)
      * **触ってほしくないもの** — フラグフレームワーク自体と、個別のフラグの違い (例: "`src/lib/featureFlags/` は変更しないでください — そこがフレームワークです")
      * **古いコードと新しいコードの場所** — 例: "古いチェックアウトは `src/pages/checkout/legacy/` にあり、新しいフローは `src/pages/checkout/v2/` にあります"
      * **クリーンアップの範囲** — フラグを参照しているコメント、ドキュメント、`.env` ファイル、CI 設定も合わせてクリーンアップするかどうか

      このレベルの詳細を含んだプロンプトであれば、Devin は参照箇所を 1 回のパスですべてたどれるため、後追いのスイープは不要になります。
    </Step>

    <Step title="PR が作成されたらレビューする">
      スケジュールされたセッションが実行されると、Devin はコードベース全体でフラグの利用箇所をすべてたどり、有効なコードパスを残し、無効なパスとデッドコードを削除し、テストをクリーンアップしてから PR を作成します。準備ができるとメール通知が届きます。

      典型的な PR は次のようになります:

      ```
      Removed feature flag: enable_new_checkout

      - Deleted flag from src/config/featureFlags.ts (1 file)
      - Removed 12 conditional branches across 7 files
      - Deleted src/pages/checkout/legacy/ (4 files, 380 lines)
      - Updated 3 test files — removed flag mocking, deleted old-path tests
      - All 1,204 tests passing
      ```

      マージする前に、古いパスから残しておくべきビジネスロジックがないか念のため確認してください — エラーハンドリング、分析イベント、エッジケース向けのフォールバックなどが"無効"ブランチの中に存在していることがあります。
    </Step>
  </Steps>
</div>
