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