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