失敗したテストをprint文の代わりにClaudeにステップ実行させる
使うタイミング: スタックトレースが不明確なテストが失敗している — printデバッグでは時間がかかりすぎる。
前提条件
- VS CodeにDebugMCPをインストール — Marketplace → ozzafar.debugmcpextension
- 言語デバッグ拡張機能(例:.py用Python) — VS Codeが初回実行時に自動で案内
フロー
-
設定Use debugmcp. Add a breakpoint on the line
assert result == expectedin tests/test_orders.py.✓ コピーしました→ ブレークポイント設定完了;行内容でマッチ -
実行Start debugging tests/test_orders.py with the failing test.✓ コピーしました→ ブレークポイントでセッション停止
-
インスペクションShow me all local variables. What's
resultactually contain?✓ コピーしました→ 具体的な値を含む変数ダンプ -
ステップ実行と診断Step into the function that built
result. Tell me where it diverged from expected.✓ コピーしました→ コードに根拠のある根本原因
結果: 推測ではなくステップ実行でバグを特定 — 1時間ではなく数分で完了。
注意点
- 行番号によるブレークポイントが編集後にズレる — 行内容マッチングを使用(DebugMCPがネイティブでサポート)