Refactor tests

From SDiamante13/dotfiles · View interactive version

Refactor tests is an AI agent skill from the GitHub repository SDiamante13/dotfiles. Refactor test files to improve behavioral coverage, clarity, structure, assertions, fixture setup, mocking strategy, and remove implementation-detail or low-value tests. Use when asked to clean up, declutter, consolidate, or improve tests.

How to use this skill

Skill file

Test Refactor

Ask the user for the test file to refactor. Work on one test file at a time.

Process

Work through these steps in order, making a separate commit for each step that makes changes:

0. **Count cyclomatic complexity (DO FIRST)**

1. **Identify public API and remove tests for internals**

2. **Remove tests for getters/trivial code**

3. **Remove implementation detail tests**

4. **Consolidate to match cyclomatic complexity**

5. **Fix test anti-patterns**

Replace with fluent assertion idioms (AssertJ filteredOn(...).singleElement().satisfies(...), extracting(...), anySatisfy; Jest arrayContaining/objectContaining) or stream collectors (Collectors.toMap).

6. **Improve test data**

7. **Improve test names/assertions (ASK USER FIRST)**

1. Rename test to describe behavior

2. Improve assertion messages

3. Both

8. **Refactor test structure**

9. **Review mocking strategy**

After EACH step:

Testing Philosophy

Output

Commit Format

Use Arlo's Commit Notation (ACN):

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.