systematic-debugging

A step-by-step debugging guide for finding the real cause of software bugs before changing code.

In plain words
What is it for?
Use it when tests or CI fail, program output is wrong, an interface or screen behaves unexpectedly, or a change causes a regression.
Why use it?
It prevents guesswork and unverified fixes by requiring a stable reproduction, careful reading of errors, and evidence about where the problem occurs.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/systematic-debugging
Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill systematic-debugging
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,952 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01952
Opus 5 $0.00015 $0.00976
Sonnet 5 $0.00006 $0.00390
Haiku 4.5 $0.00003 $0.00195

Measured 2d ago against content hash b7739a4149ca, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

systematic-debugging scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/systematic-debugging/SKILL.md · 146 lines

How it starts

The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.

系统化调试

何时用

  • 运行测试时出现 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,数据链路静默损坏

Read the full file on GitHub · 146 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 146 lines · 31 tokens per session scan A b7739a4149ca

Subscribe to this mod's changes

systematic-debugging is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (6 stars, last pushed 2mo ago), licensed MIT. It adds 31 tokens to every session and 1,952 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

chinese-git-workflow

国内 Git 平台配置参考——Gitee、Coding.net、极狐 GitLab、CNB 的 SSH/HTTPS/凭据/CI 接入差异与镜像同步配置。仅在用户显式 /chinese-git-workflow 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 69 tokens

brainstorming

在任何创造性工作之前必须使用此技能——创建功能、构建组件、添加功能或修改行为。在实现之前先探索用户意图、需求和设计。.

jnMetaCode/superpowers-zh · 40 tokens

chinese-code-review

中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-commit-conventions

中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 65 tokens

chinese-documentation

中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

systematic-debugging

Skill "systematic-debugging" from jnMetaCode/superpowers-zh, covering 系统化调试, 概述, 铁律, 何时使用 and 四个阶段.

jnMetaCode/superpowers-zh · 24 tokens