systematic-debugging
Skill7 starsChanged 5 months agoMITView on GitHub
遇到 bug、测试失败、行为异常时使用。先定位根因,再改代码,禁止瞎试。
190 other projects use a version of this.
Adopted by
Most recently taken up by
- DemonDamon/AgenticXtheir own version, first seen Nov 9, 2026
- chrysogonus/power-agentstheir own version, first seen Nov 8, 2026
- willy92wins/DayZ-Modding-Knowledge-Packtheir own version, first seen Nov 8, 2026
- roundpilot/superpowers-antigravitytheir own version, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- lingyired/status-triotheir own version, first seen Nov 8, 2026
Used with
Projects with it also use chinese-code-review, chinese-commit-conventions and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Leodorareluctant259Skillchinese-code-review
中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
Also in 8 projects that use this
Leodorareluctant259Skillchinese-commit-conventions
中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
Also in 8 projects that use this
obraSkilldiagnosing-superpowers
Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.
Also in 20 projects that use this
mjunaidcaSkillbuilding-chatgpt-apps
Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers. Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response metadata, and Developer Mode configuration. NOT when building standard MCP servers without widgets (use building-mcp-servers skill instead).
Also in 4 projects that use this
mjunaidcaSkillbuilding-chat-interfaces
Build AI chat interfaces with custom backends, authentication, and context injection. Use when integrating chat UI with AI agents, adding auth to chat, injecting user/page context, or implementing httpOnly cookie proxies. Covers ChatKitServer, useChatKit, and MCP auth patterns. NOT when building simple chatbots without persistence or custom agent integration.
Also in 4 projects that use this
- +2 more from Leodorareluctant259
- +5 more from mjunaidca
Other versions190 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 190
- obra/superpowers★ 314ksame name
- NousResearch/hermes-agent★ 262ksame name
- open-metadata/OpenMetadata★ 16ksame name
- jnMetaCode/superpowers-zh★ 8.4ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- openai/plugins★ 7.8ksame name
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- farm-fe/farm★ 5.6ksame name
- microsoft/FluidFramework★ 4.9ksame name
180 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- api-designSkill
- chinese-commitSkill
- ci-cd-pipelineSkill
- cocos2dx-luaSkill
- cocos-creator-adaptationSkill
- cocos-creator-bundleSkill
- cocos-creator-drawcallSkill
- cocos-creator-hotupdateSkill
- cocos-creatorSkill
- cocos-creator-tween-animSkill
- cocos-creator-ui-listSkill
- code-review-selfSkill
- concurrency-safetySkill
- core-disciplineSkill
- database-safetySkill
- docker-best-practicesSkill
- domestic-stackSkill
- error-handlingSkill
- frontend-best-practicesSkill
- game-assets-memorySkill
- game-mathSkill
- game-netcodeSkill
- game-performanceSkill
- gameplay-architectureSkill
- godot-gdscriptSkill
- go-idiomsSkill
- input-validationSkill
- integration-testingSkill
- large-repo-refactorSkill
- legacy-safe-editSkill
- naming-thingsSkill
- node-best-practicesSkill
- performance-profilingSkill
- pr-descriptionSkill
- python-idiomsSkill
- requirement-deliverySkill
- rust-safetySkill
- secrets-handlingSkill
- security-reviewSkill
- shell-scripting-safeSkill
- test-data-managementSkill
- test-drivenSkill
- unity-csharpSkill
- unreal-cppSkill
- writing-docsSkill
The file
Files
系统化调试
何时用
- 运行测试时出现
FAILED/ERROR,或 CI 红了。 - 程序行为与预期不符:输出值错误、接口返回异常状态码、UI 渲染出错。
- 改了一处代码后原本正常的功能突然挂掉(回归)。
- 看到报错信息、异常堆栈、日志中的
Exception/panic/Segfault,不知道从哪里下手。
核心规则
1. 先复现
规则: 在动任何代码之前,先稳定复现问题,写下复现步骤与"期望行为 vs 实际行为"。
为什么: AI 拿到 bug 描述后会立刻联想到"可能是 X 原因"并直接改代码——但如果问题根本无法稳定复现,改动就是在打空拳。更常见的事故是:AI 改了某处,恰好该次运行没触发 bug,就宣称"已修复",下次复现时问题依然存在。
怎么做:
- 明确记录触发条件:输入数据、环境变量、调用顺序、并发时序等。
- 写一个最小复现脚本或测试用例,能稳定触发问题再继续。
- 若问题无法稳定复现,先补充日志/断言,下一次触发时收集更多信息,而非盲猜。
2. 读真实报错
规则: 逐字阅读错误信息与完整堆栈,定位第一处出错的文件行号,不跳过、不脑补。
为什么: AI 经常只看错误的最后一行(如 NullPointerException),然后凭直觉猜"是不是哪个对象没初始化"并随意修改。真正的根因往往藏在堆栈中部——例如某个中间件吞掉了原始异常、某个工厂方法返回了错误类型——只读最后一行会让修复方向完全偏离。
怎么做:
- 从堆栈的最顶层(第一次抛出点)开始读,而不是从底层的框架代码开始。
- 遇到"Caused by"或"wrapped"链式异常,追到链条的根源。
- 把报错的关键词(函数名、行号、错误码)直接复制到搜索或代码跳转,不凭记忆定位。
3. 二分缩小范围
规则: 用打印/断点/注释二分法,把问题缩小到最小代码段,再下结论。
为什么: AI 倾向于在读了几十行代码后就"觉得问题在这里",跳过验证直接改。这种直觉经常错:真实 bug 往往在你以为不可能出错的地方。不二分就不改,是避免"修了半天发现改错位置"的唯一可靠方法。
怎么做:
- 把可疑范围一分为二:注释掉后半段,确认前半段输出正确,再检查后半段。
- 在关键中间点插入
print/console.log/assert,确认数据在此时的真实状态。 - 重复缩小,直到能用不超过 10 行代码稳定触发问题,再动手修复。
4. 找根因,不贴补丁
规则: 能解释"为什么会错"之后再动手改代码。禁止用 try/except 吞异常、随机调参、加 || null 等掩盖症状的做法。
为什么: AI 面对报错时最常见的逃生路线就是在外层套一个 try/except,让异常不再抛出,然后声称"问题解决了"。但根因没消除:数据仍然损坏、状态仍然不一致,只是沉默了。这类"修复"在生产环境会演变成更难排查的数据问题或静默错误。
怎么做:
- 改代码前用一句话写下根因假设:「变量
user在首次调用时为None,因为db.find()在记录不存在时返回None而非抛出异常。」 - 修复根因(加校验、修初始化逻辑),而不是在调用处加
try/except掩盖。 - 若确实需要捕获异常,必须在
except块里做有意义的处理(记录、回滚、向上重抛),绝不能空块或仅pass。
5. 改完验证
规则: 用最初的复现步骤逐一确认问题已修复,并确认没有引入新的失败。
为什么: AI 改完代码后习惯性地说"应该好了",但没有真正跑一遍。或者只跑了新加的测试,没跑已有的回归测试集,结果修了一个 bug、破了三个已有功能。
怎么做:
- 重新执行第 1 步写下的复现步骤,确认实际行为与期望行为一致。
- 跑完整测试套件(不只是相关测试),确认无新的
FAILED。 - 若引入了新失败,视为新 bug,回到第 1 步重新走流程,不要在同一次修改里叠加多个"顺手修复"。
正例 / 反例
反例:用 try/except 吞异常声称"已修复"
# 反例 — AI 用空 except 消灭报错,根因未解决
def get_user_age(user_id: int) -> int:
try:
user = db.find_user(user_id)
return user["age"] # user 为 None 时会 TypeError
except Exception:
pass # ❌ 吞掉异常,调用方收到 None,数据链路静默损坏# 正例 — 定位根因:db.find_user 在记录不存在时返回 None,修复初始化逻辑
def get_user_age(user_id: int) -> int:
user = db.find_user(user_id)
if user is None:
raise ValueError(f"用户 {user_id} 不存在") # ✅ 明确报错,调用方能感知并处理
return user["age"]反例:不读堆栈、凭直觉改错位置
# 错误日志:
# AttributeError: 'NoneType' object has no attribute 'email'
# File "app/views.py", line 42, in send_welcome
# msg = build_email(request.user)
# File "app/email.py", line 17, in build_email
# return Template(user.email) # ← 第一次出错点在这里
# 反例 — AI 只看到 AttributeError 就在视图层加了防御
def send_welcome(request):
if request.user is None: # ❌ request.user 其实从不为 None,
return # 根因是 build_email 接收了未登录状态下的匿名对象
...# 正例 — 读完堆栈,定位到 build_email 第 17 行,找到根因:
# 匿名用户对象没有 email 属性,而非 request.user 为 None
def build_email(user):
if not hasattr(user, "email") or user.email is None:
raise ValueError("无法为匿名用户构建邮件") # ✅ 在真正出错点做校验
return Template(user.email)自查清单
- 已写下稳定的复现步骤,并能在改代码前稳定触发问题。
- 已逐字读完完整堆栈,定位到第一处出错的文件与行号。
- 已通过二分或打印确认问题所在的最小代码段,而非凭直觉猜测。
- 能用一句话解释根因("因为 X,所以 Y"),而不只是描述症状。
- 修复方式针对根因,没有用空
except、|| null、if err != nil { return }等手段掩盖问题。 - 改完后重新执行了最初的复现步骤,确认实际行为与期望一致。
- 运行了完整测试套件,确认没有引入新的失败。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

