Agent skill
test-writer
Write comprehensive tests following TDD principles
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/test-writer-etroxtaran-conductor
SKILL.md
Test Writer Skill
When to Use
Use this skill when you need to:
- Write tests for new features
- Add tests for existing code (increase coverage)
- Write integration or E2E tests
Instructions
Step 1: Understand the Requirements
Read the acceptance criteria and identify:
- Happy path scenarios
- Edge cases
- Error conditions
- Integration points
Step 2: Choose Test Type
| Scenario | Test Type | Framework |
|---|---|---|
| Single function/class | Unit test | pytest / jest |
| Multiple components | Integration | pytest / jest |
| Full user flow | E2E | Playwright |
| API endpoints | API test | httpx / supertest |
Step 3: Write Tests
Unit Test Template (Python)
import pytest
from src.module import function_under_test
class TestFunctionName:
"""Tests for function_name."""
def test_happy_path(self):
"""Test normal operation."""
result = function_under_test(valid_input)
assert result == expected_output
def test_edge_case_empty_input(self):
"""Test with empty input."""
result = function_under_test([])
assert result == []
def test_error_invalid_input(self):
"""Test error handling for invalid input."""
with pytest.raises(ValueError, match="Invalid input"):
function_under_test(invalid_input)
Unit Test Template (TypeScript)
import { describe, it, expect } from 'vitest';
import { functionUnderTest } from '../src/module';
describe('functionName', () => {
it('should handle normal operation', () => {
const result = functionUnderTest(validInput);
expect(result).toEqual(expectedOutput);
});
it('should handle edge case with empty input', () => {
const result = functionUnderTest([]);
expect(result).toEqual([]);
});
it('should throw error for invalid input', () => {
expect(() => functionUnderTest(invalidInput)).toThrow('Invalid input');
});
});
Step 4: Run and Verify Failure
# Python
pytest tests/test_new_feature.py -v
# TypeScript
npm test -- tests/new-feature.test.ts
Tests MUST fail before implementation.
Step 5: Report
{
"status": "tests_written",
"tests_count": 5,
"test_file": "tests/test_feature.py",
"ready_for_implementation": true
}
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?