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