diagnose
再現、最小化、仮説構築、計測、修正、回帰テストという手順で、難しいバグや性能低下の原因を特定し、問題解決に導く、体系化された診断プロセスを実行するSkill。
📜 元の英語説明(参考)
Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
🇯🇵 日本人クリエイター向け解説
再現、最小化、仮説構築、計測、修正、回帰テストという手順で、難しいバグや性能低下の原因を特定し、問題解決に導く、体系化された診断プロセスを実行するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o diagnose.zip https://jpskill.com/download/19625.zip && unzip -o diagnose.zip && rm diagnose.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19625.zip -OutFile "$d\diagnose.zip"; Expand-Archive "$d\diagnose.zip" -DestinationPath $d -Force; ri "$d\diagnose.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
diagnose.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
diagnoseフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 2
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[スキル名] 診断
診断
困難なバグのための規律です。明示的に正当化される場合にのみフェーズをスキップしてください。
コードベースを調査する際は、プロジェクトのドメイン用語集を使用して関連モジュールの明確なメンタルモデルを構築し、触れている領域のADRを確認してください。
フェーズ1 — フィードバックループを構築する
これがスキルです。 他のすべては機械的なものです。バグに対して高速で決定論的、エージェントが実行可能な合否シグナルがあれば、原因を見つけることができます。二分法、仮説検証、計測はすべてそのシグナルを消費するだけです。それがなければ、いくらコードを眺めても解決にはなりません。
ここに不釣り合いなほどの努力を費やしてください。積極的になり、創造的になり、諦めないでください。
構築方法 — おおよそこの順序で試してください
- 失敗するテスト。バグに到達するあらゆる接合部(ユニット、統合、e2e)で。
- 実行中の開発サーバーに対するCurl / HTTPスクリプト。
- フィクスチャ入力を用いたCLI呼び出し。既知の良好なスナップショットとstdoutを比較します。
- ヘッドレスブラウザスクリプト(Playwright / Puppeteer)。UIを操作し、DOM/コンソール/ネットワークをアサートします。
- キャプチャされたトレースを再生する。 実際のネットワークリクエスト/ペイロード/イベントログをディスクに保存し、コードパスを単独で再生します。
- 使い捨てハーネス。 システムの最小限のサブセット(1つのサービス、モックされた依存関係)を起動し、単一の関数呼び出しでバグのコードパスを実行します。
- プロパティ / ファズループ。 バグが「時々間違った出力」である場合、1000個のランダムな入力を実行し、失敗モードを探します。
- 二分法ハーネス。 バグが2つの既知の状態(コミット、データセット、バージョン)の間で発生した場合、「状態Xで起動し、確認し、繰り返す」を自動化して、
git bisect runできるようにします。 - 差分ループ。 同じ入力を旧バージョンと新バージョン(または2つの設定)で実行し、出力を比較します。
- HITL bashスクリプト。 最後の手段です。人間がクリックする必要がある場合でも、
scripts/hitl-loop.template.shで彼らを駆動し、ループが構造化されたままであるようにします。キャプチャされた出力はあなたにフィードバックされます。
適切なフィードバックループを構築すれば、バグは90%解決したも同然です。
ループ自体を反復する
ループを製品として扱ってください。一度ループができたら、次のことを自問してください。
- 高速化できますか?(セットアップのキャッシュ、無関係な初期化のスキップ、テストスコープの絞り込み。)
- シグナルをより鮮明にできますか?(「クラッシュしなかった」ではなく、特定の症状をアサートする。)
- より決定論的にできますか?(時間の固定、RNGのシード、ファイルシステムの分離、ネットワークの凍結。)
30秒の不安定なループは、ループがないのとほとんど変わりません。2秒の決定論的なループは、デバッグの超能力です。
非決定論的なバグ
目標はクリーンな再現ではなく、高い再現率です。トリガーを100回ループさせ、並列化し、負荷を加え、タイミングウィンドウを狭め、スリープを注入します。50%の不安定なバグはデバッグ可能ですが、1%はそうではありません。デバッグ可能になるまでレートを上げ続けてください。
真にループを構築できない場合
立ち止まり、その旨を明示的に伝えてください。試したことをリストアップしてください。ユーザーに次のことを依頼してください。(a) それを再現する環境へのアクセス、(b) キャプチャされたアーティファクト(HARファイル、ログダンプ、コアダンプ、タイムスタンプ付きのスクリーンレコーディング)、または (c) 一時的な本番環境計測を追加する許可。ループなしで仮説を立てることに進まないでください。
信じられるループができるまで、フェーズ2に進まないでください。
フェーズ2 — 再現
ループを実行します。バグが現れるのを見てください。
確認してください:
- [ ] ループがユーザーが説明した失敗モードを生成していること — たまたま近くで発生する別の失敗ではないこと。間違ったバグは間違った修正につながります。
- [ ] 失敗が複数回実行しても再現可能であること(または、非決定論的なバグの場合、デバッグするのに十分な高いレートで再現可能であること)。
- [ ] 正確な症状(エラーメッセージ、間違った出力、遅いタイミング)をキャプチャしていること。これにより、後のフェーズで修正が実際にそれを解決していることを検証できます。
バグを再現するまで進まないでください。
フェーズ3 — 仮説を立てる
テストする前に、3〜5つの順位付けされた仮説を生成してください。単一の仮説生成は、最初のもっともらしいアイデアに固執してしまいます。
各仮説は反証可能でなければなりません。それがどのような予測をするかを述べてください。
形式:「もし<X>が原因であるならば、<Y>を変更するとバグは消える / <Z>を変更すると悪化するだろう。」
予測を述べられない場合、その仮説は漠然としたものです。破棄するか、明確にしてください。
テストする前に、順位付けされたリストをユーザーに見せてください。 ユーザーは、すぐに順位を付け直すドメイン知識を持っていることがよくあります(「#3に最近変更をデプロイしました」)、またはすでに除外した仮説を知っていることがあります。安価なチェックポイントで、大幅な時間節約になります。ユーザーがAFKの場合でも、それにブロックされずに、自分の順位付けで進めてください。
フェーズ4 — 計測
各プローブは、フェーズ3からの特定の予測に対応している必要があります。一度に1つの変数だけを変更してください。
ツールの優先順位:
- 環境がサポートしている場合はデバッガー / REPL検査。1つのブレークポイントは10個のログに勝ります。
- 仮説を区別する境界でのターゲットを絞ったログ。
- 「すべてをログに記録してgrepする」は決して行わないでください。
すべてのデバッグログに一意のプレフィックス(例:[DEBUG-a4f2])をタグ付けしてください。最後にクリーンアップは単一のgrepになります。タグなしのログは残り、タグ付きのログは消えます。
パフォーマンスブランチ。 パフォーマンス回帰の場合、ログは通常間違っています。代わりに、ベースライン測定(タイミングハーネス、performance.now()、プロファイラー、クエリプラン)を確立し、その後二分法を行います。まず測定し、次に修正します。
フェーズ5 — 修正 + 回帰テスト
修正前に回帰テストを作成してください。ただし、それを行うための適切な接合部がある場合に限ります。
適切な接合部とは、テストが呼び出しサイトで発生する実際のバグパターンを実行する場所です。利用可能な接合部が浅すぎる場合(バグが複数の呼び出し元を必要とする場合の単一呼び出し元テスト、バグをトリガーしたチェーンを再現できないユニットテスト)、そこでの回帰テストは誤った自信を与えます。
適切な接合部が存在しない場合、それ自体が発見です。 それを記録してください。コードベースのアーキテクチャがバグの封じ込めを妨げているのです。これを次のフェーズのためにフラグ付けしてください。
適切な接合部が存在する場合:
- 最小化された再現を、その接合部での失敗するテストに変換します。
- それが失敗するのを確認します。
- 修正を適用します。
- それがパスするのを確認します。
- 元の(最小化されていない)シナリオに対してフェーズ1のフィードバックループを再実行します。
フェーズ6 —
(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Diagnose
A discipline for hard bugs. Skip phases only when explicitly justified.
When exploring the codebase, use the project's domain glossary to get a clear mental model of the relevant modules, and check ADRs in the area you're touching.
Phase 1 — Build a feedback loop
This is the skill. Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you.
Spend disproportionate effort here. Be aggressive. Be creative. Refuse to give up.
Ways to construct one — try them in roughly this order
- Failing test at whatever seam reaches the bug — unit, integration, e2e.
- Curl / HTTP script against a running dev server.
- CLI invocation with a fixture input, diffing stdout against a known-good snapshot.
- Headless browser script (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
- Replay a captured trace. Save a real network request / payload / event log to disk; replay it through the code path in isolation.
- Throwaway harness. Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
- Property / fuzz loop. If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
- Bisection harness. If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can
git bisect runit. - Differential loop. Run the same input through old-version vs new-version (or two configs) and diff outputs.
- HITL bash script. Last resort. If a human must click, drive them with
scripts/hitl-loop.template.shso the loop is still structured. Captured output feeds back to you.
Build the right feedback loop, and the bug is 90% fixed.
Iterate on the loop itself
Treat the loop as a product. Once you have a loop, ask:
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
Non-deterministic bugs
The goal is not a clean repro but a higher reproduction rate. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
When you genuinely cannot build a loop
Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do not proceed to hypothesise without a loop.
Do not proceed to Phase 2 until you have a loop you believe in.
Phase 2 — Reproduce
Run the loop. Watch the bug appear.
Confirm:
- [ ] The loop produces the failure mode the user described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
Do not proceed until you reproduce the bug.
Phase 3 — Hypothesise
Generate 3–5 ranked hypotheses before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
Each hypothesis must be falsifiable: state the prediction it makes.
Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
Show the ranked list to the user before testing. They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
Phase 4 — Instrument
Each probe must map to a specific prediction from Phase 3. Change one variable at a time.
Tool preference:
- Debugger / REPL inspection if the env supports it. One breakpoint beats ten logs.
- Targeted logs at the boundaries that distinguish hypotheses.
- Never "log everything and grep".
Tag every debug log with a unique prefix, e.g. [DEBUG-a4f2]. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
Perf branch. For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, performance.now(), profiler, query plan), then bisect. Measure first, fix second.
Phase 5 — Fix + regression test
Write the regression test before the fix — but only if there is a correct seam for it.
A correct seam is one where the test exercises the real bug pattern as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
If no correct seam exists, that itself is the finding. Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
If a correct seam exists:
- Turn the minimised repro into a failing test at that seam.
- Watch it fail.
- Apply the fix.
- Watch it pass.
- Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
Phase 6 — Cleanup + post-mortem
Required before declaring done:
- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
- [ ] Regression test passes (or absence of seam is documented)
- [ ] All
[DEBUG-...]instrumentation removed (grepthe prefix) - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
- [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
Then ask: what would have prevented this bug? If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the /improve-codebase-architecture skill with the specifics. Make the recommendation after the fix is in, not before — you have more information now than when you started.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (7,163 bytes)
- 📎 scripts/hitl-loop.template.sh (1,164 bytes)