mcpbeat Sign in

Nw Test Refactoring Catalog Agent Skill

Detailed refactoring mechanics with step-by-step procedures, and test code smell catalog with detection patterns and before/after examples

885 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
588
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/nWave-ai/nWave --skill nw-test-refactoring-catalog

The instruction itself

14 sections, as written by the author

Test Refactoring Catalog

Test Code Smells (Full Detail)

L1 Readability Smells

Obscure Test
  • Problem: test name does not reveal business scenario being tested
  • Detection: generic names like Test1(), ProcessOrderTest(), or names requiring reading test body to understand
  • Solution: rename to Given_When_Then or should_do_expected_thing_when_condition format
Before: public void Test1() { /* ... */ }
After:  public void ProcessOrder_PremiumCustomer_AppliesCorrectDiscount() { /* ... */ }
Hard-Coded Test Data
  • Problem: magic numbers and strings obscure business rules being tested
  • Detection: numbers like 1000, 0.15, strings without explanation
  • Solution: extract to named constants that reveal business meaning
Before: Assert.Equal(850, result.Total);  // What discount?
After:  const decimal EXPECTED_TOTAL = 1000 * (1 - 0.15m);
        Assert.Equal(EXPECTED_TOTAL, result.Total);
Assertion Roulette
  • Problem: multiple assertions without messages make failures unclear
  • Detection: multiple Assert.* calls without message parameter
  • Solution: add descriptive message to each assertion explaining expected business outcome

L2 Complexity Smells

Eager Test
  • Problem: single test verifies multiple unrelated behaviors
  • Detection: multiple arrange/act/assert cycles or assertions testing different concerns
  • Solution: split into focused tests, one per business scenario
Before: ProcessOrderTest() { /* tests discount AND shipping AND tax */ }
After:  ProcessOrder_AppliesDiscount()
        ProcessOrder_CalculatesShipping()
        ProcessOrder_CalculatesTax()

Prefer parameterized tests for variations of the same behavior.

Test Code Duplication
  • Problem: repeated test setup logic across multiple tests
  • Detection: same object creation, mock setup, or data builders copied in 3+ tests
  • Solution: extract helper methods
Extract: CreatePremiumCustomer(), CreateHighValueOrder()
Conditional Test Logic
  • Problem: if/switch statements in test code make tests non-deterministic
  • Detection: if, switch, for loops in test methods
  • Solution: replace with parameterized tests
# Before: if/else in test
# After:
@pytest.mark.parametrize("input,expected", [...])
def test_behavior(input, expected): ...

L3 Organization Smells

Mystery Guest
  • Problem: test depends on external files or hidden dependencies
  • Detection: File.ReadAllText, database queries, external config in tests
  • Solution: inline test data or make dependency explicit in test setup
Test Class Bloat
  • Problem: single test class contains tests for multiple unrelated concerns
  • Detection: test class with 15+ tests covering different features
  • Solution: split by feature
Before: UserServiceTests (31 tests)
After:  UserAuthTests, UserProfileTests, UserNotificationTests
General Fixture
  • Problem: shared fixture used by tests with different needs
  • Detection: SetUp method creates data used by only some tests
  • Solution: move to per-test setup methods or test-specific fixtures

For production code refactoring techniques and mechanics, load the progressive-refactoring skill.

Other skills for the same job

different authors, same section of the catalogue
Performance Testing Review AI Review
by ComeOnOliver
×2

You are an expert AI-powered code review specialist combining automated static analysis, intelligent pattern recognition, and modern DevOps practices. Leverage AI tools (GitHub Copilot, Qodo, GPT-5, C

6k tokens
Ruby Pro
by ComeOnOliver
×2

Write idiomatic Ruby code with metaprogramming, Rails patterns, and performance optimization. Specializes in Ruby on Rails, gem development, and testing frameworks. Use PROACTIVELY for Ruby refactoring, optimization, or complex Ruby features.

3k tokens
Tdd Workflows Tdd Refactor
by ComeOnOliver
×2

Use when working with tdd workflows tdd refactor

4k tokens
Setup Pre Commit
by aiskillstore
×1

Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

7k tokens
Pair Programming
by Microck
×1

AI-assisted pair programming with multiple modes (driver/navigator/switch), real-time verification, quality monitoring, and comprehensive testing. Supports TDD, debugging, refactoring, and learning sessions. Features automatic role switching, continuous code review, security scanning, and performance optimization with truth-score verification.

6k tokens
Audit Prep Assistant
by christophacham
×1

Prepares codebases for security review using Trail of Bits' checklist. Helps set review goals, runs static analysis tools, increases test coverage, removes dead code, ensures accessibility, and generates documentation (flowcharts, user stories, inline comments).

2k tokens
Component Refactoring
by ComeOnOliver
×1

Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.

20k tokens
Csharp Pro
by ComeOnOliver
×1

Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.

3k tokens

How to use it

Copy the folder

Take nwave-ai/nw-test-refactoring-catalog from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.