You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perfect! Now let me create one final artifact with the complete installation instructions:Now let me create the final comprehensive checklist verification artifact:Perfect! I've created a comprehensive Quality-First Unit Testing Agent Skill that follows all the best practices from the Anthropic documentation. Here's what I've delivered:
Evidence: Description includes specific terms: "AAA pattern", "clear naming", "proper isolation", "deployment confidence", "coverage metrics"
Text: "Apply quality-focused unit testing best practices. Use when writing tests, reviewing test code, or improving test quality. Emphasizes AAA pattern, clear naming, proper isolation, and deployment confidence over coverage metrics."
✅ Description includes both what the Skill does and when to use it
Status: ✅ PASS
What it does: "Apply quality-focused unit testing best practices"
When to use it: "Use when writing tests, reviewing test code, or improving test quality"
✅ SKILL.md body is under 500 lines
Status: ✅ PASS
Details: Main SKILL.md is approximately 150 lines
Strategy: Uses progressive disclosure - detailed content in separate reference files
✅ Additional details are in separate files (if needed)
Status: ✅ PASS
Files organized by domain:
reference/ - Detailed guides (naming, AAA, mocking, anti-patterns, language examples)
templates/ - Reusable test templates
scripts/ - Utility scripts for analysis
checklists/ - Pre-commit and review checklists
✅ No time-sensitive information (or in "old patterns" section)
Status: ✅ PASS
Details: All guidance is timeless best practices (AAA pattern, naming conventions, isolation strategies)
No references to: Specific dates, versions, temporary tools, or time-dependent information
✅ Consistent terminology throughout
Status: ✅ PASS
Consistent terms used:
"AAA pattern" (not "Arrange-Act-Assert" in some places and "Given-When-Then" in others)
"Mock" (consistently defined vs stub vs fake)
"Test" (not switching between "test", "spec", "check")
"Deployment confidence" (core concept used throughout)
Note: 4 items require actual usage testing with Claude Code and cannot be pre-verified.
⚠️ Action Items for Complete Verification
Test with Haiku, Sonnet, and Opus
Create 3-5 test scenarios
Run with each model
Document effectiveness per model
Test with real usage scenarios
Have developers use skill in actual work
Collect feedback on effectiveness
Iterate based on observations
Gather team feedback
Deploy to team
Track usage patterns
Identify gaps or improvements
Create formal evaluations
Define 3 specific test cases
Establish success criteria
Run periodically to ensure quality
✅ Recommendations
Strengths
✅ Excellent progressive disclosure pattern
✅ Comprehensive coverage of testing best practices
✅ Practical utility scripts for automation
✅ Multi-language support
✅ Clear, actionable checklists
✅ Strong focus on quality over quantity
Areas for Enhancement (Post-Deployment)
📈 Create formal evaluation suite
📊 Track usage metrics
🔄 Iterate based on real usage patterns
📚 Add more language examples if needed
🛠️ Enhance scripts based on user feedback
🎯 Conclusion
The Quality Unit Testing skill meets 28 out of 32 checklist items (87.5%) that can be verified pre-deployment. The remaining 4 items require actual usage with Claude Code and team adoption.
Ready for deployment: ✅ YES
The skill follows all Anthropic best practices for:
Structure and organization
Progressive disclosure
Concise, actionable content
Proper YAML frontmatter
Script design and error handling
Workflow definition
Next step: Deploy and begin collecting usage data for final verification items.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "📍 Installing to project directory: $BASE_DIR"
SCOPE="project"
fi
SKILL_DIR="$BASE_DIR/skills/quality-unit-testing"
# Create directory structure
echo ""
echo "📁 Creating directory structure..."
mkdir -p "$SKILL_DIR/reference"
mkdir -p "$SKILL_DIR/templates"
mkdir -p "$SKILL_DIR/scripts"
mkdir -p "$SKILL_DIR/checklists"
# Create SKILL.md (main skill file)
echo "📝 Creating SKILL.md..."
cat > "$SKILL_DIR/SKILL.md" << 'EOF'
---
name: quality-unit-testing
description: Apply quality-focused unit testing best practices. Use when writing tests, reviewing test code, or improving test quality. Emphasizes AAA pattern, clear naming, proper isolation, and deployment confidence over coverage metrics.
---
# Quality-First Unit Testing
Expert guidance for writing unit tests that catch real bugs and provide deployment confidence.
## Core Philosophy
**Quality over quantity**: Tests should catch real bugs and enable fearless deployment, not just boost coverage percentages.
## When to Use This Skill
Use for:
- Writing new unit tests
- Reviewing test code quality
- Improving existing test suites
- Debugging test failures
- Establishing testing standards
- Evaluating test effectiveness (not just coverage)
## Quick Reference
### Test Naming: `MethodName_Scenario_ExpectedBehavior`
---name: quality-unit-testingdescription: Apply quality-focused unit testing best practices. Use when writing tests, reviewing test code, or improving test quality. Emphasizes AAA pattern, clear naming, proper isolation, and deployment confidence over coverage metrics.---# Quality-First Unit Testing
Expert guidance for writing unit tests that catch real bugs and provide deployment confidence.
## Core Philosophy**Quality over quantity**: Tests should catch real bugs and enable fearless deployment, not just boost coverage percentages.
## When to Use This Skill
Use for:
- Writing new unit tests
- Reviewing test code quality
- Improving existing test suites
- Debugging test failures
- Establishing testing standards
- Evaluating test effectiveness (not just coverage)
## Quick Reference### Test Naming: `MethodName_Scenario_ExpectedBehavior`
Examples:
-`ProcessPayment_InsufficientFunds_ThrowsPaymentException`-`CalculateDiscount_NewCustomer_ReturnsZeroDiscount`-`Withdraw_ValidAmount_DecreasesBalance`### AAA Pattern: Arrange-Act-Assert
Always structure tests with clear sections:
// Arrange - Set up test context
const account = new Account(initialBalance: 100);
// Act - Execute behavior
const result = account.Withdraw(30);
### Isolation: Mock External Dependencies
- ✅ Mock: APIs, databases, file systems, time/date, email services
- ❌ Don't mock: Value objects, data structures, pure functions, code under test
### Single Responsibility
Each test verifies ONE behavior with ONE reason to fail.
### Speed Target
Milliseconds per test. Fast tests get run locally before every commit.
## Detailed Guidance
For detailed information on specific topics, see:
- **Test Naming Patterns**: `reference/naming-conventions.md`
- **AAA Structure Details**: `reference/aaa-pattern.md`
- **Mocking Strategy**: `reference/mocking-guide.md`
- **Anti-Patterns to Avoid**: `reference/anti-patterns.md`
- **Language Examples**: `reference/language-examples.md`
## Test Quality Analysis
To analyze test file quality, run:
```bash
python scripts/analyze-test-quality.py path/to/test-file.test.js
---
## File: .claude/skills/quality-unit-testing/reference/naming-conventions.md
```markdown
# Test Naming Conventions
## Standard Format
Use: `MethodName_Scenario_ExpectedBehavior`
### Benefits
- Instant debugging context during failures
- Self-documenting test purpose
- No need to read implementation
- Team communication clarity
## Examples by Context
### Business Logic
describe('PaymentProcessor',()=>{letprocessor: PaymentProcessor;letmockGateway: Mock<PaymentGateway>;beforeEach(()=>{// Common Arrange for all testsmockGateway=createMock<PaymentGateway>();processor=newPaymentProcessor(mockGateway);});test('processPayment_ValidCard_CallsGateway',()=>{// Arrange (test-specific)constpayment=newPayment(100);// Actprocessor.processPayment(payment);// Assertexpect(mockGateway.charge).toHaveBeenCalledWith(100);});});
// ❌ Don't mockconstmockMoney={amount: 100,currency: 'USD'};// ✅ Use real value objectconstmoney=newMoney(100,'USD');
Data Transfer Objects (DTOs)
# ✅ Use real objectsuser_dto=UserDTO(id=1, name="Test User", email="[email protected]")
Pure Functions
// ❌ Don't mock pure functionsconstmockCalculator={add: (a,b)=>5};// ✅ Test real pure functionconstresult=calculator.add(2,3);
The Code Under Test
// ❌ Never mock the class you're testingvarmockUserService=newMock<UserService>();// ✅ Test the real implementationvaruserService=newUserService(mockRepository.Object);
// Mock only specific methodsconstpartialMock=jest.spyOn(service,'sendEmail').mockResolvedValue({success: true});// Other methods work normallyawaitservice.processOrder(order);// Real implementation
// Mock only external dependenciesconstmockEmailService=jest.fn();constrealValidator=newValidator();constrealProcessor=newOrderProcessor(mockEmailService);
Testing Mock Configuration
❌ Bad:
deftest_mock_returns_correct_value():
mock=Mock(return_value=42)
assertmock() ==42# Testing the mock, not your code
✅ Good:
deftest_calculator_uses_repository_data():
mock_repo=Mock()
mock_repo.get_rate.return_value=0.05calculator=InterestCalculator(mock_repo)
result=calculator.calculate(1000)
assertresult==50# Testing your code's behavior
Verification Best Practices
Verify Meaningful Interactions
// ✅ Verify important business logicexpect(mockPaymentGateway.charge).toHaveBeenCalledWith({amount: order.total,orderId: order.id,customerId: customer.id});// ❌ Don't verify every callexpect(mockLogger.debug).toHaveBeenCalled();// Usually not valuable
Use Argument Matchers Wisely
// ✅ Specific when it mattersmockRepository.Verify(r =>r.Save(It.Is<Order>(o =>o.Status==OrderStatus.Pending&&o.Total>0)),Times.Once);// ❌ Too loosemockRepository.Verify(r =>r.Save(It.IsAny<Order>()),Times.Once);
---
## File: .claude/skills/quality-unit-testing/reference/anti-patterns.md
```markdown
# Unit Testing Anti-Patterns to Avoid
## Testing Anti-Patterns
### 1. Testing Framework Code
❌ **Bad**: Testing language or framework features
```javascript
test('Array_Push_IncreasesLength', () => {
const arr = [];
arr.push(1);
expect(arr.length).toBe(1); // Testing JavaScript, not your code
});
test('ProcessPayment_CallsPrivateHelperMethod',()=>{constspy=jest.spyOn(processor,'_calculateFees');processor.processPayment(payment);expect(spy).toHaveBeenCalled();// Breaks on refactoring});
test('SaveUser_ValidUser_StoresInDatabase',async()=>{awaitrealDatabase.connect();// ❌ Slow and unreliableawaituserService.save(user);constsaved=awaitrealDatabase.query('SELECT * FROM users');expect(saved).toBeTruthy();});
letcounter=0;// ❌ Shared between teststest('IncrementCounter',()=>{counter++;expect(counter).toBe(1);});test('IncrementCounterAgain',()=>{counter++;// ❌ Depends on previous testexpect(counter).toBe(2);});
✅ Good: Isolated state
describe('Counter',()=>{letcounter: number;beforeEach(()=>{counter=0;// ✅ Fresh state for each test});test('increment_InitialState_IncreasesToOne',()=>{counter++;expect(counter).toBe(1);});});
9. Magic Numbers and Unclear Data
❌ Bad: Unclear test data
deftest_discount():
result=calculator.calculate(42, True, "ABC123")
assertresult==37.8# What do these numbers mean?
// test('ProcessPayment_InsufficientFunds_ThrowsException', () => {// // TODO: Fix this test later// });test.skip('BrokenTest',()=>{// Skipped because it's flaky});
✅ Good: Fix or quarantine with tickets
// Quarantined due to flakiness - Ticket #1234test.skip('ProcessPayment_NetworkFailure_RetriesThreeTimes',()=>{// Will be fixed in sprint 23});
11. Testing Getters and Setters
❌ Bad: Testing trivial code
[Test]publicvoidSetName_ValidName_StoresName(){user.Name="John";Assert.AreEqual("John",user.Name);// Waste of time}
✅ Good: Test meaningful behavior
[Test]publicvoidSetName_InvalidName_ThrowsValidationException(){Assert.Throws<ValidationException>(()=>{user.Name="";// Empty name not allowed});}
12. Excessive Mocking
❌ Bad: Mocking everything
constmockValidator=jest.fn().mockReturnValue(true);constmockLogger=jest.fn();constmockMetrics=jest.fn();constmockConfig=jest.fn().mockReturnValue({timeout: 5000});constmockFormatter=jest.fn().mockReturnValue("formatted");// Testing nothing at this point