Write Tests
Generate comprehensive tests for the current file or function.
What happens when you install it
You run the install command
mcp install-skill write-testsMCPHub CLI downloads this prompt from the registry.
Saved as a file in Claude Code
~/.claude/commands/write-tests.mdClaude Code reads all .md files in this folder as slash commands.
Use it in any conversation
/write-testsin Claude Code (after restart)Claude runs the prompt against your current file or selection — no copy-paste needed.
Content
Write Tests
Write comprehensive tests for the selected code. Tests should be a first-class citizen, not an afterthought.
What to cover
- Happy path — the expected, normal usage
- Edge cases — empty inputs, boundary values, large inputs
- Error conditions — invalid inputs, network failures, missing dependencies
- Concurrent access — if the code deals with shared state
Rules
- Use the testing framework already present in the project (Jest, Vitest, pytest, Go testing, etc.)
- Mock external dependencies: databases, APIs, filesystem, time, randomness
- Each test name should read like a sentence: "returns empty array when no users exist"
- Group related tests in
describeblocks with a clear subject - Test behavior, not implementation — don't test private methods
- Prioritize meaningful tests over coverage percentage
Structure per test
// Arrange — set up state and dependencies
// Act — call the function under test
// Assert — verify the outcome
Output
Output only the test code, ready to run. No explanations unless a specific test choice needs justification.
Install
After install, restart Claude Code and type:
/write-testsRequires MCPHub CLI
Author

MCPHub
github.com/sallyhellerLooking for Agents?
Agents run with a full system prompt and persistent behavior — not just a one-off command.
Browse agents →