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