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