[{"data":1,"prerenderedAt":3239},["ShallowReactive",2],{"article-/topics/ai/ai-agent-workflow-dead-letter-queue-recovery":3,"related-ai":276,"content-query-iMd4LSFjj6":3046},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"topic":5,"author":11,"tags":12,"image":17,"imageQuery":18,"pexelsPhotoId":19,"pexelsUrl":20,"featured":6,"readingTime":21,"body":22,"_type":270,"_id":271,"_source":272,"_file":273,"_stem":274,"_extension":275},"/topics/ai/ai-agent-workflow-dead-letter-queue-recovery","ai",false,"","AI agent Workflow Dead Letter Queue：失败任务如何隔离、修复与回放","DLQ 不是失败墓地，而是恢复入口。本文讲清 agent workflow 的 dead letter queue 设计、分诊规则和恢复流程。","2026-05-30","HTMLPAGE 团队",[13,14,15,16],"AI agent","Dead Letter Queue","Recovery","Workflow Operations","/images/articles/ai-agent-workflow-dead-letter-queue-recovery-featured.jpg","operations incident response queue management",32652792,"https://www.pexels.com/photo/aerial-view-of-emergency-vehicles-in-urban-crisis-32652792/",13,{"type":23,"children":24,"toc":262},"root",[25,33,40,60,65,70,150,155,161,166,172,226,231],{"type":26,"tag":27,"props":28,"children":29},"element","p",{},[30],{"type":31,"value":32},"text","没有 DLQ 的 workflow，失败任务会污染主队列；只有 DLQ 但没有分诊规则，失败任务会永久堆积。真正可运营的系统需要“隔离 + 分诊 + 恢复”闭环。",{"type":26,"tag":34,"props":35,"children":37},"h2",{"id":36},"dlq-设计目标",[38],{"type":31,"value":39},"DLQ 设计目标",{"type":26,"tag":41,"props":42,"children":43},"ul",{},[44,50,55],{"type":26,"tag":45,"props":46,"children":47},"li",{},[48],{"type":31,"value":49},"隔离不可自动恢复任务",{"type":26,"tag":45,"props":51,"children":52},{},[53],{"type":31,"value":54},"保留足够证据支持复盘",{"type":26,"tag":45,"props":56,"children":57},{},[58],{"type":31,"value":59},"提供受控回放入口",{"type":26,"tag":27,"props":61,"children":62},{},[63],{"type":31,"value":64},"DLQ 的核心不是存储，而是恢复治理。",{"type":26,"tag":34,"props":66,"children":68},{"id":67},"分诊分层",[69],{"type":31,"value":67},{"type":26,"tag":71,"props":72,"children":73},"table",{},[74,93],{"type":26,"tag":75,"props":76,"children":77},"thead",{},[78],{"type":26,"tag":79,"props":80,"children":81},"tr",{},[82,88],{"type":26,"tag":83,"props":84,"children":85},"th",{},[86],{"type":31,"value":87},"类别",{"type":26,"tag":83,"props":89,"children":90},{},[91],{"type":31,"value":92},"处理方式",{"type":26,"tag":94,"props":95,"children":96},"tbody",{},[97,111,124,137],{"type":26,"tag":79,"props":98,"children":99},{},[100,106],{"type":26,"tag":101,"props":102,"children":103},"td",{},[104],{"type":31,"value":105},"数据问题",{"type":26,"tag":101,"props":107,"children":108},{},[109],{"type":31,"value":110},"补充字段后重放",{"type":26,"tag":79,"props":112,"children":113},{},[114,119],{"type":26,"tag":101,"props":115,"children":116},{},[117],{"type":31,"value":118},"依赖问题",{"type":26,"tag":101,"props":120,"children":121},{},[122],{"type":31,"value":123},"等待外部恢复再重试",{"type":26,"tag":79,"props":125,"children":126},{},[127,132],{"type":26,"tag":101,"props":128,"children":129},{},[130],{"type":31,"value":131},"策略问题",{"type":26,"tag":101,"props":133,"children":134},{},[135],{"type":31,"value":136},"规则修正后批量回放",{"type":26,"tag":79,"props":138,"children":139},{},[140,145],{"type":26,"tag":101,"props":141,"children":142},{},[143],{"type":31,"value":144},"代码缺陷",{"type":26,"tag":101,"props":146,"children":147},{},[148],{"type":31,"value":149},"修复版本后灰度回放",{"type":26,"tag":27,"props":151,"children":152},{},[153],{"type":31,"value":154},"把不同问题混在同一重试策略里，通常会造成二次故障。",{"type":26,"tag":34,"props":156,"children":158},{"id":157},"失败案例dlq-批量重放触发风暴",[159],{"type":31,"value":160},"失败案例：DLQ 批量重放触发风暴",{"type":26,"tag":27,"props":162,"children":163},{},[164],{"type":31,"value":165},"某团队在外部依赖尚未恢复时批量回放 DLQ，导致同类失败再次挤爆队列。修复后引入“回放前置条件”和并发闸门，恢复过程稳定许多。",{"type":26,"tag":34,"props":167,"children":169},{"id":168},"checklist",[170],{"type":31,"value":171},"Checklist",{"type":26,"tag":41,"props":173,"children":176},{"className":174},[175],"contains-task-list",[177,190,199,208,217],{"type":26,"tag":45,"props":178,"children":181},{"className":179},[180],"task-list-item",[182,188],{"type":26,"tag":183,"props":184,"children":187},"input",{"disabled":185,"type":186},true,"checkbox",[],{"type":31,"value":189}," DLQ 入队原因结构化",{"type":26,"tag":45,"props":191,"children":193},{"className":192},[180],[194,197],{"type":26,"tag":183,"props":195,"children":196},{"disabled":185,"type":186},[],{"type":31,"value":198}," 每类失败有分诊 owner",{"type":26,"tag":45,"props":200,"children":202},{"className":201},[180],[203,206],{"type":26,"tag":183,"props":204,"children":205},{"disabled":185,"type":186},[],{"type":31,"value":207}," 回放前必须校验前置条件",{"type":26,"tag":45,"props":209,"children":211},{"className":210},[180],[212,215],{"type":26,"tag":183,"props":213,"children":214},{"disabled":185,"type":186},[],{"type":31,"value":216}," 批量回放支持并发限流",{"type":26,"tag":45,"props":218,"children":220},{"className":219},[180],[221,224],{"type":26,"tag":183,"props":222,"children":223},{"disabled":185,"type":186},[],{"type":31,"value":225}," DLQ 老化任务有升级机制",{"type":26,"tag":27,"props":227,"children":228},{},[229],{"type":31,"value":230},"延伸阅读：",{"type":26,"tag":41,"props":232,"children":233},{},[234,244,253],{"type":26,"tag":45,"props":235,"children":236},{},[237],{"type":26,"tag":238,"props":239,"children":241},"a",{"href":240},"/topics/ai/ai-agent-review-queue-aging-escalation",[242],{"type":31,"value":243},"AI agent Review Queue Aging 与升级",{"type":26,"tag":45,"props":245,"children":246},{},[247],{"type":26,"tag":238,"props":248,"children":250},{"href":249},"/topics/ai/ai-agent-incident-response-runbook",[251],{"type":31,"value":252},"AI agent Incident Response Runbook",{"type":26,"tag":45,"props":254,"children":255},{},[256],{"type":26,"tag":238,"props":257,"children":259},{"href":258},"/topics/ai/ai-agent-harness-crash-recovery-wake-flow",[260],{"type":31,"value":261},"AI agent Harness Crash Recovery",{"title":7,"searchDepth":263,"depth":263,"links":264},3,[265,267,268,269],{"id":36,"depth":266,"text":39},2,{"id":67,"depth":266,"text":67},{"id":157,"depth":266,"text":160},{"id":168,"depth":266,"text":171},"markdown","content:topics:ai:ai-agent-workflow-dead-letter-queue-recovery.md","content","topics/ai/ai-agent-workflow-dead-letter-queue-recovery.md","topics/ai/ai-agent-workflow-dead-letter-queue-recovery","md",[277,1433,2383],{"_path":278,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":279,"description":280,"date":281,"topic":5,"author":11,"tags":282,"image":288,"imageAlt":289,"pexelsPhotoId":290,"pexelsUrl":291,"readingTime":292,"body":293,"_type":270,"_id":1430,"_source":272,"_file":1431,"_stem":1432,"_extension":275},"/topics/ai/cursor-keyboard-shortcuts-cheatsheet","Cursor 快捷键速查表（macOS/Windows）：从“会用”到“能提效”的 10 个工作流","把 Cursor 常用快捷键按任务分组（查代码、改代码、多文件、对话、审查与回滚），给出可直接照抄的工作流与最小回归清单，避免“快捷键背了也没变快”。","2026-03-02",[283,284,285,286,287],"Cursor","快捷键","AI IDE","VS Code","开发效率","/images/topics/ai/cursor-keyboard-shortcuts-cheatsheet.jpg","彩色机械键盘与鼠标的工作台面",34563105,"https://www.pexels.com/photo/colorful-mechanical-keyboard-and-mouse-setup-34563105/",12,{"type":23,"children":294,"toc":1404},[295,300,318,323,352,357,393,397,403,408,441,446,469,472,478,483,702,711,714,720,727,746,754,775,780,786,801,832,837,850,856,875,893,901,906,912,917,938,946,952,957,980,985,991,1004,1010,1028,1046,1052,1063,1081,1087,1098,1104,1109,1152,1155,1161,1169,1222,1225,1231,1237,1242,1247,1270,1288,1293,1318,1321,1327,1333,1338,1344,1349,1355,1360,1363,1369],{"type":26,"tag":27,"props":296,"children":297},{},[298],{"type":31,"value":299},"如果你在搜“Cursor 快捷键”，你大概率不是想背一张表，而是想解决这类问题：",{"type":26,"tag":41,"props":301,"children":302},{},[303,308,313],{"type":26,"tag":45,"props":304,"children":305},{},[306],{"type":31,"value":307},"为什么我用了 AI，还是很慢？（对话来回太多、改动不可控）",{"type":26,"tag":45,"props":309,"children":310},{},[311],{"type":31,"value":312},"为什么它“看起来懂了”，却改错文件/改出回归？（上下文与范围没锁住）",{"type":26,"tag":45,"props":314,"children":315},{},[316],{"type":31,"value":317},"多文件改动怎么做得安全？（验收、回滚、最小回归集）",{"type":26,"tag":27,"props":319,"children":320},{},[321],{"type":31,"value":322},"这篇文章给你两份东西：",{"type":26,"tag":324,"props":325,"children":326},"ol",{},[327,340],{"type":26,"tag":45,"props":328,"children":329},{},[330,332,338],{"type":31,"value":331},"一张",{"type":26,"tag":333,"props":334,"children":335},"strong",{},[336],{"type":31,"value":337},"按任务分组",{"type":31,"value":339},"的快捷键表（不是按功能堆在一起）",{"type":26,"tag":45,"props":341,"children":342},{},[343,345,350],{"type":31,"value":344},"一套“从需求到落地”的",{"type":26,"tag":333,"props":346,"children":347},{},[348],{"type":31,"value":349},"最小闭环工作流",{"type":31,"value":351},"（每一步都有快捷键）",{"type":26,"tag":27,"props":353,"children":354},{},[355],{"type":31,"value":356},"想看系统玩法：",{"type":26,"tag":41,"props":358,"children":359},{},[360,371,382],{"type":26,"tag":45,"props":361,"children":362},{},[363,365],{"type":31,"value":364},"入门教程看：",{"type":26,"tag":238,"props":366,"children":368},{"href":367},"/topics/ai/cursor-tutorial",[369],{"type":31,"value":370},"Cursor 使用教程（2026）",{"type":26,"tag":45,"props":372,"children":373},{},[374,376],{"type":31,"value":375},"进阶玩法看：",{"type":26,"tag":238,"props":377,"children":379},{"href":378},"/topics/ai/cursor-editor-guide",[380],{"type":31,"value":381},"Cursor 编辑器深度玩法",{"type":26,"tag":45,"props":383,"children":384},{},[385,387],{"type":31,"value":386},"规则与忽略看：",{"type":26,"tag":238,"props":388,"children":390},{"href":389},"/topics/ai/cursor-rules-cursorrules",[391],{"type":31,"value":392},"Cursor Rules 与 .cursorrules",{"type":26,"tag":394,"props":395,"children":396},"hr",{},[],{"type":26,"tag":34,"props":398,"children":400},{"id":399},"先给结论提效不是按得快而是闭环更短",[401],{"type":31,"value":402},"先给结论：提效不是“按得快”，而是“闭环更短”",{"type":26,"tag":27,"props":404,"children":405},{},[406],{"type":31,"value":407},"你可以把 Cursor 的快捷键理解为 3 条流水线：",{"type":26,"tag":41,"props":409,"children":410},{},[411,421,431],{"type":26,"tag":45,"props":412,"children":413},{},[414,419],{"type":26,"tag":333,"props":415,"children":416},{},[417],{"type":31,"value":418},"改一小段",{"type":31,"value":420},"（内联编辑）：把改动限制在一个函数/一段样式",{"type":26,"tag":45,"props":422,"children":423},{},[424,429],{"type":26,"tag":333,"props":425,"children":426},{},[427],{"type":31,"value":428},"改一组文件",{"type":31,"value":430},"（Composer）：把改动限制在一组明确文件，并要求输出 diff + 验收点",{"type":26,"tag":45,"props":432,"children":433},{},[434,439],{"type":26,"tag":333,"props":435,"children":436},{},[437],{"type":31,"value":438},"聊清楚再动手",{"type":31,"value":440},"（侧边对话）：先对齐目标、范围、验收、回滚",{"type":26,"tag":27,"props":442,"children":443},{},[444],{"type":31,"value":445},"当你觉得“它乱改/改太大”时，往往不是快捷键没记住，而是缺了两件事：",{"type":26,"tag":41,"props":447,"children":448},{},[449,459],{"type":26,"tag":45,"props":450,"children":451},{},[452,454],{"type":31,"value":453},"没有在动手前锁定",{"type":26,"tag":333,"props":455,"children":456},{},[457],{"type":31,"value":458},"范围",{"type":26,"tag":45,"props":460,"children":461},{},[462,464],{"type":31,"value":463},"没有在接受改动前准备",{"type":26,"tag":333,"props":465,"children":466},{},[467],{"type":31,"value":468},"验收/回滚",{"type":26,"tag":394,"props":470,"children":471},{},[],{"type":26,"tag":34,"props":473,"children":475},{"id":474},"快捷键速查表按任务分组",[476],{"type":31,"value":477},"快捷键速查表（按任务分组）",{"type":26,"tag":27,"props":479,"children":480},{},[481],{"type":31,"value":482},"说明：下表按“你正在做什么”组织，而不是按“功能名字”组织。不同版本快捷键可能略有差异，但核心逻辑一致。",{"type":26,"tag":71,"props":484,"children":485},{},[486,512],{"type":26,"tag":75,"props":487,"children":488},{},[489],{"type":26,"tag":79,"props":490,"children":491},{},[492,497,502,507],{"type":26,"tag":83,"props":493,"children":494},{},[495],{"type":31,"value":496},"任务",{"type":26,"tag":83,"props":498,"children":499},{},[500],{"type":31,"value":501},"macOS",{"type":26,"tag":83,"props":503,"children":504},{},[505],{"type":31,"value":506},"Windows",{"type":26,"tag":83,"props":508,"children":509},{},[510],{"type":31,"value":511},"你该在什么时候用",{"type":26,"tag":94,"props":513,"children":514},{},[515,547,578,609,640,671],{"type":26,"tag":79,"props":516,"children":517},{},[518,523,533,542],{"type":26,"tag":101,"props":519,"children":520},{},[521],{"type":31,"value":522},"改一小段（最安全）",{"type":26,"tag":101,"props":524,"children":525},{},[526],{"type":26,"tag":527,"props":528,"children":530},"code",{"className":529},[],[531],{"type":31,"value":532},"Cmd + K",{"type":26,"tag":101,"props":534,"children":535},{},[536],{"type":26,"tag":527,"props":537,"children":539},{"className":538},[],[540],{"type":31,"value":541},"Ctrl + K",{"type":26,"tag":101,"props":543,"children":544},{},[545],{"type":31,"value":546},"只想改一个函数/一段 CSS，不想动别的",{"type":26,"tag":79,"props":548,"children":549},{},[550,555,564,573],{"type":26,"tag":101,"props":551,"children":552},{},[553],{"type":31,"value":554},"打开 AI 对话（先对齐再动手）",{"type":26,"tag":101,"props":556,"children":557},{},[558],{"type":26,"tag":527,"props":559,"children":561},{"className":560},[],[562],{"type":31,"value":563},"Cmd + L",{"type":26,"tag":101,"props":565,"children":566},{},[567],{"type":26,"tag":527,"props":568,"children":570},{"className":569},[],[571],{"type":31,"value":572},"Ctrl + L",{"type":26,"tag":101,"props":574,"children":575},{},[576],{"type":31,"value":577},"需要澄清目标、制定步骤、给验收点",{"type":26,"tag":79,"props":579,"children":580},{},[581,586,595,604],{"type":26,"tag":101,"props":582,"children":583},{},[584],{"type":31,"value":585},"多文件编辑（有组织地改一组文件）",{"type":26,"tag":101,"props":587,"children":588},{},[589],{"type":26,"tag":527,"props":590,"children":592},{"className":591},[],[593],{"type":31,"value":594},"Cmd + I",{"type":26,"tag":101,"props":596,"children":597},{},[598],{"type":26,"tag":527,"props":599,"children":601},{"className":600},[],[602],{"type":31,"value":603},"Ctrl + I",{"type":26,"tag":101,"props":605,"children":606},{},[607],{"type":31,"value":608},"改动涉及多个文件：组件+样式+测试",{"type":26,"tag":79,"props":610,"children":611},{},[612,617,626,635],{"type":26,"tag":101,"props":613,"children":614},{},[615],{"type":31,"value":616},"把选中代码加入对话上下文",{"type":26,"tag":101,"props":618,"children":619},{},[620],{"type":26,"tag":527,"props":621,"children":623},{"className":622},[],[624],{"type":31,"value":625},"Cmd + Shift + L",{"type":26,"tag":101,"props":627,"children":628},{},[629],{"type":26,"tag":527,"props":630,"children":632},{"className":631},[],[633],{"type":31,"value":634},"Ctrl + Shift + L",{"type":26,"tag":101,"props":636,"children":637},{},[638],{"type":31,"value":639},"让 AI 只看你选的片段（降低噪音）",{"type":26,"tag":79,"props":641,"children":642},{},[643,648,657,666],{"type":26,"tag":101,"props":644,"children":645},{},[646],{"type":31,"value":647},"接受当前建议",{"type":26,"tag":101,"props":649,"children":650},{},[651],{"type":26,"tag":527,"props":652,"children":654},{"className":653},[],[655],{"type":31,"value":656},"Cmd + Y",{"type":26,"tag":101,"props":658,"children":659},{},[660],{"type":26,"tag":527,"props":661,"children":663},{"className":662},[],[664],{"type":31,"value":665},"Ctrl + Y",{"type":26,"tag":101,"props":667,"children":668},{},[669],{"type":31,"value":670},"你已经准备好验收/回滚，并确认改动范围",{"type":26,"tag":79,"props":672,"children":673},{},[674,679,688,697],{"type":26,"tag":101,"props":675,"children":676},{},[677],{"type":31,"value":678},"拒绝当前建议",{"type":26,"tag":101,"props":680,"children":681},{},[682],{"type":26,"tag":527,"props":683,"children":685},{"className":684},[],[686],{"type":31,"value":687},"Cmd + N",{"type":26,"tag":101,"props":689,"children":690},{},[691],{"type":26,"tag":527,"props":692,"children":694},{"className":693},[],[695],{"type":31,"value":696},"Ctrl + N",{"type":26,"tag":101,"props":698,"children":699},{},[700],{"type":31,"value":701},"改得太大、改错方向，立刻收手",{"type":26,"tag":703,"props":704,"children":705},"blockquote",{},[706],{"type":26,"tag":27,"props":707,"children":708},{},[709],{"type":31,"value":710},"小技巧：把“改一小段”当默认路径。只有当你能清晰写出“会改哪几类文件、怎么验收”时再进入多文件。",{"type":26,"tag":394,"props":712,"children":713},{},[],{"type":26,"tag":34,"props":715,"children":717},{"id":716},"_10-个可直接照抄的提效工作流每个都能闭环",[718],{"type":31,"value":719},"10 个可直接照抄的提效工作流（每个都能闭环）",{"type":26,"tag":721,"props":722,"children":724},"h3",{"id":723},"工作流-1需求计划小步改新手最稳",[725],{"type":31,"value":726},"工作流 1：需求→计划→小步改（新手最稳）",{"type":26,"tag":324,"props":728,"children":729},{},[730,741],{"type":26,"tag":45,"props":731,"children":732},{},[733,739],{"type":26,"tag":527,"props":734,"children":736},{"className":735},[],[737],{"type":31,"value":738},"Cmd/Ctrl + L",{"type":31,"value":740}," 打开对话",{"type":26,"tag":45,"props":742,"children":743},{},[744],{"type":31,"value":745},"先发这段（可复制）：",{"type":26,"tag":703,"props":747,"children":748},{},[749],{"type":26,"tag":27,"props":750,"children":751},{},[752],{"type":31,"value":753},"目标：……\n范围：只修改以下文件/模块：……\n非目标：……（明确不做）\n验收：……（可测试/可手动检查）\n输出格式：先给计划，再逐步执行；每一步写出 diff 摘要。",{"type":26,"tag":324,"props":755,"children":756},{"start":263},[757,762],{"type":26,"tag":45,"props":758,"children":759},{},[760],{"type":31,"value":761},"让 AI 先给“计划（3~6 步）”，你确认后再执行",{"type":26,"tag":45,"props":763,"children":764},{},[765,767,773],{"type":31,"value":766},"任何一步涉及改代码：优先回到编辑区，选中片段用 ",{"type":26,"tag":527,"props":768,"children":770},{"className":769},[],[771],{"type":31,"value":772},"Cmd/Ctrl + K",{"type":31,"value":774}," 小步改",{"type":26,"tag":27,"props":776,"children":777},{},[778],{"type":31,"value":779},"为什么有效：你把“想法”变成了“可执行约束”，这就是 GEO（面向 AI/模型的可理解结构）。",{"type":26,"tag":721,"props":781,"children":783},{"id":782},"工作流-2只改一个函数高频低风险",[784],{"type":31,"value":785},"工作流 2：只改一个函数（高频、低风险）",{"type":26,"tag":41,"props":787,"children":788},{},[789],{"type":26,"tag":45,"props":790,"children":791},{},[792,794,799],{"type":31,"value":793},"选中函数 → ",{"type":26,"tag":527,"props":795,"children":797},{"className":796},[],[798],{"type":31,"value":772},{"type":31,"value":800}," → 输入指令：",{"type":26,"tag":703,"props":802,"children":803},{},[804,809],{"type":26,"tag":27,"props":805,"children":806},{},[807],{"type":31,"value":808},"把这段改成更可读：",{"type":26,"tag":41,"props":810,"children":811},{},[812,817,822,827],{"type":26,"tag":45,"props":813,"children":814},{},[815],{"type":31,"value":816},"用 async/await",{"type":26,"tag":45,"props":818,"children":819},{},[820],{"type":31,"value":821},"错误处理不要吞掉",{"type":26,"tag":45,"props":823,"children":824},{},[825],{"type":31,"value":826},"添加类型（若可推断）",{"type":26,"tag":45,"props":828,"children":829},{},[830],{"type":31,"value":831},"不要改函数签名",{"type":26,"tag":27,"props":833,"children":834},{},[835],{"type":31,"value":836},"验收方式（强制）：",{"type":26,"tag":41,"props":838,"children":839},{},[840,845],{"type":26,"tag":45,"props":841,"children":842},{},[843],{"type":31,"value":844},"输出前后函数行为一致（输入/输出）",{"type":26,"tag":45,"props":846,"children":847},{},[848],{"type":31,"value":849},"失败分支有可观测日志（不要悄悄 return null）",{"type":26,"tag":721,"props":851,"children":853},{"id":852},"工作流-3多文件改动先定文件清单",[854],{"type":31,"value":855},"工作流 3：多文件改动（先定“文件清单”）",{"type":26,"tag":324,"props":857,"children":858},{},[859,870],{"type":26,"tag":45,"props":860,"children":861},{},[862,868],{"type":26,"tag":527,"props":863,"children":865},{"className":864},[],[866],{"type":31,"value":867},"Cmd/Ctrl + I",{"type":31,"value":869}," 进入多文件",{"type":26,"tag":45,"props":871,"children":872},{},[873],{"type":31,"value":874},"先让 AI 输出：",{"type":26,"tag":41,"props":876,"children":877},{},[878,883,888],{"type":26,"tag":45,"props":879,"children":880},{},[881],{"type":31,"value":882},"预计会改哪些文件（最多 5 个）",{"type":26,"tag":45,"props":884,"children":885},{},[886],{"type":31,"value":887},"每个文件改什么",{"type":26,"tag":45,"props":889,"children":890},{},[891],{"type":31,"value":892},"每一步怎么验收",{"type":26,"tag":324,"props":894,"children":895},{"start":263},[896],{"type":26,"tag":45,"props":897,"children":898},{},[899],{"type":31,"value":900},"你确认文件清单后再开始生成改动",{"type":26,"tag":27,"props":902,"children":903},{},[904],{"type":31,"value":905},"关键点：多文件最容易翻车的是“它把你没想到的文件也改了”。所以文件清单是第一道闸门。",{"type":26,"tag":721,"props":907,"children":909},{"id":908},"工作流-4把上下文噪音砍掉防跑偏",[910],{"type":31,"value":911},"工作流 4：把“上下文噪音”砍掉（防跑偏）",{"type":26,"tag":27,"props":913,"children":914},{},[915],{"type":31,"value":916},"当你怀疑它在胡说/乱改时：",{"type":26,"tag":41,"props":918,"children":919},{},[920,933],{"type":26,"tag":45,"props":921,"children":922},{},[923,925,931],{"type":31,"value":924},"只选择关键代码片段 → ",{"type":26,"tag":527,"props":926,"children":928},{"className":927},[],[929],{"type":31,"value":930},"Cmd/Ctrl + Shift + L",{"type":31,"value":932}," 加入对话",{"type":26,"tag":45,"props":934,"children":935},{},[936],{"type":31,"value":937},"然后在对话里要求：",{"type":26,"tag":703,"props":939,"children":940},{},[941],{"type":26,"tag":27,"props":942,"children":943},{},[944],{"type":31,"value":945},"只基于我提供的代码片段回答，不要假设其它文件存在。",{"type":26,"tag":721,"props":947,"children":949},{"id":948},"工作流-5生成变更说明让-code-review-变快",[950],{"type":31,"value":951},"工作流 5：生成变更说明（让 code review 变快）",{"type":26,"tag":27,"props":953,"children":954},{},[955],{"type":31,"value":956},"改完后在对话里让它输出：",{"type":26,"tag":41,"props":958,"children":959},{},[960,965,970,975],{"type":26,"tag":45,"props":961,"children":962},{},[963],{"type":31,"value":964},"改动摘要（3~7 条）",{"type":26,"tag":45,"props":966,"children":967},{},[968],{"type":31,"value":969},"风险点（依赖/边界条件）",{"type":26,"tag":45,"props":971,"children":972},{},[973],{"type":31,"value":974},"回滚方式",{"type":26,"tag":45,"props":976,"children":977},{},[978],{"type":31,"value":979},"验收步骤",{"type":26,"tag":27,"props":981,"children":982},{},[983],{"type":31,"value":984},"这套结构能直接贴进 PR 描述。",{"type":26,"tag":721,"props":986,"children":988},{"id":987},"工作流-6写最小回归集不写回归-等事故",[989],{"type":31,"value":990},"工作流 6：写“最小回归集”（不写回归 = 等事故）",{"type":26,"tag":27,"props":992,"children":993},{},[994,996,1002],{"type":31,"value":995},"每次改动都至少做 10 条最小回归（见下文清单）。你可以把它写在 ",{"type":26,"tag":527,"props":997,"children":999},{"className":998},[],[1000],{"type":31,"value":1001},"README",{"type":31,"value":1003}," 或团队 wiki。",{"type":26,"tag":721,"props":1005,"children":1007},{"id":1006},"工作流-7把接受建议变成最后一步",[1008],{"type":31,"value":1009},"工作流 7：把“接受建议”变成最后一步",{"type":26,"tag":27,"props":1011,"children":1012},{},[1013,1019,1021,1026],{"type":26,"tag":527,"props":1014,"children":1016},{"className":1015},[],[1017],{"type":31,"value":1018},"Cmd/Ctrl + Y",{"type":31,"value":1020}," 应该是",{"type":26,"tag":333,"props":1022,"children":1023},{},[1024],{"type":31,"value":1025},"最后一步",{"type":31,"value":1027},"：",{"type":26,"tag":41,"props":1029,"children":1030},{},[1031,1036,1041],{"type":26,"tag":45,"props":1032,"children":1033},{},[1034],{"type":31,"value":1035},"你已经看过 diff",{"type":26,"tag":45,"props":1037,"children":1038},{},[1039],{"type":31,"value":1040},"你能说清楚“怎么验收”",{"type":26,"tag":45,"props":1042,"children":1043},{},[1044],{"type":31,"value":1045},"你知道“怎么回滚”",{"type":26,"tag":721,"props":1047,"children":1049},{"id":1048},"工作流-8拒绝建议不是失败是风控动作",[1050],{"type":31,"value":1051},"工作流 8：拒绝建议不是失败，是风控动作",{"type":26,"tag":27,"props":1053,"children":1054},{},[1055,1061],{"type":26,"tag":527,"props":1056,"children":1058},{"className":1057},[],[1059],{"type":31,"value":1060},"Cmd/Ctrl + N",{"type":31,"value":1062}," 的使用时机：",{"type":26,"tag":41,"props":1064,"children":1065},{},[1066,1071,1076],{"type":26,"tag":45,"props":1067,"children":1068},{},[1069],{"type":31,"value":1070},"它开始改你没提过的东西（范围漂移）",{"type":26,"tag":45,"props":1072,"children":1073},{},[1074],{"type":31,"value":1075},"它改了 10 个文件但你只想改 1 个",{"type":26,"tag":45,"props":1077,"children":1078},{},[1079],{"type":31,"value":1080},"它为了“更优雅”引入新依赖/新抽象",{"type":26,"tag":721,"props":1082,"children":1084},{"id":1083},"工作流-9重复任务做成模板提示词不是一次性",[1085],{"type":31,"value":1086},"工作流 9：重复任务做成模板（提示词不是一次性）",{"type":26,"tag":27,"props":1088,"children":1089},{},[1090,1092,1096],{"type":31,"value":1091},"把高频任务（比如“写组件+样式+验收”）固化成模板，放进 Rules（见：",{"type":26,"tag":238,"props":1093,"children":1094},{"href":389},[1095],{"type":31,"value":392},{"type":31,"value":1097},"）。",{"type":26,"tag":721,"props":1099,"children":1101},{"id":1100},"工作流-10把快捷键表做成你自己的任务表",[1102],{"type":31,"value":1103},"工作流 10：把“快捷键表”做成你自己的任务表",{"type":26,"tag":27,"props":1105,"children":1106},{},[1107],{"type":31,"value":1108},"你不需要记住所有快捷键，只需要记住：",{"type":26,"tag":41,"props":1110,"children":1111},{},[1112,1122,1132,1142],{"type":26,"tag":45,"props":1113,"children":1114},{},[1115,1117],{"type":31,"value":1116},"小步改：",{"type":26,"tag":527,"props":1118,"children":1120},{"className":1119},[],[1121],{"type":31,"value":772},{"type":26,"tag":45,"props":1123,"children":1124},{},[1125,1127],{"type":31,"value":1126},"先对齐：",{"type":26,"tag":527,"props":1128,"children":1130},{"className":1129},[],[1131],{"type":31,"value":738},{"type":26,"tag":45,"props":1133,"children":1134},{},[1135,1137],{"type":31,"value":1136},"多文件：",{"type":26,"tag":527,"props":1138,"children":1140},{"className":1139},[],[1141],{"type":31,"value":867},{"type":26,"tag":45,"props":1143,"children":1144},{},[1145,1147],{"type":31,"value":1146},"上下文聚焦：",{"type":26,"tag":527,"props":1148,"children":1150},{"className":1149},[],[1151],{"type":31,"value":930},{"type":26,"tag":394,"props":1153,"children":1154},{},[],{"type":26,"tag":34,"props":1156,"children":1158},{"id":1157},"必交付物-1最小回归任务清单10-条通用",[1159],{"type":31,"value":1160},"必交付物 1：最小回归任务清单（10 条，通用）",{"type":26,"tag":703,"props":1162,"children":1163},{},[1164],{"type":26,"tag":27,"props":1165,"children":1166},{},[1167],{"type":31,"value":1168},"这份清单的意义：让每次 AI 改动都能“被验证”。否则你只是把不可控变成了更快的不可控。",{"type":26,"tag":324,"props":1170,"children":1171},{},[1172,1177,1182,1187,1192,1197,1202,1207,1212,1217],{"type":26,"tag":45,"props":1173,"children":1174},{},[1175],{"type":31,"value":1176},"关键路径能跑通（手动点击/请求一次）",{"type":26,"tag":45,"props":1178,"children":1179},{},[1180],{"type":31,"value":1181},"错误路径能触发（模拟一次失败输入）",{"type":26,"tag":45,"props":1183,"children":1184},{},[1185],{"type":31,"value":1186},"控制台无新增错误（至少关注 1 次真实操作）",{"type":26,"tag":45,"props":1188,"children":1189},{},[1190],{"type":31,"value":1191},"关键 UI 未错位（移动端/桌面端各看一眼）",{"type":26,"tag":45,"props":1193,"children":1194},{},[1195],{"type":31,"value":1196},"刷新后状态正确（尤其是表单/列表）",{"type":26,"tag":45,"props":1198,"children":1199},{},[1200],{"type":31,"value":1201},"路由跳转没断（从入口到目标页）",{"type":26,"tag":45,"props":1203,"children":1204},{},[1205],{"type":31,"value":1206},"相关接口未改变契约（字段名/类型）",{"type":26,"tag":45,"props":1208,"children":1209},{},[1210],{"type":31,"value":1211},"性能没有明显退化（首屏、交互卡顿）",{"type":26,"tag":45,"props":1213,"children":1214},{},[1215],{"type":31,"value":1216},"回滚方案可执行（知道回滚哪几个文件/commit）",{"type":26,"tag":45,"props":1218,"children":1219},{},[1220],{"type":31,"value":1221},"写下“这次改动解决了什么、风险是什么”（可贴 PR）",{"type":26,"tag":394,"props":1223,"children":1224},{},[],{"type":26,"tag":34,"props":1226,"children":1228},{"id":1227},"必交付物-2失败案例复盘真实会发生",[1229],{"type":31,"value":1230},"必交付物 2：失败案例复盘（真实会发生）",{"type":26,"tag":721,"props":1232,"children":1234},{"id":1233},"现象快捷键用得很熟但交付还是慢",[1235],{"type":31,"value":1236},"现象：快捷键用得很熟，但交付还是慢",{"type":26,"tag":27,"props":1238,"children":1239},{},[1240],{"type":31,"value":1241},"典型原因：你把 Cursor 当成“更聪明的搜索框”，不断对话，直到它给出你想要的答案。",{"type":26,"tag":27,"props":1243,"children":1244},{},[1245],{"type":31,"value":1246},"复现路径：",{"type":26,"tag":41,"props":1248,"children":1249},{},[1250,1255,1260,1265],{"type":26,"tag":45,"props":1251,"children":1252},{},[1253],{"type":31,"value":1254},"你直接说“把页面做得更好看、更高级”",{"type":26,"tag":45,"props":1256,"children":1257},{},[1258],{"type":31,"value":1259},"AI 开始大改样式、抽象组件、甚至引入新依赖",{"type":26,"tag":45,"props":1261,"children":1262},{},[1263],{"type":31,"value":1264},"你为了省事按了“接受建议”",{"type":26,"tag":45,"props":1266,"children":1267},{},[1268],{"type":31,"value":1269},"最后发现：设计没统一、移动端崩、甚至埋了性能问题",{"type":26,"tag":27,"props":1271,"children":1272},{},[1273,1275,1279,1281,1286],{"type":31,"value":1274},"根因：缺少",{"type":26,"tag":333,"props":1276,"children":1277},{},[1278],{"type":31,"value":458},{"type":31,"value":1280},"与",{"type":26,"tag":333,"props":1282,"children":1283},{},[1284],{"type":31,"value":1285},"验收",{"type":31,"value":1287},"。",{"type":26,"tag":27,"props":1289,"children":1290},{},[1291],{"type":31,"value":1292},"修复方式（可照抄）：",{"type":26,"tag":41,"props":1294,"children":1295},{},[1296,1301,1313],{"type":26,"tag":45,"props":1297,"children":1298},{},[1299],{"type":31,"value":1300},"把需求拆成 3 个可验证目标：例如“按钮样式统一”“首屏 CTA 更明显”“移动端间距不挤”",{"type":26,"tag":45,"props":1302,"children":1303},{},[1304,1306,1311],{"type":31,"value":1305},"每个目标只用 ",{"type":26,"tag":527,"props":1307,"children":1309},{"className":1308},[],[1310],{"type":31,"value":772},{"type":31,"value":1312}," 改一个局部",{"type":26,"tag":45,"props":1314,"children":1315},{},[1316],{"type":31,"value":1317},"每次接受建议前跑一遍“最小回归集”",{"type":26,"tag":394,"props":1319,"children":1320},{},[],{"type":26,"tag":34,"props":1322,"children":1324},{"id":1323},"faq高频问题",[1325],{"type":31,"value":1326},"FAQ（高频问题）",{"type":26,"tag":721,"props":1328,"children":1330},{"id":1329},"q1我应该先记快捷键还是先学工作流",[1331],{"type":31,"value":1332},"Q1：我应该先记快捷键还是先学工作流？",{"type":26,"tag":27,"props":1334,"children":1335},{},[1336],{"type":31,"value":1337},"先学工作流。快捷键只是把工作流的步骤变短。",{"type":26,"tag":721,"props":1339,"children":1341},{"id":1340},"q2为什么我一用多文件就容易翻车",[1342],{"type":31,"value":1343},"Q2：为什么我一用多文件就容易翻车？",{"type":26,"tag":27,"props":1345,"children":1346},{},[1347],{"type":31,"value":1348},"因为多文件意味着范围更大、依赖更多、验收更难。先锁定“文件清单 + 每步验收”，再让它动手。",{"type":26,"tag":721,"props":1350,"children":1352},{"id":1351},"q3有没有万能提示词",[1353],{"type":31,"value":1354},"Q3：有没有“万能提示词”？",{"type":26,"tag":27,"props":1356,"children":1357},{},[1358],{"type":31,"value":1359},"没有，但有“万能结构”：目标、范围、非目标、验收、输出格式。",{"type":26,"tag":394,"props":1361,"children":1362},{},[],{"type":26,"tag":34,"props":1364,"children":1366},{"id":1365},"延伸阅读建议按顺序",[1367],{"type":31,"value":1368},"延伸阅读（建议按顺序）",{"type":26,"tag":41,"props":1370,"children":1371},{},[1372,1379,1386,1393],{"type":26,"tag":45,"props":1373,"children":1374},{},[1375],{"type":26,"tag":238,"props":1376,"children":1377},{"href":367},[1378],{"type":31,"value":370},{"type":26,"tag":45,"props":1380,"children":1381},{},[1382],{"type":26,"tag":238,"props":1383,"children":1384},{"href":378},[1385],{"type":31,"value":381},{"type":26,"tag":45,"props":1387,"children":1388},{},[1389],{"type":26,"tag":238,"props":1390,"children":1391},{"href":389},[1392],{"type":31,"value":392},{"type":26,"tag":45,"props":1394,"children":1395},{},[1396,1398],{"type":31,"value":1397},"如果你更关心“网页制作落地”：看这篇 ",{"type":26,"tag":238,"props":1399,"children":1401},{"href":1400},"/topics/practical-tips/htmlpage-quick-landing-page",[1402],{"type":31,"value":1403},"3 分钟用 HTMLPAGE 做落地页",{"title":7,"searchDepth":263,"depth":263,"links":1405},[1406,1407,1408,1420,1421,1424,1429],{"id":399,"depth":266,"text":402},{"id":474,"depth":266,"text":477},{"id":716,"depth":266,"text":719,"children":1409},[1410,1411,1412,1413,1414,1415,1416,1417,1418,1419],{"id":723,"depth":263,"text":726},{"id":782,"depth":263,"text":785},{"id":852,"depth":263,"text":855},{"id":908,"depth":263,"text":911},{"id":948,"depth":263,"text":951},{"id":987,"depth":263,"text":990},{"id":1006,"depth":263,"text":1009},{"id":1048,"depth":263,"text":1051},{"id":1083,"depth":263,"text":1086},{"id":1100,"depth":263,"text":1103},{"id":1157,"depth":266,"text":1160},{"id":1227,"depth":266,"text":1230,"children":1422},[1423],{"id":1233,"depth":263,"text":1236},{"id":1323,"depth":266,"text":1326,"children":1425},[1426,1427,1428],{"id":1329,"depth":263,"text":1332},{"id":1340,"depth":263,"text":1343},{"id":1351,"depth":263,"text":1354},{"id":1365,"depth":266,"text":1368},"content:topics:ai:cursor-keyboard-shortcuts-cheatsheet.md","topics/ai/cursor-keyboard-shortcuts-cheatsheet.md","topics/ai/cursor-keyboard-shortcuts-cheatsheet",{"_path":1434,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":1435,"description":1436,"date":1437,"topic":5,"author":11,"tags":1438,"image":1442,"imageAlt":1443,"pexelsPhotoId":1444,"pexelsUrl":1445,"readingTime":1446,"body":1447,"_type":270,"_id":2380,"_source":272,"_file":2381,"_stem":2382,"_extension":275},"/topics/ai/cursor-vs-copilot-vscode-workflow","Cursor vs GitHub Copilot vs VS Code：怎么选、怎么搭配、怎么把风险关在笼子里","用“任务类型×风险×验收成本”的选择矩阵解释 Cursor/Copilot/VS Code 的差异，并给出一套可落地的协作工作流（范围闸门、最小回归集、回滚策略）。","2026-03-01",[283,1439,286,1440,1441],"GitHub Copilot","AI 编程","工作流","/images/topics/ai/cursor-vs-copilot-vscode-workflow.jpg","团队在电脑前进行协作讨论",1181371,"https://www.pexels.com/photo/man-wearing-blue-dress-shirt-1181371/",15,{"type":23,"children":1448,"toc":2358},[1449,1454,1459,1477,1482,1500,1503,1509,1514,1545,1550,1553,1559,1567,1771,1779,1792,1795,1801,1807,1820,1825,1838,1844,1849,1882,1888,1893,1911,1914,1920,1925,1931,1936,1969,1975,1988,1993,2006,2012,2024,2030,2035,2048,2053,2056,2062,2067,2188,2191,2197,2207,2216,2234,2243,2251,2260,2278,2281,2287,2293,2298,2304,2309,2312,2317],{"type":26,"tag":27,"props":1450,"children":1451},{},[1452],{"type":31,"value":1453},"“Cursor 和 Copilot 到底有什么区别？”",{"type":26,"tag":27,"props":1455,"children":1456},{},[1457],{"type":31,"value":1458},"这个问题问得越早越好，因为你一旦把工具选错，后面所有痛苦都不是“提示词不够好”，而是：",{"type":26,"tag":41,"props":1460,"children":1461},{},[1462,1467,1472],{"type":26,"tag":45,"props":1463,"children":1464},{},[1465],{"type":31,"value":1466},"改动不可控（范围漂移、改错文件）",{"type":26,"tag":45,"props":1468,"children":1469},{},[1470],{"type":31,"value":1471},"验收成本爆炸（不知道要测什么）",{"type":26,"tag":45,"props":1473,"children":1474},{},[1475],{"type":31,"value":1476},"团队协作崩盘（没有闸门、没有回滚）",{"type":26,"tag":27,"props":1478,"children":1479},{},[1480],{"type":31,"value":1481},"这篇文章用一张选择矩阵 + 一套可执行工作流，帮你做到两件事：",{"type":26,"tag":324,"props":1483,"children":1484},{},[1485,1490],{"type":26,"tag":45,"props":1486,"children":1487},{},[1488],{"type":31,"value":1489},"知道什么时候用 Cursor、什么时候用 Copilot、什么时候“纯 VS Code 更快”",{"type":26,"tag":45,"props":1491,"children":1492},{},[1493,1495],{"type":31,"value":1494},"就算用 AI，也能把风险关在笼子里：",{"type":26,"tag":333,"props":1496,"children":1497},{},[1498],{"type":31,"value":1499},"可审查、可验证、可回滚",{"type":26,"tag":394,"props":1501,"children":1502},{},[],{"type":26,"tag":34,"props":1504,"children":1506},{"id":1505},"结论先说三者不是互斥而是分工",[1507],{"type":31,"value":1508},"结论先说：三者不是互斥，而是分工",{"type":26,"tag":27,"props":1510,"children":1511},{},[1512],{"type":31,"value":1513},"你可以把它们看成三层能力：",{"type":26,"tag":41,"props":1515,"children":1516},{},[1517,1526,1536],{"type":26,"tag":45,"props":1518,"children":1519},{},[1520,1524],{"type":26,"tag":333,"props":1521,"children":1522},{},[1523],{"type":31,"value":286},{"type":31,"value":1525},"：编辑器与生态（调试、插件、任务、终端、语言服务）",{"type":26,"tag":45,"props":1527,"children":1528},{},[1529,1534],{"type":26,"tag":333,"props":1530,"children":1531},{},[1532],{"type":31,"value":1533},"Copilot",{"type":31,"value":1535},"：代码补全与局部建议（“我正在写这一行/这一段”）",{"type":26,"tag":45,"props":1537,"children":1538},{},[1539,1543],{"type":26,"tag":333,"props":1540,"children":1541},{},[1542],{"type":31,"value":283},{"type":31,"value":1544},"：以项目为单位的 AI 协作（对话、索引、多文件编辑、规则）",{"type":26,"tag":27,"props":1546,"children":1547},{},[1548],{"type":31,"value":1549},"最常见的误区是：把“局部补全能力”当作“能做架构与多文件落地”。",{"type":26,"tag":394,"props":1551,"children":1552},{},[],{"type":26,"tag":34,"props":1554,"children":1556},{"id":1555},"选择矩阵按任务类型选工具不是按偏好",[1557],{"type":31,"value":1558},"选择矩阵：按任务类型选工具（不是按偏好）",{"type":26,"tag":703,"props":1560,"children":1561},{},[1562],{"type":26,"tag":27,"props":1563,"children":1564},{},[1565],{"type":31,"value":1566},"你只要把自己的任务放进表格，就能得到推荐路径。",{"type":26,"tag":71,"props":1568,"children":1569},{},[1570,1602],{"type":26,"tag":75,"props":1571,"children":1572},{},[1573],{"type":26,"tag":79,"props":1574,"children":1575},{},[1576,1581,1587,1592,1597],{"type":26,"tag":83,"props":1577,"children":1578},{},[1579],{"type":31,"value":1580},"任务类型",{"type":26,"tag":83,"props":1582,"children":1584},{"align":1583},"right",[1585],{"type":31,"value":1586},"风险",{"type":26,"tag":83,"props":1588,"children":1589},{"align":1583},[1590],{"type":31,"value":1591},"验收成本",{"type":26,"tag":83,"props":1593,"children":1594},{},[1595],{"type":31,"value":1596},"更推荐",{"type":26,"tag":83,"props":1598,"children":1599},{},[1600],{"type":31,"value":1601},"为什么",{"type":26,"tag":94,"props":1603,"children":1604},{},[1605,1632,1665,1691,1718,1745],{"type":26,"tag":79,"props":1606,"children":1607},{},[1608,1613,1618,1622,1627],{"type":26,"tag":101,"props":1609,"children":1610},{},[1611],{"type":31,"value":1612},"写一段代码/补一个 if",{"type":26,"tag":101,"props":1614,"children":1615},{"align":1583},[1616],{"type":31,"value":1617},"低",{"type":26,"tag":101,"props":1619,"children":1620},{"align":1583},[1621],{"type":31,"value":1617},{"type":26,"tag":101,"props":1623,"children":1624},{},[1625],{"type":31,"value":1626},"Copilot / Cursor 内联编辑",{"type":26,"tag":101,"props":1628,"children":1629},{},[1630],{"type":31,"value":1631},"局部建议足够，成本最低",{"type":26,"tag":79,"props":1633,"children":1634},{},[1635,1640,1645,1649,1660],{"type":26,"tag":101,"props":1636,"children":1637},{},[1638],{"type":31,"value":1639},"重构一个函数",{"type":26,"tag":101,"props":1641,"children":1642},{"align":1583},[1643],{"type":31,"value":1644},"中",{"type":26,"tag":101,"props":1646,"children":1647},{"align":1583},[1648],{"type":31,"value":1644},{"type":26,"tag":101,"props":1650,"children":1651},{},[1652,1654],{"type":31,"value":1653},"Cursor ",{"type":26,"tag":527,"props":1655,"children":1657},{"className":1656},[],[1658],{"type":31,"value":1659},"内联编辑",{"type":26,"tag":101,"props":1661,"children":1662},{},[1663],{"type":31,"value":1664},"需要解释、需要约束输出",{"type":26,"tag":79,"props":1666,"children":1667},{},[1668,1673,1677,1681,1686],{"type":26,"tag":101,"props":1669,"children":1670},{},[1671],{"type":31,"value":1672},"改一个组件 + 样式",{"type":26,"tag":101,"props":1674,"children":1675},{"align":1583},[1676],{"type":31,"value":1644},{"type":26,"tag":101,"props":1678,"children":1679},{"align":1583},[1680],{"type":31,"value":1644},{"type":26,"tag":101,"props":1682,"children":1683},{},[1684],{"type":31,"value":1685},"Cursor（小范围多文件）",{"type":26,"tag":101,"props":1687,"children":1688},{},[1689],{"type":31,"value":1690},"需要同时改模板与样式",{"type":26,"tag":79,"props":1692,"children":1693},{},[1694,1699,1704,1708,1713],{"type":26,"tag":101,"props":1695,"children":1696},{},[1697],{"type":31,"value":1698},"改 3~5 个文件（组件+api+测试）",{"type":26,"tag":101,"props":1700,"children":1701},{"align":1583},[1702],{"type":31,"value":1703},"高",{"type":26,"tag":101,"props":1705,"children":1706},{"align":1583},[1707],{"type":31,"value":1703},{"type":26,"tag":101,"props":1709,"children":1710},{},[1711],{"type":31,"value":1712},"Cursor Composer + 闸门",{"type":26,"tag":101,"props":1714,"children":1715},{},[1716],{"type":31,"value":1717},"需要计划、验收、回滚",{"type":26,"tag":79,"props":1719,"children":1720},{},[1721,1726,1731,1735,1740],{"type":26,"tag":101,"props":1722,"children":1723},{},[1724],{"type":31,"value":1725},"重写一段架构/引入新依赖",{"type":26,"tag":101,"props":1727,"children":1728},{"align":1583},[1729],{"type":31,"value":1730},"很高",{"type":26,"tag":101,"props":1732,"children":1733},{"align":1583},[1734],{"type":31,"value":1730},{"type":26,"tag":101,"props":1736,"children":1737},{},[1738],{"type":31,"value":1739},"先人脑设计 + VS Code 实现",{"type":26,"tag":101,"props":1741,"children":1742},{},[1743],{"type":31,"value":1744},"AI 易发散，最好先设计再执行",{"type":26,"tag":79,"props":1746,"children":1747},{},[1748,1753,1757,1761,1766],{"type":26,"tag":101,"props":1749,"children":1750},{},[1751],{"type":31,"value":1752},"排查线上问题/性能抖动",{"type":26,"tag":101,"props":1754,"children":1755},{"align":1583},[1756],{"type":31,"value":1703},{"type":26,"tag":101,"props":1758,"children":1759},{"align":1583},[1760],{"type":31,"value":1730},{"type":26,"tag":101,"props":1762,"children":1763},{},[1764],{"type":31,"value":1765},"VS Code + 工具链优先，AI 辅助归纳",{"type":26,"tag":101,"props":1767,"children":1768},{},[1769],{"type":31,"value":1770},"需要证据，不要“猜”",{"type":26,"tag":27,"props":1772,"children":1773},{},[1774],{"type":26,"tag":333,"props":1775,"children":1776},{},[1777],{"type":31,"value":1778},"一句话规则：",{"type":26,"tag":41,"props":1780,"children":1781},{},[1782,1787],{"type":26,"tag":45,"props":1783,"children":1784},{},[1785],{"type":31,"value":1786},"当你的改动可以用“10 条最小回归集”覆盖时，用 Cursor。",{"type":26,"tag":45,"props":1788,"children":1789},{},[1790],{"type":31,"value":1791},"当你的改动无法验证时，先别让 AI 动手。",{"type":26,"tag":394,"props":1793,"children":1794},{},[],{"type":26,"tag":34,"props":1796,"children":1798},{"id":1797},"差异拆解到底差在哪里",[1799],{"type":31,"value":1800},"差异拆解：到底差在哪里？",{"type":26,"tag":721,"props":1802,"children":1804},{"id":1803},"_1-上下文来源补全-vs-项目索引",[1805],{"type":31,"value":1806},"1) 上下文来源：补全 vs 项目索引",{"type":26,"tag":41,"props":1808,"children":1809},{},[1810,1815],{"type":26,"tag":45,"props":1811,"children":1812},{},[1813],{"type":31,"value":1814},"Copilot 更擅长：你正在写的这几行、当前文件的局部上下文",{"type":26,"tag":45,"props":1816,"children":1817},{},[1818],{"type":31,"value":1819},"Cursor 更擅长：项目级索引 + 多文件关联理解",{"type":26,"tag":27,"props":1821,"children":1822},{},[1823],{"type":31,"value":1824},"因此：",{"type":26,"tag":41,"props":1826,"children":1827},{},[1828,1833],{"type":26,"tag":45,"props":1829,"children":1830},{},[1831],{"type":31,"value":1832},"写代码片段：Copilot 速度更快",{"type":26,"tag":45,"props":1834,"children":1835},{},[1836],{"type":31,"value":1837},"改一坨工程：Cursor 更有胜算（但更需要闸门）",{"type":26,"tag":721,"props":1839,"children":1841},{"id":1840},"_2-交互方式你能不能控制范围",[1842],{"type":31,"value":1843},"2) 交互方式：你能不能控制范围",{"type":26,"tag":27,"props":1845,"children":1846},{},[1847],{"type":31,"value":1848},"范围控制的三个层级：",{"type":26,"tag":324,"props":1850,"children":1851},{},[1852,1862,1872],{"type":26,"tag":45,"props":1853,"children":1854},{},[1855,1857],{"type":31,"value":1856},"内联编辑（选中一段）→ ",{"type":26,"tag":333,"props":1858,"children":1859},{},[1860],{"type":31,"value":1861},"最强范围控制",{"type":26,"tag":45,"props":1863,"children":1864},{},[1865,1867],{"type":31,"value":1866},"Composer 多文件（先列文件清单）→ ",{"type":26,"tag":333,"props":1868,"children":1869},{},[1870],{"type":31,"value":1871},"可控但要闸门",{"type":26,"tag":45,"props":1873,"children":1874},{},[1875,1877],{"type":31,"value":1876},"大对话（泛目标）→ ",{"type":26,"tag":333,"props":1878,"children":1879},{},[1880],{"type":31,"value":1881},"最容易跑偏",{"type":26,"tag":721,"props":1883,"children":1885},{"id":1884},"_3-输出形态建议-vs-可审查的变更",[1886],{"type":31,"value":1887},"3) 输出形态：建议 vs 可审查的变更",{"type":26,"tag":27,"props":1889,"children":1890},{},[1891],{"type":31,"value":1892},"最好的 AI 输出不是“给我一段代码”，而是：",{"type":26,"tag":41,"props":1894,"children":1895},{},[1896,1901,1906],{"type":26,"tag":45,"props":1897,"children":1898},{},[1899],{"type":31,"value":1900},"改动摘要（做了什么）",{"type":26,"tag":45,"props":1902,"children":1903},{},[1904],{"type":31,"value":1905},"diff 级别的可审查变更",{"type":26,"tag":45,"props":1907,"children":1908},{},[1909],{"type":31,"value":1910},"验收步骤与回滚方案",{"type":26,"tag":394,"props":1912,"children":1913},{},[],{"type":26,"tag":34,"props":1915,"children":1917},{"id":1916},"一套可落地的团队工作流把风险关住",[1918],{"type":31,"value":1919},"一套可落地的团队工作流（把风险关住）",{"type":26,"tag":27,"props":1921,"children":1922},{},[1923],{"type":31,"value":1924},"下面这套流程，你可以直接写进团队规范：",{"type":26,"tag":721,"props":1926,"children":1928},{"id":1927},"step-1先写任务单geo-友好结构",[1929],{"type":31,"value":1930},"Step 1：先写任务单（GEO 友好结构）",{"type":26,"tag":27,"props":1932,"children":1933},{},[1934],{"type":31,"value":1935},"模板：",{"type":26,"tag":41,"props":1937,"children":1938},{},[1939,1944,1949,1954,1959,1964],{"type":26,"tag":45,"props":1940,"children":1941},{},[1942],{"type":31,"value":1943},"目标：……",{"type":26,"tag":45,"props":1945,"children":1946},{},[1947],{"type":31,"value":1948},"背景：……",{"type":26,"tag":45,"props":1950,"children":1951},{},[1952],{"type":31,"value":1953},"范围：只改这些文件/模块：……",{"type":26,"tag":45,"props":1955,"children":1956},{},[1957],{"type":31,"value":1958},"非目标：不做哪些事情：……",{"type":26,"tag":45,"props":1960,"children":1961},{},[1962],{"type":31,"value":1963},"验收：如何判断完成（可测试/可观察）：……",{"type":26,"tag":45,"props":1965,"children":1966},{},[1967],{"type":31,"value":1968},"回滚：如果失败怎么撤回：……",{"type":26,"tag":721,"props":1970,"children":1972},{"id":1971},"step-2用范围闸门限制-ai",[1973],{"type":31,"value":1974},"Step 2：用“范围闸门”限制 AI",{"type":26,"tag":41,"props":1976,"children":1977},{},[1978,1983],{"type":26,"tag":45,"props":1979,"children":1980},{},[1981],{"type":31,"value":1982},"单文件改动：优先 Cursor 内联编辑",{"type":26,"tag":45,"props":1984,"children":1985},{},[1986],{"type":31,"value":1987},"多文件改动：必须先让 AI 输出“文件清单（≤5）+ 每步验收”",{"type":26,"tag":27,"props":1989,"children":1990},{},[1991],{"type":31,"value":1992},"如果 AI 输出的文件清单超过 5 个：",{"type":26,"tag":41,"props":1994,"children":1995},{},[1996,2001],{"type":26,"tag":45,"props":1997,"children":1998},{},[1999],{"type":31,"value":2000},"不是它太强，是任务太大",{"type":26,"tag":45,"props":2002,"children":2003},{},[2004],{"type":31,"value":2005},"你需要拆任务，而不是继续推进",{"type":26,"tag":721,"props":2007,"children":2009},{"id":2008},"step-3最小回归集10-条",[2010],{"type":31,"value":2011},"Step 3：最小回归集（10 条）",{"type":26,"tag":27,"props":2013,"children":2014},{},[2015,2017,2022],{"type":31,"value":2016},"每次接受改动前必须跑（可参考：",{"type":26,"tag":238,"props":2018,"children":2019},{"href":278},[2020],{"type":31,"value":2021},"Cursor 快捷键速查表",{"type":31,"value":2023}," 里的清单）。",{"type":26,"tag":721,"props":2025,"children":2027},{"id":2026},"step-4回滚策略不用等事故才想",[2028],{"type":31,"value":2029},"Step 4：回滚策略（不用等事故才想）",{"type":26,"tag":27,"props":2031,"children":2032},{},[2033],{"type":31,"value":2034},"回滚最常见的两条路：",{"type":26,"tag":41,"props":2036,"children":2037},{},[2038,2043],{"type":26,"tag":45,"props":2039,"children":2040},{},[2041],{"type":31,"value":2042},"git 回滚 commit",{"type":26,"tag":45,"props":2044,"children":2045},{},[2046],{"type":31,"value":2047},"对关键文件保留前版本（至少能快速恢复）",{"type":26,"tag":27,"props":2049,"children":2050},{},[2051],{"type":31,"value":2052},"你需要做到：任何一轮 AI 改动都能在 5 分钟内撤回。",{"type":26,"tag":394,"props":2054,"children":2055},{},[],{"type":26,"tag":34,"props":2057,"children":2059},{"id":2058},"必交付物对比矩阵可复制",[2060],{"type":31,"value":2061},"必交付物：对比矩阵（可复制）",{"type":26,"tag":27,"props":2063,"children":2064},{},[2065],{"type":31,"value":2066},"下面这张表可以直接贴到你的团队 wiki：",{"type":26,"tag":71,"props":2068,"children":2069},{},[2070,2093],{"type":26,"tag":75,"props":2071,"children":2072},{},[2073],{"type":26,"tag":79,"props":2074,"children":2075},{},[2076,2081,2085,2089],{"type":26,"tag":83,"props":2077,"children":2078},{},[2079],{"type":31,"value":2080},"维度",{"type":26,"tag":83,"props":2082,"children":2083},{},[2084],{"type":31,"value":286},{"type":26,"tag":83,"props":2086,"children":2087},{},[2088],{"type":31,"value":1533},{"type":26,"tag":83,"props":2090,"children":2091},{},[2092],{"type":31,"value":283},{"type":26,"tag":94,"props":2094,"children":2095},{},[2096,2119,2142,2165],{"type":26,"tag":79,"props":2097,"children":2098},{},[2099,2104,2109,2114],{"type":26,"tag":101,"props":2100,"children":2101},{},[2102],{"type":31,"value":2103},"强项",{"type":26,"tag":101,"props":2105,"children":2106},{},[2107],{"type":31,"value":2108},"工具链、调试、生态",{"type":26,"tag":101,"props":2110,"children":2111},{},[2112],{"type":31,"value":2113},"补全与局部建议",{"type":26,"tag":101,"props":2115,"children":2116},{},[2117],{"type":31,"value":2118},"项目上下文、多文件落地",{"type":26,"tag":79,"props":2120,"children":2121},{},[2122,2127,2132,2137],{"type":26,"tag":101,"props":2123,"children":2124},{},[2125],{"type":31,"value":2126},"适合任务",{"type":26,"tag":101,"props":2128,"children":2129},{},[2130],{"type":31,"value":2131},"排查、调试、验证",{"type":26,"tag":101,"props":2133,"children":2134},{},[2135],{"type":31,"value":2136},"写一段、补一段",{"type":26,"tag":101,"props":2138,"children":2139},{},[2140],{"type":31,"value":2141},"改一段、改一组文件",{"type":26,"tag":79,"props":2143,"children":2144},{},[2145,2150,2155,2160],{"type":26,"tag":101,"props":2146,"children":2147},{},[2148],{"type":31,"value":2149},"最大风险",{"type":26,"tag":101,"props":2151,"children":2152},{},[2153],{"type":31,"value":2154},"无",{"type":26,"tag":101,"props":2156,"children":2157},{},[2158],{"type":31,"value":2159},"过度依赖建议",{"type":26,"tag":101,"props":2161,"children":2162},{},[2163],{"type":31,"value":2164},"范围漂移、多文件回归",{"type":26,"tag":79,"props":2166,"children":2167},{},[2168,2173,2178,2183],{"type":26,"tag":101,"props":2169,"children":2170},{},[2171],{"type":31,"value":2172},"必须搭配",{"type":26,"tag":101,"props":2174,"children":2175},{},[2176],{"type":31,"value":2177},"规范与检查",{"type":26,"tag":101,"props":2179,"children":2180},{},[2181],{"type":31,"value":2182},"代码评审",{"type":26,"tag":101,"props":2184,"children":2185},{},[2186],{"type":31,"value":2187},"闸门 + 最小回归集",{"type":26,"tag":394,"props":2189,"children":2190},{},[],{"type":26,"tag":34,"props":2192,"children":2194},{"id":2193},"失败案例多文件看似成功实际埋雷",[2195],{"type":31,"value":2196},"失败案例：多文件“看似成功”，实际埋雷",{"type":26,"tag":27,"props":2198,"children":2199},{},[2200,2205],{"type":26,"tag":333,"props":2201,"children":2202},{},[2203],{"type":31,"value":2204},"现象",{"type":31,"value":2206},"：AI 说“我已经把所有地方都改了”，你也接受了，结果上线后 404 或样式错位。",{"type":26,"tag":27,"props":2208,"children":2209},{},[2210,2215],{"type":26,"tag":333,"props":2211,"children":2212},{},[2213],{"type":31,"value":2214},"复现条件",{"type":31,"value":1027},{"type":26,"tag":41,"props":2217,"children":2218},{},[2219,2224,2229],{"type":26,"tag":45,"props":2220,"children":2221},{},[2222],{"type":31,"value":2223},"你给了一个大目标（例如“把所有按钮统一成主题色”）",{"type":26,"tag":45,"props":2225,"children":2226},{},[2227],{"type":31,"value":2228},"它改了组件、样式、甚至主题配置",{"type":26,"tag":45,"props":2230,"children":2231},{},[2232],{"type":31,"value":2233},"你没有按页面模块走一遍，直接合并",{"type":26,"tag":27,"props":2235,"children":2236},{},[2237,2242],{"type":26,"tag":333,"props":2238,"children":2239},{},[2240],{"type":31,"value":2241},"根因",{"type":31,"value":1027},{"type":26,"tag":41,"props":2244,"children":2245},{},[2246],{"type":26,"tag":45,"props":2247,"children":2248},{},[2249],{"type":31,"value":2250},"改动范围大，但验收仍按“小改动”的方式做（只看一处）",{"type":26,"tag":27,"props":2252,"children":2253},{},[2254,2259],{"type":26,"tag":333,"props":2255,"children":2256},{},[2257],{"type":31,"value":2258},"修复",{"type":31,"value":1027},{"type":26,"tag":41,"props":2261,"children":2262},{},[2263,2268,2273],{"type":26,"tag":45,"props":2264,"children":2265},{},[2266],{"type":31,"value":2267},"强制把任务拆成“模块级目标”：Hero、Feature、Pricing、Form",{"type":26,"tag":45,"props":2269,"children":2270},{},[2271],{"type":31,"value":2272},"每个模块改完就验收一次",{"type":26,"tag":45,"props":2274,"children":2275},{},[2276],{"type":31,"value":2277},"验收通过再进入下一个模块",{"type":26,"tag":394,"props":2279,"children":2280},{},[],{"type":26,"tag":34,"props":2282,"children":2284},{"id":2283},"faq",[2285],{"type":31,"value":2286},"FAQ",{"type":26,"tag":721,"props":2288,"children":2290},{"id":2289},"q1我已经用了-cursor为什么还要用-copilot",[2291],{"type":31,"value":2292},"Q1：我已经用了 Cursor，为什么还要用 Copilot？",{"type":26,"tag":27,"props":2294,"children":2295},{},[2296],{"type":31,"value":2297},"因为“补全”这种高频低风险任务，Copilot 的交互成本更低；Cursor 更适合需要解释与约束的改动。",{"type":26,"tag":721,"props":2299,"children":2301},{"id":2300},"q2什么时候应该完全不用-ai",[2302],{"type":31,"value":2303},"Q2：什么时候应该完全不用 AI？",{"type":26,"tag":27,"props":2305,"children":2306},{},[2307],{"type":31,"value":2308},"当你无法定义验收标准时。比如“更高级”“更好看”这种目标，先做信息结构与设计规则，再让 AI 帮你落地局部。",{"type":26,"tag":394,"props":2310,"children":2311},{},[],{"type":26,"tag":34,"props":2313,"children":2315},{"id":2314},"延伸阅读",[2316],{"type":31,"value":2314},{"type":26,"tag":41,"props":2318,"children":2319},{},[2320,2329,2338,2347],{"type":26,"tag":45,"props":2321,"children":2322},{},[2323,2325],{"type":31,"value":2324},"Cursor 入门：",{"type":26,"tag":238,"props":2326,"children":2327},{"href":367},[2328],{"type":31,"value":370},{"type":26,"tag":45,"props":2330,"children":2331},{},[2332,2334],{"type":31,"value":2333},"Cursor 进阶：",{"type":26,"tag":238,"props":2335,"children":2336},{"href":378},[2337],{"type":31,"value":381},{"type":26,"tag":45,"props":2339,"children":2340},{},[2341,2343],{"type":31,"value":2342},"规则配置：",{"type":26,"tag":238,"props":2344,"children":2345},{"href":389},[2346],{"type":31,"value":392},{"type":26,"tag":45,"props":2348,"children":2349},{},[2350,2352],{"type":31,"value":2351},"Copilot 实战：",{"type":26,"tag":238,"props":2353,"children":2355},{"href":2354},"/topics/ai/github-copilot-tips",[2356],{"type":31,"value":2357},"GitHub Copilot 实用技巧",{"title":7,"searchDepth":263,"depth":263,"links":2359},[2360,2361,2362,2367,2373,2374,2375,2379],{"id":1505,"depth":266,"text":1508},{"id":1555,"depth":266,"text":1558},{"id":1797,"depth":266,"text":1800,"children":2363},[2364,2365,2366],{"id":1803,"depth":263,"text":1806},{"id":1840,"depth":263,"text":1843},{"id":1884,"depth":263,"text":1887},{"id":1916,"depth":266,"text":1919,"children":2368},[2369,2370,2371,2372],{"id":1927,"depth":263,"text":1930},{"id":1971,"depth":263,"text":1974},{"id":2008,"depth":263,"text":2011},{"id":2026,"depth":263,"text":2029},{"id":2058,"depth":266,"text":2061},{"id":2193,"depth":266,"text":2196},{"id":2283,"depth":266,"text":2286,"children":2376},[2377,2378],{"id":2289,"depth":263,"text":2292},{"id":2300,"depth":263,"text":2303},{"id":2314,"depth":266,"text":2314},"content:topics:ai:cursor-vs-copilot-vscode-workflow.md","topics/ai/cursor-vs-copilot-vscode-workflow.md","topics/ai/cursor-vs-copilot-vscode-workflow",{"_path":2384,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":2385,"description":2386,"date":2387,"topic":5,"author":11,"tags":2388,"image":2393,"featured":185,"readingTime":1446,"body":2394,"_type":270,"_id":3043,"_source":272,"_file":3044,"_stem":3045,"_extension":275},"/topics/ai/ai-debugging-troubleshooting-guide","AI 辅助调试与问题排查：让 AI 成为你的调试搭档","深入探讨如何利用 AI 工具提升调试效率，包括错误信息分析、日志解读、性能问题定位、复杂 bug 排查等实战场景，构建 AI 驱动的调试工作流。","2026-01-18",[2389,2390,2391,287,2392],"AI 调试","问题排查","Debug","错误处理","/images/topics/ai/ai-debugging-guide.jpg",{"type":23,"children":2395,"toc":3014},[2396,2402,2408,2413,2418,2423,2429,2435,2440,2448,2476,2484,2507,2513,2524,2533,2541,2549,2582,2590,2620,2633,2641,2646,2654,2662,2673,2679,2687,2698,2706,2715,2721,2727,2732,2741,2747,2752,2761,2767,2773,2782,2788,2797,2803,2814,2820,2826,2835,2841,2850,2856,2862,2870,2876,2885,2893,2901,2904,2910,2915,2934,2946,2949,2955,2960,2969,2974,2977,2983,2988,3006],{"type":26,"tag":34,"props":2397,"children":2399},{"id":2398},"ai-辅助调试与问题排查",[2400],{"type":31,"value":2401},"AI 辅助调试与问题排查",{"type":26,"tag":34,"props":2403,"children":2405},{"id":2404},"引言调试的痛与-ai-的解药",[2406],{"type":31,"value":2407},"引言：调试的痛与 AI 的解药",{"type":26,"tag":27,"props":2409,"children":2410},{},[2411],{"type":31,"value":2412},"调试是每个程序员的日常，也是最消耗时间和精力的工作之一。我们都有过这样的经历：盯着一个莫名其妙的错误信息，翻遍 Stack Overflow，尝试各种方案，几个小时后才发现是一个愚蠢的拼写错误。",{"type":26,"tag":27,"props":2414,"children":2415},{},[2416],{"type":31,"value":2417},"AI 工具的出现，正在改变调试的方式。不是替代你的思考，而是加速你的分析过程——帮你快速理解错误、缩小排查范围、验证假设。",{"type":26,"tag":27,"props":2419,"children":2420},{},[2421],{"type":31,"value":2422},"这篇文章分享我在实际项目中使用 AI 辅助调试的经验和方法论。",{"type":26,"tag":34,"props":2424,"children":2426},{"id":2425},"第一部分建立-ai-调试的思维模型",[2427],{"type":31,"value":2428},"第一部分：建立 AI 调试的思维模型",{"type":26,"tag":721,"props":2430,"children":2432},{"id":2431},"_11-ai-在调试中的角色",[2433],{"type":31,"value":2434},"1.1 AI 在调试中的角色",{"type":26,"tag":27,"props":2436,"children":2437},{},[2438],{"type":31,"value":2439},"把 AI 想象成一个经验丰富但不了解你项目的高级工程师。它：",{"type":26,"tag":27,"props":2441,"children":2442},{},[2443],{"type":26,"tag":333,"props":2444,"children":2445},{},[2446],{"type":31,"value":2447},"擅长的事情：",{"type":26,"tag":41,"props":2449,"children":2450},{},[2451,2456,2461,2466,2471],{"type":26,"tag":45,"props":2452,"children":2453},{},[2454],{"type":31,"value":2455},"解读错误信息的含义",{"type":26,"tag":45,"props":2457,"children":2458},{},[2459],{"type":31,"value":2460},"提供可能的原因列表",{"type":26,"tag":45,"props":2462,"children":2463},{},[2464],{"type":31,"value":2465},"给出排查方向建议",{"type":26,"tag":45,"props":2467,"children":2468},{},[2469],{"type":31,"value":2470},"解释复杂的技术概念",{"type":26,"tag":45,"props":2472,"children":2473},{},[2474],{"type":31,"value":2475},"生成调试代码片段",{"type":26,"tag":27,"props":2477,"children":2478},{},[2479],{"type":26,"tag":333,"props":2480,"children":2481},{},[2482],{"type":31,"value":2483},"不擅长的事情：",{"type":26,"tag":41,"props":2485,"children":2486},{},[2487,2492,2497,2502],{"type":26,"tag":45,"props":2488,"children":2489},{},[2490],{"type":31,"value":2491},"了解你的业务逻辑",{"type":26,"tag":45,"props":2493,"children":2494},{},[2495],{"type":31,"value":2496},"知道你的代码历史",{"type":26,"tag":45,"props":2498,"children":2499},{},[2500],{"type":31,"value":2501},"理解项目特定的约定",{"type":26,"tag":45,"props":2503,"children":2504},{},[2505],{"type":31,"value":2506},"做出架构级判断",{"type":26,"tag":721,"props":2508,"children":2510},{"id":2509},"_12-有效提问的结构",[2511],{"type":31,"value":2512},"1.2 有效提问的结构",{"type":26,"tag":2514,"props":2515,"children":2519},"pre",{"code":2516,"language":270,"meta":7,"className":2517},"## 高效的调试提问模板\n\n**问题描述**\n[简洁描述遇到的问题]\n\n**错误信息**\n",[2518],"language-markdown",[2520],{"type":26,"tag":527,"props":2521,"children":2522},{"__ignoreMap":7},[2523],{"type":31,"value":2516},{"type":26,"tag":27,"props":2525,"children":2526},{},[2527],{"type":26,"tag":2528,"props":2529,"children":2530},"span",{},[2531],{"type":31,"value":2532},"完整的错误信息，不要截断",{"type":26,"tag":2514,"props":2534,"children":2536},{"code":2535},"\n**相关代码**\n```javascript\n[精简但完整的相关代码]\n",[2537],{"type":26,"tag":527,"props":2538,"children":2539},{"__ignoreMap":7},[2540],{"type":31,"value":2535},{"type":26,"tag":27,"props":2542,"children":2543},{},[2544],{"type":26,"tag":333,"props":2545,"children":2546},{},[2547],{"type":31,"value":2548},"环境信息",{"type":26,"tag":41,"props":2550,"children":2551},{},[2552,2562,2572],{"type":26,"tag":45,"props":2553,"children":2554},{},[2555,2557],{"type":31,"value":2556},"运行环境：",{"type":26,"tag":2528,"props":2558,"children":2559},{},[2560],{"type":31,"value":2561},"Node 版本/浏览器版本",{"type":26,"tag":45,"props":2563,"children":2564},{},[2565,2567],{"type":31,"value":2566},"框架版本：",{"type":26,"tag":2528,"props":2568,"children":2569},{},[2570],{"type":31,"value":2571},"相关框架版本",{"type":26,"tag":45,"props":2573,"children":2574},{},[2575,2577],{"type":31,"value":2576},"操作系统：",{"type":26,"tag":2528,"props":2578,"children":2579},{},[2580],{"type":31,"value":2581},"如果相关",{"type":26,"tag":27,"props":2583,"children":2584},{},[2585],{"type":26,"tag":333,"props":2586,"children":2587},{},[2588],{"type":31,"value":2589},"已尝试的方案",{"type":26,"tag":41,"props":2591,"children":2592},{},[2593,2607],{"type":26,"tag":45,"props":2594,"children":2595},{},[2596,2601,2602],{"type":26,"tag":2528,"props":2597,"children":2598},{},[2599],{"type":31,"value":2600},"方案1",{"type":31,"value":1027},{"type":26,"tag":2528,"props":2603,"children":2604},{},[2605],{"type":31,"value":2606},"结果",{"type":26,"tag":45,"props":2608,"children":2609},{},[2610,2615,2616],{"type":26,"tag":2528,"props":2611,"children":2612},{},[2613],{"type":31,"value":2614},"方案2",{"type":31,"value":1027},{"type":26,"tag":2528,"props":2617,"children":2618},{},[2619],{"type":31,"value":2606},{"type":26,"tag":27,"props":2621,"children":2622},{},[2623,2628],{"type":26,"tag":333,"props":2624,"children":2625},{},[2626],{"type":31,"value":2627},"期望的结果",{"type":26,"tag":2528,"props":2629,"children":2630},{},[2631],{"type":31,"value":2632},"描述期望的行为",{"type":26,"tag":2514,"props":2634,"children":2636},{"code":2635},"\n### 1.3 分级调试策略\n\n",[2637],{"type":26,"tag":527,"props":2638,"children":2639},{"__ignoreMap":7},[2640],{"type":31,"value":2635},{"type":26,"tag":27,"props":2642,"children":2643},{},[2644],{"type":31,"value":2645},"┌───────────────────────────────────────────────────────────┐\n│                    AI 辅助调试决策树                        │\n├───────────────────────────────────────────────────────────┤\n│                                                           │\n│  Level 1：简单错误（5分钟内解决）                           │\n│  ├── 语法错误、拼写错误                                    │\n│  ├── 方法：直接复制错误信息给 AI                           │\n│  └── 工具：Copilot Chat / ChatGPT                        │\n│                                                           │\n│  Level 2：中等复杂度（30分钟内解决）                        │\n│  ├── 类型错误、逻辑错误、API 使用错误                      │\n│  ├── 方法：提供错误信息 + 相关代码 + 上下文                 │\n│  └── 工具：Cursor Chat / Claude                          │\n│                                                           │\n│  Level 3：复杂问题（需要深入分析）                          │\n│  ├── 竞态条件、内存泄漏、性能问题                          │\n│  ├── 方法：详细描述场景 + 提供多个文件 + 讨论               │\n│  └── 工具：Cursor Composer / 专门的 AI 会话                │\n│                                                           │\n│  Level 4：架构级问题                                       │\n│  ├── 设计缺陷、技术债务                                    │\n│  ├── 方法：AI 辅助分析 + 人工判断                          │\n│  └── 工具：与团队讨论 + AI 作为顾问                        │\n│                                                           │\n└───────────────────────────────────────────────────────────┘",{"type":26,"tag":2514,"props":2647,"children":2649},{"code":2648},"\n## 第二部分：错误信息分析\n\n### 2.1 前端错误分析\n\n**场景 1：React 错误边界触发**\n\n```typescript\n// 错误信息：\n// Error: Hydration failed because the initial UI does not match \n// what was rendered on the server.\n\n// 提问方式：\n/**\n * 我在 Next.js 14 App Router 项目中遇到这个错误：\n * \n * Error: Hydration failed because the initial UI does not match \n * what was rendered on the server.\n * \n * 相关代码：\n */\nfunction UserStatus() {\n  const [isLoggedIn, setIsLoggedIn] = useState(false);\n  \n  useEffect(() => {\n    setIsLoggedIn(localStorage.getItem('token') !== null);\n  }, []);\n  \n  return \u003Cdiv>{isLoggedIn ? '已登录' : '未登录'}\u003C/div>;\n}\n\n// AI 会分析出：\n// 1. 服务端渲染时 localStorage 不可用，默认 false\n// 2. 客户端 hydration 时可能是 true\n// 3. 导致服务端和客户端渲染结果不一致\n\n// AI 建议的解决方案：\nfunction UserStatus() {\n  const [isLoggedIn, setIsLoggedIn] = useState\u003Cboolean | null>(null);\n  \n  useEffect(() => {\n    setIsLoggedIn(localStorage.getItem('token') !== null);\n  }, []);\n  \n  // 初始状态显示加载中，避免 hydration 不匹配\n  if (isLoggedIn === null) {\n    return \u003Cdiv>加载中...\u003C/div>;\n  }\n  \n  return \u003Cdiv>{isLoggedIn ? '已登录' : '未登录'}\u003C/div>;\n}\n",[2650],{"type":26,"tag":527,"props":2651,"children":2652},{"__ignoreMap":7},[2653],{"type":31,"value":2648},{"type":26,"tag":27,"props":2655,"children":2656},{},[2657],{"type":26,"tag":333,"props":2658,"children":2659},{},[2660],{"type":31,"value":2661},"场景 2：Vue 响应式警告",{"type":26,"tag":2514,"props":2663,"children":2668},{"code":2664,"language":2665,"meta":7,"className":2666},"// 警告信息：\n// [Vue warn]: Property \"xxx\" was accessed during render but is not \n// defined on instance.\n\n// 提问方式：\n/**\n * Vue 3 项目中出现这个警告：\n * [Vue warn]: Property \"userInfo\" was accessed during render \n * but is not defined on instance.\n * \n * 组件代码：\n */\n\u003Ctemplate>\n  \u003Cdiv>{{ userInfo.name }}\u003C/div>\n\u003C/template>\n\n\u003Cscript setup>\nconst { data: userInfo } = await useFetch('/api/user');\n\u003C/script>\n\n// AI 分析：\n// 1. useFetch 是异步的，初始渲染时 userInfo 可能是 undefined\n// 2. 直接访问 userInfo.name 会报错\n\n// AI 建议：\n\u003Ctemplate>\n  \u003Cdiv v-if=\"userInfo\">{{ userInfo.name }}\u003C/div>\n  \u003Cdiv v-else>加载中...\u003C/div>\n\u003C/template>\n\n\u003Cscript setup>\nconst { data: userInfo, pending } = await useFetch('/api/user');\n\u003C/script>\n","typescript",[2667],"language-typescript",[2669],{"type":26,"tag":527,"props":2670,"children":2671},{"__ignoreMap":7},[2672],{"type":31,"value":2664},{"type":26,"tag":721,"props":2674,"children":2676},{"id":2675},"_22-后端错误分析",[2677],{"type":31,"value":2678},"2.2 后端错误分析",{"type":26,"tag":27,"props":2680,"children":2681},{},[2682],{"type":26,"tag":333,"props":2683,"children":2684},{},[2685],{"type":31,"value":2686},"场景 1：Node.js 内存问题",{"type":26,"tag":2514,"props":2688,"children":2693},{"code":2689,"language":2690,"meta":7,"className":2691},"// 错误信息：\n// FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - \n// JavaScript heap out of memory\n\n// 提问方式（包含上下文）：\n/**\n * Node.js 服务运行几小时后崩溃，错误信息：\n * FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - \n * JavaScript heap out of memory\n * \n * 服务功能：处理 CSV 文件上传，每次约 100MB\n * \n * 处理代码：\n */\nasync function processCSV(filePath) {\n  const content = fs.readFileSync(filePath, 'utf-8');\n  const rows = content.split('\\n');\n  const results = [];\n  \n  for (const row of rows) {\n    const processed = await processRow(row);\n    results.push(processed);\n  }\n  \n  return results;\n}\n\n// AI 分析会指出：\n// 1. 一次性读取整个文件到内存\n// 2. 所有处理结果累积在 results 数组\n// 3. 建议使用流式处理\n\n// AI 提供的优化方案：\nconst { createReadStream } = require('fs');\nconst { createInterface } = require('readline');\n\nasync function processCSVStream(filePath, onRow) {\n  const fileStream = createReadStream(filePath);\n  const rl = createInterface({\n    input: fileStream,\n    crlfDelay: Infinity\n  });\n  \n  let count = 0;\n  for await (const line of rl) {\n    await onRow(line);\n    count++;\n    \n    // 每处理 1000 行，给 GC 机会运行\n    if (count % 1000 === 0) {\n      await new Promise(r => setImmediate(r));\n    }\n  }\n}\n","javascript",[2692],"language-javascript",[2694],{"type":26,"tag":527,"props":2695,"children":2696},{"__ignoreMap":7},[2697],{"type":31,"value":2689},{"type":26,"tag":27,"props":2699,"children":2700},{},[2701],{"type":26,"tag":333,"props":2702,"children":2703},{},[2704],{"type":31,"value":2705},"场景 2：数据库连接问题",{"type":26,"tag":2514,"props":2707,"children":2710},{"code":2708,"language":2665,"meta":7,"className":2709},"// 错误信息：\n// Error: Connection pool exhausted - \n// max connections (10) already in use\n\n// 提问方式：\n/**\n * PostgreSQL 连接池耗尽错误，高并发时出现：\n * Error: Connection pool exhausted\n * \n * 当前配置：\n * - max connections: 10\n * - 并发请求: 约 100/秒\n * \n * 数据库调用代码：\n */\nasync function getUserData(userId: string) {\n  const client = await pool.connect();\n  try {\n    const user = await client.query('SELECT * FROM users WHERE id = $1', [userId]);\n    const orders = await client.query('SELECT * FROM orders WHERE user_id = $1', [userId]);\n    const payments = await client.query('SELECT * FROM payments WHERE user_id = $1', [userId]);\n    return { user: user.rows[0], orders: orders.rows, payments: payments.rows };\n  } finally {\n    client.release();\n  }\n}\n\n// AI 会分析出多个可能原因并给出综合方案\n",[2667],[2711],{"type":26,"tag":527,"props":2712,"children":2713},{"__ignoreMap":7},[2714],{"type":31,"value":2708},{"type":26,"tag":34,"props":2716,"children":2718},{"id":2717},"第三部分日志分析与问题定位",[2719],{"type":31,"value":2720},"第三部分：日志分析与问题定位",{"type":26,"tag":721,"props":2722,"children":2724},{"id":2723},"_31-结构化日志分析",[2725],{"type":31,"value":2726},"3.1 结构化日志分析",{"type":26,"tag":27,"props":2728,"children":2729},{},[2730],{"type":31,"value":2731},"当面对大量日志时，让 AI 帮你快速定位问题：",{"type":26,"tag":2514,"props":2733,"children":2736},{"code":2734,"language":2690,"meta":7,"className":2735},"// 提问示例：\n/**\n * 分析以下日志，找出导致请求失败的原因：\n * \n * 日志片段：\n */\nconst logs = `\n2024-01-15 10:23:45.123 INFO  [req-abc123] 收到请求 POST /api/order\n2024-01-15 10:23:45.125 DEBUG [req-abc123] 用户认证通过 userId=u001\n2024-01-15 10:23:45.130 DEBUG [req-abc123] 开始库存检查 productId=p001\n2024-01-15 10:23:45.145 DEBUG [req-abc123] 库存检查通过 available=50\n2024-01-15 10:23:45.150 DEBUG [req-abc123] 开始创建订单\n2024-01-15 10:23:45.200 DEBUG [req-abc123] 数据库连接获取成功\n2024-01-15 10:23:45.250 ERROR [req-abc123] 订单创建失败 error=\"deadlock detected\"\n2024-01-15 10:23:45.251 WARN  [req-abc123] 事务回滚\n2024-01-15 10:23:45.255 INFO  [req-abc123] 响应 500 耗时 132ms\n`;\n\n// AI 分析结果会包括：\n// 1. 问题定位：数据库死锁\n// 2. 可能原因：并发订单创建导致锁竞争\n// 3. 排查建议：检查事务隔离级别、锁顺序\n",[2692],[2737],{"type":26,"tag":527,"props":2738,"children":2739},{"__ignoreMap":7},[2740],{"type":31,"value":2734},{"type":26,"tag":721,"props":2742,"children":2744},{"id":2743},"_32-创建调试日志",[2745],{"type":31,"value":2746},"3.2 创建调试日志",{"type":26,"tag":27,"props":2748,"children":2749},{},[2750],{"type":31,"value":2751},"让 AI 帮你生成调试用的日志代码：",{"type":26,"tag":2514,"props":2753,"children":2756},{"code":2754,"language":2665,"meta":7,"className":2755},"// 请求：\n// \"为这个函数添加详细的调试日志，包括入参、关键步骤、耗时和结果\"\n\n// 原代码：\nasync function processOrder(order: Order): Promise\u003COrderResult> {\n  const inventory = await checkInventory(order.items);\n  const payment = await processPayment(order.userId, order.total);\n  const result = await createOrder(order, payment.transactionId);\n  return result;\n}\n\n// AI 生成的带日志版本：\nasync function processOrder(order: Order): Promise\u003COrderResult> {\n  const requestId = generateRequestId();\n  const startTime = performance.now();\n  \n  logger.info({\n    requestId,\n    event: 'order_processing_start',\n    orderId: order.id,\n    userId: order.userId,\n    itemCount: order.items.length,\n    total: order.total\n  });\n  \n  try {\n    // 库存检查\n    const inventoryStart = performance.now();\n    const inventory = await checkInventory(order.items);\n    logger.debug({\n      requestId,\n      event: 'inventory_check_complete',\n      duration: performance.now() - inventoryStart,\n      available: inventory.allAvailable\n    });\n    \n    // 支付处理\n    const paymentStart = performance.now();\n    const payment = await processPayment(order.userId, order.total);\n    logger.debug({\n      requestId,\n      event: 'payment_complete',\n      duration: performance.now() - paymentStart,\n      transactionId: payment.transactionId\n    });\n    \n    // 创建订单\n    const createStart = performance.now();\n    const result = await createOrder(order, payment.transactionId);\n    logger.debug({\n      requestId,\n      event: 'order_created',\n      duration: performance.now() - createStart,\n      resultOrderId: result.orderId\n    });\n    \n    logger.info({\n      requestId,\n      event: 'order_processing_complete',\n      duration: performance.now() - startTime,\n      success: true\n    });\n    \n    return result;\n  } catch (error) {\n    logger.error({\n      requestId,\n      event: 'order_processing_failed',\n      duration: performance.now() - startTime,\n      error: error.message,\n      stack: error.stack\n    });\n    throw error;\n  }\n}\n",[2667],[2757],{"type":26,"tag":527,"props":2758,"children":2759},{"__ignoreMap":7},[2760],{"type":31,"value":2754},{"type":26,"tag":34,"props":2762,"children":2764},{"id":2763},"第四部分性能问题排查",[2765],{"type":31,"value":2766},"第四部分：性能问题排查",{"type":26,"tag":721,"props":2768,"children":2770},{"id":2769},"_41-前端性能分析",[2771],{"type":31,"value":2772},"4.1 前端性能分析",{"type":26,"tag":2514,"props":2774,"children":2777},{"code":2775,"language":2665,"meta":7,"className":2776},"// 场景：页面加载慢，需要分析原因\n\n// 提问方式：\n/**\n * 页面首屏加载需要 5 秒，以下是 Performance API 数据，\n * 请分析性能瓶颈：\n */\nconst performanceData = {\n  // Navigation Timing\n  dns: 50,           // DNS 查询\n  tcp: 100,          // TCP 连接\n  ttfb: 800,         // 首字节时间\n  download: 200,     // 文档下载\n  domParsing: 300,   // DOM 解析\n  domContentLoaded: 1500,\n  load: 5000,\n  \n  // Resource Timing (主要资源)\n  resources: [\n    { name: 'main.js', size: '2.5MB', duration: 1200 },\n    { name: 'vendor.js', size: '1.8MB', duration: 900 },\n    { name: 'styles.css', size: '500KB', duration: 300 },\n    { name: 'hero-image.jpg', size: '3MB', duration: 1500 },\n  ],\n  \n  // Long Tasks\n  longTasks: [\n    { startTime: 1600, duration: 800, name: 'script-evaluation' },\n    { startTime: 2500, duration: 400, name: 'layout' }\n  ]\n};\n\n// AI 会分析出：\n// 1. JS bundle 过大（4.3MB），需要代码分割\n// 2. 图片未优化（3MB 的 hero 图片）\n// 3. 存在长任务阻塞主线程\n// 并给出具体优化建议\n",[2667],[2778],{"type":26,"tag":527,"props":2779,"children":2780},{"__ignoreMap":7},[2781],{"type":31,"value":2775},{"type":26,"tag":721,"props":2783,"children":2785},{"id":2784},"_42-内存泄漏排查",[2786],{"type":31,"value":2787},"4.2 内存泄漏排查",{"type":26,"tag":2514,"props":2789,"children":2792},{"code":2790,"language":2665,"meta":7,"className":2791},"// 场景：应用运行一段时间后变卡\n\n// 提问方式：\n/**\n * React 应用运行一段时间后内存持续增长，以下是 Heap Snapshot 对比：\n * \n * 初始状态：50MB\n * 运行 1 小时后：150MB\n * 运行 2 小时后：280MB\n * \n * Retained objects 增长最快的：\n * - (closure) - 增长 50MB\n * - HTMLDivElement - 增长 30MB\n * - Array - 增长 20MB\n * \n * 可疑代码：\n */\nfunction DataDashboard() {\n  const [data, setData] = useState([]);\n  const chartRef = useRef(null);\n  \n  useEffect(() => {\n    // 每秒刷新数据\n    const interval = setInterval(async () => {\n      const newData = await fetchLatestData();\n      setData(prev => [...prev, ...newData]);  // 数据不断累积\n    }, 1000);\n    \n    // 初始化图表\n    const chart = new Chart(chartRef.current, {\n      // 配置...\n    });\n    \n    // 没有 cleanup！\n  }, []);\n  \n  return \u003Ccanvas ref={chartRef} />;\n}\n\n// AI 会指出：\n// 1. interval 没有清理\n// 2. Chart 实例没有销毁\n// 3. data 无限增长\n// 并提供修复代码\n",[2667],[2793],{"type":26,"tag":527,"props":2794,"children":2795},{"__ignoreMap":7},[2796],{"type":31,"value":2790},{"type":26,"tag":721,"props":2798,"children":2800},{"id":2799},"_43-数据库查询优化",[2801],{"type":31,"value":2802},"4.3 数据库查询优化",{"type":26,"tag":2514,"props":2804,"children":2809},{"code":2805,"language":2806,"meta":7,"className":2807},"-- 场景：查询很慢，让 AI 分析执行计划\n\n-- 提问方式：\n-- 以下查询在数据量大时很慢（orders 表 1000 万行），\n-- 执行计划如下，请分析并优化：\n\nEXPLAIN ANALYZE\nSELECT o.*, u.name, u.email\nFROM orders o\nJOIN users u ON o.user_id = u.id\nWHERE o.status = 'pending'\n  AND o.created_at > '2024-01-01'\nORDER BY o.created_at DESC\nLIMIT 20;\n\n-- 执行计划：\n/*\nSort  (cost=156847.23..157847.23 rows=400000 width=250)\n  Sort Key: o.created_at DESC\n  ->  Hash Join  (cost=1500.00..89847.23 rows=400000 width=250)\n        Hash Cond: (o.user_id = u.id)\n        ->  Seq Scan on orders o  (cost=0.00..85000.00 rows=400000)\n              Filter: ((status = 'pending') AND (created_at > '2024-01-01'))\n        ->  Hash  (cost=1000.00..1000.00 rows=50000 width=100)\n              ->  Seq Scan on users u  (cost=0.00..1000.00 rows=50000)\nPlanning Time: 0.5 ms\nExecution Time: 3500 ms\n*/\n\n-- AI 会分析出问题并建议：\n-- 1. orders 表全表扫描 - 需要复合索引\n-- 2. 建议创建索引：\nCREATE INDEX idx_orders_status_created ON orders(status, created_at DESC);\n\n-- 3. 如果 status 选择性不高，考虑部分索引：\nCREATE INDEX idx_orders_pending ON orders(created_at DESC) \nWHERE status = 'pending';\n","sql",[2808],"language-sql",[2810],{"type":26,"tag":527,"props":2811,"children":2812},{"__ignoreMap":7},[2813],{"type":31,"value":2805},{"type":26,"tag":34,"props":2815,"children":2817},{"id":2816},"第五部分复杂-bug-排查",[2818],{"type":31,"value":2819},"第五部分：复杂 Bug 排查",{"type":26,"tag":721,"props":2821,"children":2823},{"id":2822},"_51-竞态条件",[2824],{"type":31,"value":2825},"5.1 竞态条件",{"type":26,"tag":2514,"props":2827,"children":2830},{"code":2828,"language":2665,"meta":7,"className":2829},"// 场景：偶发的数据不一致问题\n\n// 提问方式：\n/**\n * 用户反馈偶尔看到错误的账户余额，但刷新后正常。\n * 怀疑是竞态条件，以下是相关代码：\n */\nasync function updateBalance(userId: string, amount: number) {\n  // 读取当前余额\n  const user = await db.users.findOne({ id: userId });\n  const newBalance = user.balance + amount;\n  \n  // 更新余额\n  await db.users.update({ id: userId }, { balance: newBalance });\n  \n  // 记录交易\n  await db.transactions.create({\n    userId,\n    amount,\n    balanceAfter: newBalance,\n    createdAt: new Date()\n  });\n  \n  return newBalance;\n}\n\n// 并发调用场景：\n// 用户同时发起两笔交易：+100 和 -50\n// 期望结果：原余额 1000 → 1050\n// 实际可能：原余额 1000 → 1100 或 950\n\n// AI 会分析竞态条件并提供解决方案：\nasync function updateBalanceAtomic(userId: string, amount: number) {\n  // 方案 1：使用数据库原子操作\n  const result = await db.users.findOneAndUpdate(\n    { id: userId },\n    { $inc: { balance: amount } },\n    { returnDocument: 'after' }\n  );\n  \n  await db.transactions.create({\n    userId,\n    amount,\n    balanceAfter: result.balance,\n    createdAt: new Date()\n  });\n  \n  return result.balance;\n}\n\n// 方案 2：使用乐观锁\nasync function updateBalanceOptimistic(userId: string, amount: number) {\n  const maxRetries = 3;\n  \n  for (let i = 0; i \u003C maxRetries; i++) {\n    const user = await db.users.findOne({ id: userId });\n    const newBalance = user.balance + amount;\n    \n    const updated = await db.users.updateOne(\n      { id: userId, version: user.version },\n      { balance: newBalance, version: user.version + 1 }\n    );\n    \n    if (updated.modifiedCount === 1) {\n      await db.transactions.create({...});\n      return newBalance;\n    }\n    \n    // 版本冲突，重试\n    await sleep(10 * (i + 1));\n  }\n  \n  throw new Error('Update failed after retries');\n}\n",[2667],[2831],{"type":26,"tag":527,"props":2832,"children":2833},{"__ignoreMap":7},[2834],{"type":31,"value":2828},{"type":26,"tag":721,"props":2836,"children":2838},{"id":2837},"_52-分布式系统问题",[2839],{"type":31,"value":2840},"5.2 分布式系统问题",{"type":26,"tag":2514,"props":2842,"children":2845},{"code":2843,"language":2665,"meta":7,"className":2844},"// 场景：微服务间的数据不一致\n\n// 提问方式：\n/**\n * 订单服务和库存服务偶尔出现数据不一致：\n * - 订单显示已创建\n * - 库存未扣减\n * \n * 当前流程：\n */\n// Order Service\nasync function createOrder(orderData) {\n  // 1. 调用库存服务扣减库存\n  await inventoryService.deduct(orderData.items);\n  \n  // 2. 创建订单\n  const order = await orderRepository.create(orderData);\n  \n  // 3. 发送订单创建事件\n  await eventBus.publish('order.created', order);\n  \n  return order;\n}\n\n// 问题分析：如果步骤 2 或 3 失败，库存已经扣减但订单未创建\n\n// AI 会建议使用 Saga 模式或事务发件箱模式\n",[2667],[2846],{"type":26,"tag":527,"props":2847,"children":2848},{"__ignoreMap":7},[2849],{"type":31,"value":2843},{"type":26,"tag":34,"props":2851,"children":2853},{"id":2852},"第六部分ai-调试工作流",[2854],{"type":31,"value":2855},"第六部分：AI 调试工作流",{"type":26,"tag":721,"props":2857,"children":2859},{"id":2858},"_61-我的调试流程",[2860],{"type":31,"value":2861},"6.1 我的调试流程",{"type":26,"tag":2514,"props":2863,"children":2865},{"code":2864},"┌────────────────────────────────────────────────────────────┐\n│                    AI 辅助调试工作流                         │\n├────────────────────────────────────────────────────────────┤\n│                                                            │\n│  Step 1: 问题收集                                          │\n│  ├── 复制完整错误信息                                       │\n│  ├── 截图相关日志                                          │\n│  └── 记录复现步骤                                          │\n│                                                            │\n│  Step 2: 快速分析                                          │\n│  ├── 将错误信息发给 AI                                      │\n│  ├── 获取可能原因列表                                       │\n│  └── 评估哪些最可能                                         │\n│                                                            │\n│  Step 3: 深入调查                                          │\n│  ├── 根据 AI 建议添加日志/断点                              │\n│  ├── 收集更多信息                                          │\n│  └── 再次询问 AI（带新信息）                                │\n│                                                            │\n│  Step 4: 验证修复                                          │\n│  ├── AI 生成修复代码                                        │\n│  ├── 人工审查确认                                          │\n│  └── 测试验证                                               │\n│                                                            │\n│  Step 5: 预防措施                                          │\n│  ├── AI 建议类似问题的预防方法                              │\n│  ├── 添加相关测试用例                                       │\n│  └── 更新文档/知识库                                        │\n│                                                            │\n└────────────────────────────────────────────────────────────┘\n",[2866],{"type":26,"tag":527,"props":2867,"children":2868},{"__ignoreMap":7},[2869],{"type":31,"value":2864},{"type":26,"tag":721,"props":2871,"children":2873},{"id":2872},"_62-调试对话模板",[2874],{"type":31,"value":2875},"6.2 调试对话模板",{"type":26,"tag":2514,"props":2877,"children":2880},{"code":2878,"language":270,"meta":7,"className":2879},"## 第一轮：问题描述\n\n我遇到了一个问题：[简述问题]\n\n错误信息：\n",[2518],[2881],{"type":26,"tag":527,"props":2882,"children":2883},{"__ignoreMap":7},[2884],{"type":31,"value":2878},{"type":26,"tag":27,"props":2886,"children":2887},{},[2888],{"type":26,"tag":2528,"props":2889,"children":2890},{},[2891],{"type":31,"value":2892},"粘贴完整错误",{"type":26,"tag":2514,"props":2894,"children":2896},{"code":2895},"\n相关代码：\n```javascript\n[粘贴代码]\n",[2897],{"type":26,"tag":527,"props":2898,"children":2899},{"__ignoreMap":7},[2900],{"type":31,"value":2895},{"type":26,"tag":394,"props":2902,"children":2903},{},[],{"type":26,"tag":34,"props":2905,"children":2907},{"id":2906},"第二轮补充信息",[2908],{"type":31,"value":2909},"第二轮：补充信息",{"type":26,"tag":27,"props":2911,"children":2912},{},[2913],{"type":31,"value":2914},"根据你的建议，我添加了日志，发现：",{"type":26,"tag":41,"props":2916,"children":2917},{},[2918,2926],{"type":26,"tag":45,"props":2919,"children":2920},{},[2921],{"type":26,"tag":2528,"props":2922,"children":2923},{},[2924],{"type":31,"value":2925},"发现 1",{"type":26,"tag":45,"props":2927,"children":2928},{},[2929],{"type":26,"tag":2528,"props":2930,"children":2931},{},[2932],{"type":31,"value":2933},"发现 2",{"type":26,"tag":27,"props":2935,"children":2936},{},[2937,2939,2944],{"type":31,"value":2938},"这是否说明问题出在 ",{"type":26,"tag":2528,"props":2940,"children":2941},{},[2942],{"type":31,"value":2943},"你的猜测",{"type":31,"value":2945},"？",{"type":26,"tag":394,"props":2947,"children":2948},{},[],{"type":26,"tag":34,"props":2950,"children":2952},{"id":2951},"第三轮确认修复",[2953],{"type":31,"value":2954},"第三轮：确认修复",{"type":26,"tag":27,"props":2956,"children":2957},{},[2958],{"type":31,"value":2959},"我按照你的建议修改了代码：",{"type":26,"tag":2514,"props":2961,"children":2964},{"code":2962,"language":2690,"meta":7,"className":2963},"[粘贴修改后的代码]\n",[2692],[2965],{"type":26,"tag":527,"props":2966,"children":2967},{"__ignoreMap":7},[2968],{"type":31,"value":2962},{"type":26,"tag":27,"props":2970,"children":2971},{},[2972],{"type":31,"value":2973},"请确认这个修复是否正确，以及是否有其他潜在问题。",{"type":26,"tag":394,"props":2975,"children":2976},{},[],{"type":26,"tag":34,"props":2978,"children":2980},{"id":2979},"第四轮预防",[2981],{"type":31,"value":2982},"第四轮：预防",{"type":26,"tag":27,"props":2984,"children":2985},{},[2986],{"type":31,"value":2987},"这个问题已解决。请建议：",{"type":26,"tag":324,"props":2989,"children":2990},{},[2991,2996,3001],{"type":26,"tag":45,"props":2992,"children":2993},{},[2994],{"type":31,"value":2995},"如何防止类似问题再次发生？",{"type":26,"tag":45,"props":2997,"children":2998},{},[2999],{"type":31,"value":3000},"应该添加什么测试用例？",{"type":26,"tag":45,"props":3002,"children":3003},{},[3004],{"type":31,"value":3005},"有什么最佳实践可以参考？",{"type":26,"tag":2514,"props":3007,"children":3009},{"code":3008},"\n## 结语：AI 是放大器，不是替代品\n\nAI 调试工具能够显著加速问题排查过程，但它不能替代你的思考。最有价值的能力组合是：\n\n- **你的领域知识** + **AI 的广博见识**\n- **你对项目的理解** + **AI 的分析能力**\n- **你的判断力** + **AI 的执行速度**\n\n调试的本质是假设-验证的循环。AI 帮你更快地生成假设、更高效地验证假设，但做出最终判断的还是你。\n\n学会与 AI 高效协作调试，不是依赖 AI 给你答案，而是让 AI 帮你更快地找到自己的答案。\n\n---\n\n## 参考资源\n\n- [Chrome DevTools 官方文档](https://developer.chrome.com/docs/devtools)\n- [Node.js 调试指南](https://nodejs.org/en/docs/guides/debugging-getting-started)\n- [React DevTools 使用指南](https://react.dev/learn/react-developer-tools)\n",[3010],{"type":26,"tag":527,"props":3011,"children":3012},{"__ignoreMap":7},[3013],{"type":31,"value":3008},{"title":7,"searchDepth":263,"depth":263,"links":3015},[3016,3017,3018,3023,3027,3032,3036,3040,3041,3042],{"id":2398,"depth":266,"text":2401},{"id":2404,"depth":266,"text":2407},{"id":2425,"depth":266,"text":2428,"children":3019},[3020,3021,3022],{"id":2431,"depth":263,"text":2434},{"id":2509,"depth":263,"text":2512},{"id":2675,"depth":263,"text":2678},{"id":2717,"depth":266,"text":2720,"children":3024},[3025,3026],{"id":2723,"depth":263,"text":2726},{"id":2743,"depth":263,"text":2746},{"id":2763,"depth":266,"text":2766,"children":3028},[3029,3030,3031],{"id":2769,"depth":263,"text":2772},{"id":2784,"depth":263,"text":2787},{"id":2799,"depth":263,"text":2802},{"id":2816,"depth":266,"text":2819,"children":3033},[3034,3035],{"id":2822,"depth":263,"text":2825},{"id":2837,"depth":263,"text":2840},{"id":2852,"depth":266,"text":2855,"children":3037},[3038,3039],{"id":2858,"depth":263,"text":2861},{"id":2872,"depth":263,"text":2875},{"id":2906,"depth":266,"text":2909},{"id":2951,"depth":266,"text":2954},{"id":2979,"depth":266,"text":2982},"content:topics:ai:ai-debugging-troubleshooting-guide.md","topics/ai/ai-debugging-troubleshooting-guide.md","topics/ai/ai-debugging-troubleshooting-guide",{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"topic":5,"author":11,"tags":3047,"image":17,"imageQuery":18,"pexelsPhotoId":19,"pexelsUrl":20,"featured":6,"readingTime":21,"body":3048,"_type":270,"_id":271,"_source":272,"_file":273,"_stem":274,"_extension":275},[13,14,15,16],{"type":23,"children":3049,"toc":3233},[3050,3054,3058,3073,3077,3081,3145,3149,3153,3157,3161,3205,3209],{"type":26,"tag":27,"props":3051,"children":3052},{},[3053],{"type":31,"value":32},{"type":26,"tag":34,"props":3055,"children":3056},{"id":36},[3057],{"type":31,"value":39},{"type":26,"tag":41,"props":3059,"children":3060},{},[3061,3065,3069],{"type":26,"tag":45,"props":3062,"children":3063},{},[3064],{"type":31,"value":49},{"type":26,"tag":45,"props":3066,"children":3067},{},[3068],{"type":31,"value":54},{"type":26,"tag":45,"props":3070,"children":3071},{},[3072],{"type":31,"value":59},{"type":26,"tag":27,"props":3074,"children":3075},{},[3076],{"type":31,"value":64},{"type":26,"tag":34,"props":3078,"children":3079},{"id":67},[3080],{"type":31,"value":67},{"type":26,"tag":71,"props":3082,"children":3083},{},[3084,3098],{"type":26,"tag":75,"props":3085,"children":3086},{},[3087],{"type":26,"tag":79,"props":3088,"children":3089},{},[3090,3094],{"type":26,"tag":83,"props":3091,"children":3092},{},[3093],{"type":31,"value":87},{"type":26,"tag":83,"props":3095,"children":3096},{},[3097],{"type":31,"value":92},{"type":26,"tag":94,"props":3099,"children":3100},{},[3101,3112,3123,3134],{"type":26,"tag":79,"props":3102,"children":3103},{},[3104,3108],{"type":26,"tag":101,"props":3105,"children":3106},{},[3107],{"type":31,"value":105},{"type":26,"tag":101,"props":3109,"children":3110},{},[3111],{"type":31,"value":110},{"type":26,"tag":79,"props":3113,"children":3114},{},[3115,3119],{"type":26,"tag":101,"props":3116,"children":3117},{},[3118],{"type":31,"value":118},{"type":26,"tag":101,"props":3120,"children":3121},{},[3122],{"type":31,"value":123},{"type":26,"tag":79,"props":3124,"children":3125},{},[3126,3130],{"type":26,"tag":101,"props":3127,"children":3128},{},[3129],{"type":31,"value":131},{"type":26,"tag":101,"props":3131,"children":3132},{},[3133],{"type":31,"value":136},{"type":26,"tag":79,"props":3135,"children":3136},{},[3137,3141],{"type":26,"tag":101,"props":3138,"children":3139},{},[3140],{"type":31,"value":144},{"type":26,"tag":101,"props":3142,"children":3143},{},[3144],{"type":31,"value":149},{"type":26,"tag":27,"props":3146,"children":3147},{},[3148],{"type":31,"value":154},{"type":26,"tag":34,"props":3150,"children":3151},{"id":157},[3152],{"type":31,"value":160},{"type":26,"tag":27,"props":3154,"children":3155},{},[3156],{"type":31,"value":165},{"type":26,"tag":34,"props":3158,"children":3159},{"id":168},[3160],{"type":31,"value":171},{"type":26,"tag":41,"props":3162,"children":3164},{"className":3163},[175],[3165,3173,3181,3189,3197],{"type":26,"tag":45,"props":3166,"children":3168},{"className":3167},[180],[3169,3172],{"type":26,"tag":183,"props":3170,"children":3171},{"disabled":185,"type":186},[],{"type":31,"value":189},{"type":26,"tag":45,"props":3174,"children":3176},{"className":3175},[180],[3177,3180],{"type":26,"tag":183,"props":3178,"children":3179},{"disabled":185,"type":186},[],{"type":31,"value":198},{"type":26,"tag":45,"props":3182,"children":3184},{"className":3183},[180],[3185,3188],{"type":26,"tag":183,"props":3186,"children":3187},{"disabled":185,"type":186},[],{"type":31,"value":207},{"type":26,"tag":45,"props":3190,"children":3192},{"className":3191},[180],[3193,3196],{"type":26,"tag":183,"props":3194,"children":3195},{"disabled":185,"type":186},[],{"type":31,"value":216},{"type":26,"tag":45,"props":3198,"children":3200},{"className":3199},[180],[3201,3204],{"type":26,"tag":183,"props":3202,"children":3203},{"disabled":185,"type":186},[],{"type":31,"value":225},{"type":26,"tag":27,"props":3206,"children":3207},{},[3208],{"type":31,"value":230},{"type":26,"tag":41,"props":3210,"children":3211},{},[3212,3219,3226],{"type":26,"tag":45,"props":3213,"children":3214},{},[3215],{"type":26,"tag":238,"props":3216,"children":3217},{"href":240},[3218],{"type":31,"value":243},{"type":26,"tag":45,"props":3220,"children":3221},{},[3222],{"type":26,"tag":238,"props":3223,"children":3224},{"href":249},[3225],{"type":31,"value":252},{"type":26,"tag":45,"props":3227,"children":3228},{},[3229],{"type":26,"tag":238,"props":3230,"children":3231},{"href":258},[3232],{"type":31,"value":261},{"title":7,"searchDepth":263,"depth":263,"links":3234},[3235,3236,3237,3238],{"id":36,"depth":266,"text":39},{"id":67,"depth":266,"text":67},{"id":157,"depth":266,"text":160},{"id":168,"depth":266,"text":171},1780105148384]