16-testing — Claude Code prompt: Vitest setup for the claude-code rebuild
The 16-testing prompt wires up Vitest in the claude-code project and writes tests for shims, tools, commands and context. It fires when the leaked-and-rebuilt source has no test suite at all.
no license ★ 3,444 updated 2026-10-14
.claude/commands/16-testing.mdWhat 16-testing does
The prompt walks through installing vitest and @types/node with bun add -d, writing a vitest.config.ts that aliases bun:bundle to src/shims/bun-bundle.ts, and a tests/setup.ts that loads src/shims/preload.js. It then lists the files to create: unit tests for bun-bundle.test.ts and macro.test.ts, smoke tests for tools.test.ts, commands.test.ts, context.test.ts and prompt.test.ts, integration tests for the API and MCP, and a build check on dist/cli.mjs.
The integration tests in tests/integration/api.test.ts and mcp.test.ts are meant to skip automatically when ANTHROPIC_API_KEY is absent and run the real checks once the key is set. An optional pre-commit hook chains bun run typecheck && bun run test, but only if the project already uses git hooks.
The whole plan assumes the claude-code sources already sit at /workspaces/claude-code and that functions like getTools(), getCommands(), getSystemContext() and getSystemPrompt() exist under those exact names, so it's tied to that specific reconstructed codebase rather than a generic project.
What it helps with
- bootstrap Vitest in a project that ships with zero tests
- check that
feature()inbun-bundlereturns correct flag values - write smoke tests that confirm tools, commands and the system prompt load
- skip API integration tests when
ANTHROPIC_API_KEYis missing - verify the built
dist/cli.mjsruns and answers--version
Example prompts for the agent
- Run the 16-testing prompt and set up Vitest in /workspaces/claude-code
- Write the tools.test.ts and commands.test.ts smoke tests from the 16-testing plan
- Add the MCP integration tests from part D of the 16-testing prompt
How to install 16-testing
Manually: put the files in place
.claude/commands/16-testing.mdHow to use
Paste the text at the start of a chat or into project instructions
Questions about 16-testing
How do I install 16-testing in Claude Code?
Save the file as .claude/commands/16-testing.md inside the project; it then shows up as a command in Claude Code.
What does 16-testing do?
It sets up a Vitest-based test suite and lays out unit, smoke, integration and build tests for the shims, tools, commands, context and system prompt in claude-code.
Does 16-testing need an API key for every test?
No. The API and MCP integration tests from part D skip automatically without ANTHROPIC_API_KEY and only run when the key is present.