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