cwinvestments/memstack/test-writer
Claude Code and agent skill by cwinvestments/memstack
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use this skill when the user says 'write tests', 'add tests', 'test coverage', 'unit tests', 'integration tests', 'component tests', 'mocking', 'edge cases', or needs to generate tests with proper mocking and edge case coverage. Do NOT use for refactoring plans or database migrations.
Install
npx vskill@latest install cwinvestments/memstack/test-writerSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as cwinvestments/memstack/test-writer.
Test Writer: Generating test suite...
Generates comprehensive test suites with unit, integration, and e2e tests, proper mocking strategies, edge case coverage, naming conventions, and CI integration patterns.
Activation
When this skill activates, output:
Test Writer: Generating test suite...
Then execute the protocol below.
Context Guard
| Context | Status | |
|---|---|---|
| User says "write tests", "add tests", "test coverage" | ACTIVE | |
| User says "unit tests", "integration tests", "component tests", "e2e tests" | ACTIVE | |
| User says "mocking", "edge cases", "test this function" | ACTIVE | |
| User wants to refactor existing code | DORMANT: use Refactor Planner | |
| User wants to change database schema | DORMANT: use Migration Planner |
Common Mistakes
| Mistake | Why It's Wrong | |
|---|---|---|
| "Testing implementation, not behavior" | Tests that break when you refactor internals are brittle. Test WHAT it does, not HOW. | |
| "No edge cases" | Happy path tests catch 20% of bugs. Boundaries, nulls, empty inputs, and error paths catch the rest. | |
| "Mocking everything" | Over-mocking creates tests that pass but don't catch real bugs. Mock boundaries, not internals. | |
| "Test names like test1, test2" | Names should describe behavior: "returns empty array when no items match filter". Self-documenting tests. | |
| "No test isolation" | Tests that depend on each other or shared state create flaky test suites that nobody trusts. |
Protocol
Step 1: Gather Test Requirements
If the user hasn't provided details, ask:
1. Target: what code needs tests? (function, class, module, API endpoint)2. Language/framework: what tech stack? (JS/TS + Jest/Vitest, Python + pytest, Go, etc.)3. Test level: unit, integration, e2e, or all three?4. Current coverage: any existing tests? What percentage?5. Priority: critical paths first, or comprehensive coverage?
Step 2: Analyze the Code Under Test
Before writing tests, understand the target:
Function/method analysis:
| Property | Value | |
|---|---|---|
| Inputs | [Parameters, types, optional/required] | |
| Outputs | [Return type, side effects, thrown exceptions] | |
| Dependencies | [External calls: DB, API, file system, other modules] | |
| State changes | [What mutates: database records, cache, global state] | |
| Branching paths | [Number of if/else/switch branches] | |
| Error conditions | [What can fail and how it's handled] |
Dependency map:
Mock decision rule:
- Mock external boundaries: databases, APIs, file system, network, time
- Don't mock pure functions, internal utilities, simple data transformations
- Sometimes mock sibling modules (mock for unit tests, real for integration)
Step 3: Design Test Cases
Coverage strategy: identify all test scenarios:
Happy path tests:
| # | Scenario | Input | Expected Output | |
|---|---|---|---|---|
| 1 | [Normal case with typical input] | [Input] | [Output] | |
| 2 | [Normal case with different valid input] | [Input] | [Output] |
Edge case tests:
| # | Category | Scenario | Input | Expected Output | |
|---|---|---|---|---|---|
| 1 | Boundaries | Minimum valid value | [Input] | [Output] | |
| 2 | Boundaries | Maximum valid value | [Input] | [Output] | |
| 3 | Boundaries | Exactly at limit | [Input] | [Output] | |
| 4 | Empty | Empty string / array / object | "" / [] / {} | [Output] | |
| 5 | Null/Undefined | Null input | null | [Output or error] | |
| 6 | Type coercion | Unexpected type | "123" vs 123 | [Output] | |
| 7 | Large input | Very large dataset | [X items] | [Output / perf] | |
| 8 | Unicode | Special characters | "café ñ 中文" | [Output] | |
| 9 | Concurrent | Race condition scenario | [Parallel calls] | [Consistent state] |
Error path tests:
| # | Error Condition | Input | Expected Behavior | |
|---|---|---|---|---|
| 1 | Invalid input | [Bad input] | Throws [ErrorType] with message | |
| 2 | Dependency failure | [DB timeout] | Returns fallback or propagates error | |
| 3 | Permission denied | [Unauthorized] | Returns 403 / throws AuthError | |
| 4 | Not found | [Missing resource] | Returns null or throws NotFoundError |
Step 4: Write the Tests
Test file naming conventions:
| Framework | Convention | Example | |
|---|---|---|---|
| Jest / Vitest | [name].test.ts or [name].spec.ts | userService.test.ts | |
| pytest | test_[name].py | test_user_service.py | |
| Go | [name]_test.go | user_service_test.go | |
| JUnit | [Name]Test.java | UserServiceTest.java |
Test naming conventions:
| Style | Pattern | Example | |
|---|---|---|---|
| Behavior-driven | should [expected] when [condition] | should return empty array when no items match filter | |
| Given-When-Then | given [state] when [action] then [result] | given expired token when authenticating then throws AuthError | |
| Method-focused | [method], [scenario], [expected] | calculateTotal, with discount: applies percentage reduction |
Test structure template (JavaScript/TypeScript):
Test structure template (Python):
Step 5: Mocking Strategy
Mock patterns by dependency type:
| Dependency | Mock Approach | Example | |
|---|---|---|---|
| Database | Mock repository/ORM layer | jest.spyOn(db, 'query').mockResolvedValue(rows) | |
| HTTP API | Mock HTTP client or use MSW/nock | nock('https://api.example.com').get('/users').reply(200, data) | |
| File system | Mock fs module or use memfs | jest.mock('fs/promises') | |
| Time/Date | Fake timers | jest.useFakeTimers(); jest.setSystemTime(new Date('2026-01-15')) | |
| Random | Seed or mock | jest.spyOn(Math, 'random').mockReturnValue(0.5) | |
| Environment | Set/restore env vars | process.env.NODE_ENV = 'test' in beforeEach | |
| Third-party SDK | Mock the client | jest.mock('stripe', () => mockStripeClient) |
Mock verification patterns:
Step 6: Integration & E2E Tests
Integration test patterns:
E2E test patterns (API):
Step 7: Coverage & CI Integration
Coverage targets:
| Level | Target | Rationale | |
|---|---|---|---|
| Critical paths (auth, payments, data writes) | >90% | Bugs here = revenue loss or security issues | |
| Business logic (services, domain) | >80% | Core value: must work correctly | |
| Utilities / helpers | >70% | Important but lower risk | |
| UI components | >60% | Visual testing often complements | |
| Overall project | >75% | Healthy baseline |
CI configuration template (GitHub Actions):
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/development/test-writer/SKILL.md
Popularity
- Repository stars
- 412
- Repository forks
- 45
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cwinvestments/memstack/test-writer)