本文へスキップ
Skillpedia
テスト48k · #5971

test-guard

できること

このエージェントは、テストコードがベストプラクティスに沿っているかをレビューします。テストがプログラムの振る舞いに焦点を当てているか、重複がないか、システムがすでに保証している機能をテストしていないかを確認します。

使う場面

  • ✓AIが生成した新しいテストコードをレビューするとき。
  • ✓既存のテストを編集またはリファクタリングするとき。
  • ✓テストの変更を含む一連の変更内容を分析するとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/test-guard/SKILL.md

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“これらのテストが品質ルールに従っているかレビューしてください。”

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

仕組み

エージェントはテストコードを読み込み、一連のルールと照らし合わせます。ルールに違反している箇所を指摘し、修正方法を提案します。特に、保守の困難さを生んだり、実際のバグを隠したりする問題に注目します。

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

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

Test Guard

You are reviewing generated or changed test code before it ships. Enforce the rules below after the first test-writing pass and before the tests are presented, committed, or merged. Be a sharp reviewer, not a pedantic one: flag what wastes maintenance effort or hides real bugs, ignore cosmetic preferences.

These rules exist because coding agents over-generate tests. The common failure modes: mock-heavy unit tests that assert implementation details, near-duplicate test bodies that differ by one value, and tests that re-verify the framework instead of the project's logic. Each looks productive in a diff and costs maintenance forever.

When to Use

Use this skill when reviewing generated or changed test code before it ships. Activate it reactively after an agent writes, edits, generates, or refactors tests — unit tests, integration tests, e2e tests, or snapshot tests in any framework.

When this skill activates

  • A coding agent has just written new test functions or test files, in any language
  • You are editing existing tests
  • You are reviewing a diff that contains test changes
  • The user asks you to write, add, or review tests

Adapt to the project first

These rules are universal, but their application is not. Before reviewing:

  1. Check the project's own agent instructions (CLAUDE.md, AGENTS.md) and testing docs. Project-specific testing rules win over this skill when they conflict.
  2. Identify the test stack, then read the matching reference for concrete patterns:
  3. If the project calls LLM APIs, uses agent frameworks, or wires up observability/telemetry, also read references/llm-app-testing.md — it adds three rules specific to LLM applications.
  4. Map the project's system boundaries: network calls, databases, filesystem, clock and randomness, third-party SDKs, LLM APIs. Existing fixtures and test helpers usually reveal where the project already draws these lines.

What to do

  1. Read the test code: the diff, the new file, or the section being modified.
  2. Check each test against the rules below.
  3. Report violations concisely: rule number, location, why it violates, suggested fix.
  4. If the user explicitly invokes this skill before test writing, apply the rules as you write — don't write violations and then flag them.

When writing new tests, ask for each test: "What specific bug does this catch that no other test in this suite catches?" If you can't answer clearly, don't write it.

The Nine Rules

Rule 1: Test behavior, not implementation

Test what code does from the caller's perspective. Assert return values and observable side effects. Never assert that an internal helper was called with specific arguments — that test breaks on every refactor while catching nothing.

Violation pattern: asserting a mock of an internal function was called, where that function is not a system boundary. Fix: assert the return value or the state change the caller observes.

Rule 2: Every mock must be justified

Mock only at system boundaries: network and HTTP calls, LLM APIs, databases, filesystem I/O on external files, clock and randomness, third-party SDKs. Never mock internal classes or helper functions to isolate a "unit" — the seams you create hide the integration bugs worth catching.

When you mock a boundary, assert what the caller does with the response, not that the mock received specific arguments.

Rule 3: One scenario per test, data-driven for variants

If two or more tests share identical setup and differ only in input/output values, merge them into one data-driven test (@pytest.mark.parametrize, PHPUnit #[DataProvider], Jest test.each).

When separate tests ARE correct: different setup, different assertions, different mock configurations, or genuinely different scenarios that happen to exercise the same function.

Rule 4: Every test must justify its existence

Ask: "What bug does this catch that no other test catches?" Delete tests that only catch typos, verify default values of data classes, or test trivial pass-through logic.

…

よくある質問

「汎用的なテストルール」とは何ですか?

効果的なテストを書くための一般的な指針です。たとえば、内部の処理方法ではなく、プログラムの最終的な結果に焦点を当てることや、互いに似すぎたテストを避けることなどが含まれます。

なぜ内部の実装の詳細をテストしてはいけないのですか?

内部の実装をテストすると、プログラムの最終的な結果が変わらなくても、コードを修正するだけでテストが壊れやすくなります。その結果、新しいバグは見つからないのに保守の手間だけが増えてしまいます。

「モック」とは何ですか?

モックとは、テスト中に他の部分の動作を模倣するために使う偽物のオブジェクトです。このエージェントは、ネットワーク通信など、システムの特定の境界部分でのみモックを使い、自分のコードの内部部分には使わないことを提案します。

詳細

作者による元の説明

Review generated or changed test code against universal testing rules before it ships or is presented for approval.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#5971
ライセンス
MIT
更新日
2026/10/15

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

0

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

コメント

  • …

このリポジトリの他のスキル

似ているスキル