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