← All skills
Prompt · Slash command✓ Verified

Write Tests

Generate comprehensive tests for the current file or function.

What happens when you install it

1

You run the install command

mcp install-skill write-tests

MCPHub CLI downloads this prompt from the registry.

2

Saved as a file in Claude Code

~/.claude/commands/write-tests.md

Claude Code reads all .md files in this folder as slash commands.

3

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 describe blocks 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

mcp install-skill write-tests

After install, restart Claude Code and type:

/write-tests

Requires MCPHub CLI

Looking for Agents?

Agents run with a full system prompt and persistent behavior — not just a one-off command.

Browse agents →