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