本文へスキップ
Skillpedia
一般的なプログラミング6.1k · #14428

systematic-debugging

できること

このスキルは、デバッグのための四つの段階の方法を定めます。根本原因を見つける、動いているコードと比べる、仮説を立てる、そして直す、の順です。本当の問題を解決する修正がほしい開発者のためのものです。

使う場面

  • ✓バグや予期しない動作を調べているとき。
  • ✓テストが失敗し続けていて、手早い修正がうまくいかないとき。
  • ✓エラーを発生源までさかのぼりたいとき。

スキルのリンク

https://github.com/ChrisWiles/claude-code-showcase/blob/main/.claude/skills/systematic-debugging/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/ChrisWiles/claude-code-showcase/blob/main/.claude/skills/systematic-debugging/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“チェックアウトのテストは金曜日だけ失敗します。何かを変える前に、根本原因を調べてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、エージェントにエラーを読み、問題を再現し、最近の変更を確認し、データを発生源までたどるよう指示します。根本原因が確認された後にだけ修正し、その結果を検証します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Systematic Debugging

Core Principle

NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.

Never apply symptom-focused patches that mask underlying problems. Understand WHY something fails before attempting to fix it.

The Four-Phase Framework

Phase 1: Root Cause Investigation

Before touching any code:

  1. Read error messages thoroughly - Every word matters
  2. Reproduce the issue consistently - If you can't reproduce it, you can't verify a fix
  3. Examine recent changes - What changed before this started failing?
  4. Gather diagnostic evidence - Logs, stack traces, state dumps
  5. Trace data flow - Follow the call chain to find where bad values originate

Root Cause Tracing Technique:

1. Observe the symptom - Where does the error manifest?
2. Find immediate cause - Which code directly produces the error?
3. Ask "What called this?" - Map the call chain upward
4. Keep tracing up - Follow invalid data backward through the stack
5. Find original trigger - Where did the problem actually start?

Key principle: Never fix problems solely where errors appear—always trace to the original trigger.

Phase 2: Pattern Analysis

  1. Locate working examples - Find similar code that works correctly
  2. Compare implementations completely - Don't just skim
  3. Identify differences - What's different between working and broken?
  4. Understand dependencies - What does this code depend on?

Phase 3: Hypothesis and Testing

Apply the scientific method:

  1. Formulate ONE clear hypothesis - "The error occurs because X"
  2. Design minimal test - Change ONE variable at a time
  3. Predict the outcome - What should happen if hypothesis is correct?
  4. Run the test - Execute and observe
  5. Verify results - Did it behave as predicted?
  6. Iterate or proceed - Refine hypothesis if wrong, implement if right

Phase 4: Implementation

  1. Create failing test case - Captures the bug behavior
  2. Implement single fix - Address root cause, not symptoms
  3. Verify test passes - Confirms fix works
  4. Run full test suite - Ensure no regressions
  5. If fix fails, STOP - Re-evaluate hypothesis

Critical rule: If THREE or more fixes fail consecutively, STOP. This signals architectural problems requiring discussion, not more patches.

Red Flags - Process Violations

Stop immediately if you catch yourself thinking:

  • "Quick fix for now, investigate later"
  • "One more fix attempt" (after multiple failures)
  • "This should work" (without understanding why)
  • "Let me just try..." (without hypothesis)
  • "It works on my machine" (without investigating difference)

Warning Signs of Deeper Problems

Consecutive fixes revealing new problems in different areas indicates architectural issues:

  • Stop patching
  • Document what you've found
  • Discuss with team before proceeding
  • Consider if the design needs rethinking

Common Debugging Scenarios

Test Failures

1. Read the FULL error message and stack trace
2. Identify which assertion failed and why
3. Check test setup - is the test environment correct?
4. Check test data - are mocks/fixtures correct?
5. Trace to the source of unexpected value

Runtime Errors

1. Capture the full stack trace
2. Identify the line that throws
3. Check what values are undefined/null
4. Trace backward to find where bad value originated
5. Add validation at the source

"It worked before"

1. Use git bisect to find the breaking commit
2. Compare the change with previous working version
3. Identify what assumption changed
4. Fix at the source of the assumption violation

Intermittent Failures

1. Look for race conditions
2. Check for shared mutable state
3. Examine async operation ordering
4. Look for timing dependencies
5. Add deterministic waits or proper synchronization

Debugging Checklist

Before claiming a bug is fixed:

  • Root cause identified and documented
  • Hypothesis formed and tested
  • Fix addresses root cause, not symptoms
  • Failing test created that reproduces bug
  • Test now passes with fix
  • Full test suite passes
  • No "quick fix" rationalization used
  • Fix is minimal and focused

Success Metrics

Systematic debugging achieves ~95% first-time fix rate vs ~40% with ad-hoc approaches.

Signs you're doing it right:

  • Fixes don't create new bugs
  • You can explain WHY the bug occurred
  • Similar bugs don't recur
  • Code is better af
よくある質問

手早い修正は許されますか?

いいえ。根本原因が見つかる前に修正を適用しないよう、スキルに書かれています。

根本原因のさかのぼりとは何ですか?

エラーを各呼び出しの流れにそってたどり、問題がどこで始まったかを見つけることです。

テストの失敗も対象ですか?

はい。予期しない動作と同様に、失敗するテストも対象です。

詳細

作者による元の説明

Four-phase debugging methodology with root cause analysis. Use when investigating bugs, fixing test failures, or troubleshooting unexpected behavior. Emphasizes NO FIXES WITHOUT ROOT CAUSE FIRST.

repo: ChrisWiles/claude-code-showcase

人気

GitHubのスター
6.1k
ランキング
#14428
ライセンス
—
更新日
2026/1/6

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

似ているスキル