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