skills/writing-unit-test/SKILL.md
Guide for writing a unit test. Use when writing a unit test for functions or components, and when fixing a bug in existing code.
npx skillsauth add rakaadi/agent-kit writing-unit-testInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill is a focused companion to the globally installed tdd skill from mattpocock/skills.
Before using this skill:
tdd skill if it is not already available.tdd skill's reference docs: tests.md, mocking.md, interface-design.md, and deep-modules.md.See README.md for install instructions and the rationale for keeping this skill separate.
Core principle: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
Use the global tdd skill's examples and reference docs as the canonical source for interface design, mocking, and broader TDD guidance.
tdd skill's guidance for mocking and interface designtdd skill referencesAsk: "What should the public interface look like? Which behaviors are most important to test?"
You can't test everything. Confirm with the user exactly which behaviors matter most. Focus testing effort on critical paths and complex logic, not every possible edge case.
development
Use when you have a spec or requirements for a multi-step task, before touching code. Supports either Markdown plans or review-oriented HTML plan artifacts.
documentation
Protocol for dispatching subagents effectively. Use this skill EVERY TIME you are about to delegate work to a custom or built-in agent. Covers when to dispatch, which agent to pick, how to write self-contained prompts, and parallel execution. Trigger phrases: "delegate to agent", "dispatch subagent", "run agent", "use subagent", "context isolation", "parallel agents".
development
Guide for code refactoring, use this skill to guide you when user asked to refactor a components or functions and when an implementation of a plan requiring a code refactoring.
development
Guide for debugging issue on a specific code sections, pattern, or files. Used this skill when user asking for assistant when debugging an issues or explaining a code.