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