debug

A step-by-step guide for finding and fixing software bugs by reproducing them, testing competing explanations, correcting the underlying cause, and rerunning the original case.

In plain words
What is it for?
Use it to create minimal reproductions, collect distinguishing evidence, inspect changes, make focused fixes, and verify them with tests.
Why use it?
It prevents guesses and unrelated patches from hiding the real problem or introducing new ones.

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/caiwuu/riot/debug
Any agent
npx skills add caiwuu/Riot --skill debug
Clone the repo
git clone --depth 1 https://github.com/caiwuu/Riot

Made for: Claude Code, Codex.

Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 718 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.00052 $0.00718
Opus 5 $0.00026 $0.00359
Sonnet 5 $0.00010 $0.00144
Haiku 4.5 $0.00005 $0.00072

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

Security

Grade A, and why

debug 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.

crates/riot-kernel/builtin/skills/debug/SKILL.md · 49 lines

What it actually says

调试

顺序是硬的:复现 → 定位 → 修 → 验证。跳过复现直接改,修完也不知道 修没修好;「看起来像这个问题」的改动堆几层,代码比原来更难懂。

1. 复现

  • 拿到最小复现路径:什么输入、什么操作、期望什么、实际什么。
  • 按用户的描述复现不出来时,先对齐环境差异(版本、配置、数据), 不要按「大概是这个意思」开修。
  • 间歇性的 bug 先想并发、时序、未初始化、缓存。复现率不到 100% 也要 拿到一个「多跑几次必现」的脚本——没有它,最后没法证明修好了。

2. 定位:让证据淘汰假设

  • 看到症状先列 2-3 个候选假设,再找能区分它们的证据——不是找 支持第一个假设的证据。
  • 二分收敛:注释掉一半、在中间点打日志、git bisect。每一步的目标 是砍掉一半可能性,而不是「再看一眼」。
  • [约束] 打日志要打变量的值,不是「到这里了」。执行路径只占 bug 的少数,多数 bug 错在数据不在路径。
  • git 历史是证据:git log -p -- 那个文件 看这行什么时候变的、当时 的提交想干什么。「以前是好的」这类 bug,bisect 比读代码快得多。

3. 修

  • 根因,不是在症状处打补丁。上游给了空值,在下游判空只是把 炸点挪远了,还把上游的问题盖住了。
  • 最小改动。定位过程中看到的其它可疑点,记下来告诉用户,不要一起 改——一起改就分不清哪个改动起了作用。

4. 验证

  • 用第 1 步的原始复现路径再跑一遍,不是用「我觉得等价」的路径。
  • 跑一遍相关测试,确认没修出新的问题。
  • 收尾回答两个问题:同类的地方还有吗(同一个错误模式往往不止 一处,grep 一把);要不要加个测试守住这里(这个 bug 能溜进来, 说明现在没有测试拦它)。

调试自己刚写的代码时

嫌疑最大的不是代码,是自己对「输入长什么样」「这个 API 行为如何」的 假设。打印真实输入和中间值对着看,比反复重读代码快。

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 · 49 lines · 52 tokens per session scan A 630ed39a9fb8

Subscribe to this mod's changes

debug is a skill published in the GitHub repository caiwuu/Riot (2 stars, last pushed 2d ago), licensed MIT. It adds 52 tokens to every session and 718 once invoked, about $0.0003 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

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens