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

# 将生产环境热修复整理为 Playbook

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="从一次成功的故障响应会话中抽取精确步骤，让团队每次都能复现修复过程。" prompt="上周二的内存泄漏故障处置会话堪称教科书级——Devin 找到了连接池中的泄漏点，应用修复，在预发布环境验证后实现零停机部署：[session link]。从中提取一份可复用的热修复操作手册，让值班工程师在后续内存问题中都能按同样流程处理。" category="Devin 优化" features="高级, 操作手册" agent="advanced" intent="create" />

<div className="uc-detail-wrapper">
  <Tip>不想手动设置？把此页面的链接粘贴到 Devin 会话中，并让它为你完成全部设置。</Tip>

  <Steps>
    <Step title="识别值得沉淀为操作手册的故障会话">
      在解决一次生产故障后，你会得到一份 Devin 会话记录，里面完整记录了每一步诊断操作、执行的每条命令，以及在压力下做出的每个决策。这份记录就是为值班团队制作可复用操作手册的原材料，下次可以直接套用。

      不是每次故障会话都适合写成操作手册。重点关注 Devin 遵循了清晰、可重复方法论的会话——也就是你们团队经常遇到的那类故障：

      * **内存泄漏**——识别泄漏源头、应用修复、在发布后验证堆内存使用情况是否恢复正常
      * **连接池耗尽**——追踪根因、调优连接池参数、补充监控
      * **级联超时**——隔离故障上游、添加熔断器、验证恢复效果
    </Step>

    <Step title="创建操作手册">
      打开 [Devin 主页](https://app.devin.ai/?utm_source=docs\&utm_medium=use-case-gallery) 并启动一个新会话。描述你想要转化为操作手册的会话。

      粘贴故障会话链接，并描述操作手册应该覆盖的内容。要把**泛化范围**说清楚——操作手册应该适用于这一类故障，而不只是当前这个出问题的服务。

      <PromptBlock agent="advanced" intent="create">
        ```txt Create hotfix playbook from incident session theme={null}
        This session diagnosed and fixed a memory leak in our payments service
        caused by unclosed database connections:
        https://app.devin.ai/sessions/abc123

        Create a reusable hotfix playbook for memory-leak incidents that any
        on-call engineer can attach to a new session. It should:
        - Generalize the diagnostic steps (not payments-specific)
        - Include the heap profiling approach from the session
        - Capture how it validated the fix in staging before deploying
        - Keep the rollback procedure in case the fix makes things worse
        - Add a step for posting a summary to the #incidents Slack channel
        ```
      </PromptBlock>

      如果你有多次相同类型的已解决故障 (例如两次不同的内存泄漏会话) ，可以把它们都加进去。Devin 会识别跨会话的共性模式，生成更加健壮的[操作手册](/zh/product-guides/creating-playbooks)。
    </Step>

    <Step title="在下一次故障中验证效果">
      真正的检验标准，是这个操作手册能否在*不同*但同一类别的故障中奏效。当下一次内存问题出现时，新建一个 Devin 会话，附加这个操作手册，并指向受影响的服务。

      <PromptBlock>
        ```txt Diagnose memory leak in the notifications service theme={null}
        Use the attached hotfix playbook to investigate and fix a memory leak
        in the notifications service. OOM kills started at 03:12 UTC.
        The service is at src/services/notifications/.
        ```
      </PromptBlock>

      如果会话能够顺利解决故障，说明你的操作手册泛化得很好。如果遇到困难——比如泄漏模式不同，或者服务使用了不同的数据库驱动——就把这次会话重新交给 Devin，并让它改进这份操作手册。关于该工作流，可以参考[修复不稳定的数据库迁移操作手册](/zh/use-cases/gallery/improve-playbook-from-sessions)。
    </Step>
  </Steps>
</div>
