agentsclimarketplace

Clean tests

Skill OmarSaleh506/skills/skills/ai-os-init/templates/.claude/skills/clean-tests

Portable, install-once agent skills for Claude Code, Cursor, Codex & more — a price-comparison shopper, a SQLAlchemy 2.0 reference, a codebase flow-mapper, and an AI-OS scaffolder.

Install
npx -y skills add OmarSaleh506/skills --skill clean-tests

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Audits and refactors existing test files for quality — removes brittle assertions, fixes implementation coupling (mocking internals), improves test names, eliminates duplication, and enforces behavior-over-implementation testing. Does NOT write new tests (use /tdd for that). Use when asked to "clean up the tests", "improve test quality", "fix brittle tests", "refactor the test suite", "tests keep breaking on refactor", "tests are a mess", or "make the tests better".

SKILL.md

2.5 KB, as published. Nobody here has run it

clean-tests

Audits and refactors existing tests without removing coverage.

What Gets Fixed

IssueSymptomFix
Implementation couplingMocking internal modules, testing private methods, asserting on internal stateRewrite to test through public API only
Brittle assertionsExact error message strings, hardcoded IDs, timestamp comparisonsUse flexible matchers, freeze time, assert structure not exact value
Poor test namestest_1, test_user, testGetUserRewrite as sentences: returns_404_when_user_not_found
Multi-assertion testsOne test checks 5 things — failure is ambiguousSplit into focused single-assertion tests
Duplicated setupSame 15-line setup repeated across every testExtract to fixture/factory/helper
False confidenceassert True, assert result is not None, empty testsAdd meaningful behavioral assertions
Order dependenceTests pass together but fail in isolationMake each test fully self-contained
Flaky time/randomdatetime.now() or random() in assertionsFreeze time, seed random, or use matchers

Process

1. Discover test files

find . -type f \( -name "test_*.py" -o -name "*_test.py" -o -name "*.test.ts" -o -name "*.spec.ts" -o -name "*.test.tsx" -o -name "*.spec.tsx" \) \
  | grep -v node_modules | grep -v .venv | grep -v dist | sort

2. Analyze → Prioritize → Fix → Run tests after each file

Fix order: implementation coupling → poor naming → brittle assertions → duplication → false confidence.

Run tests after every file:

pytest <file> -x -q 2>&1 | tail -8   # Python
npx vitest run <file> 2>&1 | tail -8  # JS/TS

3. Rules

  • Never delete a test — only improve it
  • Never change WHAT a test asserts about behavior, only HOW
  • If a fix is uncertain, leave # TODO clean-tests: <reason> rather than breaking coverage
  • Run tests after every file before moving to the next

4. Report findings at the end with counts per category

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.