nw-test-refactoring-catalog
Detailed refactoring mechanics with step-by-step procedures, and test code smell catalog with detection patterns and before/after examples
Best use case
nw-test-refactoring-catalog is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Detailed refactoring mechanics with step-by-step procedures, and test code smell catalog with detection patterns and before/after examples
Teams using nw-test-refactoring-catalog should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/nw-test-refactoring-catalog/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How nw-test-refactoring-catalog Compares
| Feature / Agent | nw-test-refactoring-catalog | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Detailed refactoring mechanics with step-by-step procedures, and test code smell catalog with detection patterns and before/after examples
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# 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
```python
# 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.Related Skills
nw-test-organization-conventions
Test directory structure patterns by architecture style, language conventions, naming rules, and fixture placement. Decision tree for selecting test organization strategy.
nw-test-design-mandates
Four design mandates for acceptance tests - hexagonal boundary enforcement, business language abstraction, user journey completeness, walking skeleton strategy, and pure function extraction
nw-property-based-testing
Property-based testing strategies, mutation testing, shrinking, and combined PBT+mutation workflow for test quality validation
nw-progressive-refactoring
Progressive L1-L6 refactoring hierarchy, 22 code smell taxonomy, atomic transformations, test code smells, and Fowler refactoring catalog
nw-mutation-test
Runs feature-scoped mutation testing to validate test suite quality. Use after implementation to verify tests catch real bugs (kill rate >= 80%).
nw-legacy-refactoring-ddd
DDD-guided legacy refactoring patterns -- strangler fig, bubble context, ACL migration, 14 tactical/strategic/infrastructure patterns, and incremental monolith-to-microservices methodology
nw-hexagonal-testing
5-layer agent output validation, I/O contract specification, vertical slice development, and test doubles policy with per-layer examples
nw-buddy-command-catalog
All /nw-* commands — what they do, when to use them, which agent they invoke. For the buddy agent to help users pick the right command.
nw-agent-testing
5-layer testing approach for agent validation including adversarial testing, security validation, and prompt injection resistance
nw-ux-web-patterns
Web UI design patterns for product owners. Load when designing web application interfaces, writing web-specific acceptance criteria, or evaluating responsive designs.
nw-ux-tui-patterns
Terminal UI and CLI design patterns for product owners. Load when designing command-line tools, interactive terminal applications, or writing CLI-specific acceptance criteria.
nw-ux-principles
Core UX principles for product owners. Load when evaluating interface designs, writing acceptance criteria with UX requirements, or reviewing wireframes and mockups.