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