Code test quality

From laurigates/claude-plugins · View interactive version

Code test quality is an AI agent skill from the GitHub repository laurigates/claude-plugins. Analyze test quality: smells, empty assertions, flaky patterns, coverage gaps. Use when tests are unreliable, coverage is misleading, or after major refactors.

How to use this skill

Skill file

/code:test-quality

Analyze test suite for quality issues and reliability.

When to Use This Skill

| Use this skill when... | Use something else when... |

|---|---|

| Test suite passes but bugs still ship | Setting up test framework → /configure:tests |

| Coverage numbers are high but quality feels low | Setting up coverage thresholds → /configure:coverage |

| Tests are flaky or timing-dependent | Looking for code anti-patterns → /code:antipatterns |

| After major refactor, need test health check | Running tests → /test:run |

Context

Parameters

Execution

Execute this test quality analysis:

Step 1: Discover test suite

Scan the target path for test files. Categorize by:

Count total test files and estimate test-to-source ratio.

Step 2: Detect test smells

Scan test files for these anti-patterns:

Empty tests (Critical):

Weak assertions (High):

Test duplication (Medium):

Missing edge cases (Medium):

Flaky patterns (High):

Overly broad mocks (Medium):

Step 3: Analyze coverage quality (if --focus coverage or all)

If coverage data is available:

  1. Identify files with 0% coverage
  2. Find files with high line coverage but low branch coverage
  3. Detect "coverage padding" — tests that execute code but don't assert behavior
  4. Identify critical paths without coverage (error handlers, auth, data validation)

Step 4: Report findings

Print categorized results:

Test Quality Report
===================
Test files: N
Test-to-source ratio: N:1

Smells Found:
  Critical: N (empty tests, no assertions)
  High: N (weak assertions, flaky patterns)
  Medium: N (duplication, missing edge cases)
  Low: N (style issues)

Top Issues:
1. [file:line] Empty test - "should handle X" has no assertions
2. [file:line] Flaky - uses setTimeout(500) instead of async await
3. [file:line] Weak assertion - toBeTruthy on object (always passes)

Recommendations:
- Add assertions to N empty tests
- Replace N setTimeout calls with proper async patterns
- Add error path tests for N untested handlers

Step 5: Suggest improvements

For each finding, provide specific fix guidance:

Post-Actions

Agentic Optimizations

| Context | Command |

|---|---|

| Find empty tests (JS) | grep -rn "it\|test" --include="*.test.*" -l then check for assertions |

| Find sleeps in tests | grep -rn "setTimeout\|sleep\|time.sleep" --include="*.test.*" |

| Coverage report (Vitest) | npx vitest run --coverage --reporter=json |

| Coverage report (pytest) | pytest --cov --cov-report=json |

| Quick smell scan | Grep for assertion-free test bodies |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.