debugging-failures
できること
このスキルは、長いログを読まずに、Go言語のGinkgoテストが失敗した理由を見つける方法を示します。すぐに失敗の詳細が必要な開発者とエージェント向けです。
使う場面
- ✓Ginkgoのテストスイートが失敗し、どのテストがなぜ失敗したか知りたいとき。
- ✓テストが並列で動いたため、テスト出力が混ざっているとき。
- ✓同じランダム順序で失敗したテストを再実行したいとき。
スキルのリンク
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/debugging-failures/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Ginkgoのテストが失敗しました。どのテストが、なぜ失敗したのか正確に調べてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、JSONレポート付きでスイートを一度実行し、一行の結果を読みます。フィルターを使い、失敗したテストだけ、そのメッセージ、ファイルの位置、取得されたログを取り出します。同じシードを使って再実行し、失敗を再現できます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Debugging Ginkgo failures (especially as an agent)
Ginkgo's terminal output is good for a human; for programmatic diagnosis, prefer a hybrid: terminal for the verdict, JSON + jq for the details. This is empirically the most reliable, lowest-token workflow. Docs: https://onsi.github.io/ginkgo/#reporting-and-profiling-suites.
The workflow: one run, JSON-first diagnosis
# One invocation gives you BOTH the human verdict on the terminal AND a structured report.
# --json-report does NOT suppress console output, so you don't pay for two runs.
ginkgo -r -p --no-color --json-report=report.json --output-dir=.ginkgo-report
- Read the terminal tail for the one-line verdict:
FAIL! -- 5 Passed | 6 Failed | 1 Pending | 1 Skipped. Cheap, immediate. - If there are failures, query the JSON with
jq(filters below) to get exactly the failing specs — stable, addressable, order-independent. - Clean up the report dir when done.
Why hybrid and not one or the other:
- Terminal-only is brittle to parse (free-form text) and, under
-p, interleaves failures in nondeterministic order. - JSON-only is wasteful if you dump it: the full
report.jsonis ~9× the tokens of the terminal output. Ajqfailures-only extraction is a fraction of either. The discipline is filter, don't dump.
Where the JSON lands (use --output-dir deliberately)
--json-report=report.jsonalone writesreport.jsonto the current directory — which scatters into package dirs under-rand risks getting committed.- Prefer
--output-dir=DIRto collect everything in one known place (auto-created). With-r, all suites merge into oneDIR/report.json— ideal: one file, one set ofjqfilters. - Use a gitignored or temp location: a repo-local
.ginkgo-report/(add it to.gitignore) or an absolute temp path (--output-dir=/tmp/ginkgo-report). Don't leavereport.jsonin the working tree. --keep-separate-reports(with-r) writes onePACKAGE_report.jsonper package instead of merging — only reach for it when you must attribute failures per package.
The jq filters (tested against the real schema)
The report is an array of suite reports, each with a .SpecReports[] array.
Verdict / counts per suite:
jq -r '.[] | "\(.SuiteDescription): \([.SpecReports[].State]|group_by(.)|map("\(length) \(.[0])")|join(", "))"' .ginkgo-report/report.json
All failures — name, location, message (the workhorse). Select failed and panicked and timedout — see the trap below:
jq -r '.[].SpecReports[]
| select(.State=="failed" or .State=="panicked" or .State=="timedout")
| "[\(.State|ascii_upcase)] \((.ContainerHierarchyTexts+[.LeafNodeText])|join(" > "))\n \(.Failure.Location.FileName):\(.Failure.Location.LineNumber)\n \(.Failure.Message)"' .ginkgo-report/report.json
Panics — the real user-code line (the headline location lies; see below):
jq -r '.[].SpecReports[] | select(.State=="panicked")
| "PANIC: \(.Failure.ForwardedPanic)\n\(.Failure.Location.FullStackTrace)"' .ginkgo-report/report.json
Drill into one spec by name, with its captured logs:
jq -r '.[].SpecReports[] | select(.LeafNodeText|test("SUBSTRING"))
| "STATE: \(.State)\n\(.Failure.Message)\n--- GinkgoWriter ---\n\(.CapturedGinkgoWriterOutput // "(none)")"' .ginkgo-report/report.json
Slowest specs:
jq '.[0].SpecReports | map([(.ContainerHierarchyTexts+[.LeafNodeText])|join(" "), .RunTime/1e9]) | sort_by(.[1]) | reverse | .[0:10]' .ginkgo-report/report.json
Schema facts you need
State:passed | failed | panicked | pending | skipped | timedout | interrupted | aborted.- Spec name =
ContainerHierarchyTexts(array) +LeafNodeText. Failure.Message— the failure text (Gomega's full expected/got block for assertions).Failure.Location.{FileName,LineNumber,FullStackTrace}.Failure.ForwardedPanic— the panic value (only meaningful forpanicked).Failure.FailureNodeType— e.g.BeforeEachvsIt, so you know a setup node failed.CapturedGinkgoWriterOutput—GinkgoWriterlogs (omitted if empty).SpecEvents[]—By(...)steps and node enter/exit (does not include raw GinkgoWriter text).ParallelProcess— which worker ran the spec (-p).AdditionalFailures[]— failures beyond the primaryFailure(e.g. a failingAfterEachorDeferOnFailurecallback). Usually the primary is
よくある質問
なぜログ全体を読まないのですか?
並列実行では失敗のメッセージが混ざることがあり、完全なレポートは非常に大きいため、このスキルは詳細をフィルターで絞り込みます。
シードとは何ですか?
テストの順序をランダムにする数字のことです。同じシードを再利用すると、同じ実行を再現できます。
レポートのファイルは片付けられますか?
はい。診断が終わると、このスキルはレポートのフォルダを削除して終わります。
詳細
作者による元の説明
Diagnose a failing Ginkgo suite as an agent — always run with --json-report into a predictable temp/gitignored location, read the terminal verdict line, then use jq to extract structured failure details (name, message, file:line, panic value, captured logs). Covers the panicked-vs-failed trap, panic locations pointing into the Go runtime, parallel output interleaving, reproducing with --seed, and progress reports for hangs. Use when a suite failed and you need to know why. Also invokable as /ginkgo:debugging-failures.
repo: onsi/ginkgo
人気
- GitHubのスター
- 9.1k
- ランキング
- #12299
- ライセンス
- MIT
- 更新日
- 2026/10/9
コメント
- …
このリポジトリの他のスキル
ci
9.1kエージェントが、GinkgoのテストをCIで確実に動かせるよう設定を支援します。保留やフォーカスの取り残し、不安定なテストを見つける推奨フラグも含みます。
decorators
9.1kエージェントが、Serial、Ordered、Label、Focus、タイムアウトなどのGinkgoのテストのデコレーターを、それぞれの働きを説明しながら正しく使えるよう支援します。
filtering
9.1kエージェントが、保留、スキップ、フォーカス、ラベル、バージョン条件、ファイルのフィルターを正しい優先順位で使い、Ginkgoのテストの一部だけを実行できるよう支援します。
ordering-and-flakes
9.1kエージェントが、GinkgoのSerialとOrderedの設定と再試行オプションを使い、Goのテストの実行順序と不安定なテストを管理できるよう支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。