structured-debugging
できること
このスキルは、推測せずに難しいバグを解決するための方法です。予想外の動作、不安定なテスト、簡単な修正では解決しなかった問題に直面している開発者やエージェント向けです。
使う場面
- ✓バグが難しく、最初の修正が効かなかったとき。
- ✓テストが不安定、または動作が起こりえないように見えるとき。
- ✓証拠がないのに、外部のシステムのせいにしたくなったとき。
スキルのリンク
https://github.com/QwenLM/qwen-code/blob/main/.qwen/skills/structured-debugging/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このバグは時々しか起きず、簡単な修正は効きませんでした。段階を追ってデバッグする手伝いをしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、まず具体的な仮説を書き出し、的を絞ったログや確認を追加して実行します。その結果を使って原因を絞り込みます。難しいバグでは、セッションをまたいでメモを残し、原因が確認されてから修正します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Structured Debugging
When debugging hard issues, the natural instinct is to form a theory and immediately apply a fix. This fails more often than it works. The fix addresses the wrong cause, adds complexity, creates false confidence, and obscures the real issue. Worse, after several failed attempts you lose track of what's been tried and start guessing randomly.
This methodology replaces guessing with a disciplined cycle that converges on the root cause. Each iteration narrows the search space. It's slower per attempt but dramatically faster overall because you stop wasting runs on wrong theories.
The Cycle
1. Hypothesize
Before touching code, write down what you think is happening and why. Be specific about the expected state at each step in the execution path.
Bad: "Something is wrong with the wait loop." Good: "The leader hangs because
hasActiveTeammates() returns true after all agents have reported completed,
likely because terminal status isn't being set on the agent object after the
backend process exits."
For bugs you expect to take more than one round, create a side note file for the investigation in whichever location the project uses for such notes.
Write your hypothesis there. This file persists across conversation turns and even across sessions — it's your investigation journal.
2. Design Instrumentation
Add targeted debug logs or assertions at the exact decision points that would confirm or reject your hypothesis. Think about what data you need to see.
Don't scatter console.log everywhere. Identify the 2-3 places where your
hypothesis makes a testable prediction, and instrument those.
Prefer logging values (return codes, payload contents, stream types, message bodies, env state) over presence checks ("was this function called?", "was this branch taken?"). Code-path traces tell you what ran; data traces tell you what it ran on. Most non-trivial bugs are correct code processing wrong data.
Ask yourself: "If my hypothesis is correct, what will I see at point X? If it's wrong, what will I see instead?"
3. Verify Data Collection
Before running, confirm that your instrumentation output will actually be captured and accessible.
Common traps:
- stderr discarded by
2>/dev/nullin the test command - Process killed before flush (logs lost)
- Logging to a file in a directory that doesn't exist
- Output piped through something that truncates it
- Looking at log files from a previous run, not the current one
A test run that produces no data is wasted.
4. Run and Observe
Execute the test. Read the actual output — every line of it. Don't assume what it says.
When the data contradicts your hypothesis, believe the data. Don't rationalize it away. The whole point of this step is to let reality override your theory.
5. Document Findings
Update the side note with:
- What the data showed (quote specific log lines)
- What was confirmed vs. disproved
- Updated hypothesis for the next iteration
This is critical for not losing context across attempts. Hard bugs typically take 3-5 rounds. Without notes, you'll forget what you ruled out and waste runs re-checking things.
6. Iterate
Update the hypothesis based on the new evidence. Go back to step 2. Each round should narrow the search space.
If you're not making progress after 3 rounds, step back and question your assumptions. The bug might be in a layer you haven't considered.
Failure Modes to Avoid
These are the specific traps this methodology is designed to prevent. When you notice yourself drifting toward any of them, stop and return to the cycle.
Jumping to fixes without evidence
The most common failure. You have a plausible theory, so you "fix" it and run again. If the theory was wrong, you've added complexity, wasted a test run, and possibly introduced a new bug. The side note should always show "hypothesis verified by [specific data]" before any fix is applied.
Blaming external systems
"The model is hallucinating." "The API is flaky." "The library has a bug." These conclusions feel satisfying because they put the problem outside your control. They're also usually wrong.
Before blaming an external system, inspect what it actually received. A model that appears to hallucinate may be responding rationally to stale data you didn't know was there. An API that appears flaky may be receiving malformed requests. Look at the inputs, not just the outputs.
Inspecting code paths but not data
You
よくある質問
なぜすぐに修正を試さないのですか?
推測による修正は、間違った原因を直し、複雑さを増やすことが多いため、この方法ではまず検証可能な仮説を求めます。
メモは残りますか?
はい、難しいバグでは、セッションをまたいで残る調査の記録を保管します。
1つのプログラミング言語だけが対象ですか?
いいえ、複雑なシステムの中で問題を追跡するための一般的な方法です。
詳細
作者による元の説明
Hypothesis-driven debugging methodology for hard bugs. Use this skill whenever you're investigating non-trivial bugs, unexpected behavior, flaky tests, or tracing issues through complex systems. Activate proactively when debugging requires more than a quick glance — especially when the first attempt at a fix didn't work, when behavior seems "impossible", or when you're tempted to blame an external system (model, API, library) without evidence.
repo: QwenLM/qwen-code
人気
- GitHubのスター
- 29k
- ランキング
- #9770
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
codegraph
29kエージェントが、索引化されたコードベースを、呼び出しグラフ、依存関係、デッドコード、ホットスポット、意味検索を通じて分析できるよう支援します。
qwen-code-claw
29kエージェントが、コードベースの理解、バグ修正、リファクタリング、新しいプロジェクトの生成などのコーディング作業を、Qwen Codeに任せられるよう支援します。
tmux-real-user-testing
29kエージェントが、tmux内でターミナルアプリを実際のユーザーのように試せるよう支援します。各操作の画面のスナップショットを付けた、読みやすい手順のログを保存します。
generated-ui
29kエージェントが、対話型の計算ツール、シミュレーター、比較表をチャットの中に表示し、入力を変えて結果を確かめられるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。