/whoislewys-skills:unit-testfrom whoislewys-skills
Guidance for writing unit tests that verify observable behavior and public contracts rather than internal implementation. Use when writing, reviewing, or refactoring unit tests, deciding whether to mock or stub, or when tests are brittle and break on refactors.
Ships in whoislewys-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Effective unit testing focuses on what the code achieves (its behavior and public contract) rather than how it achieves it (its internal implementation). The primary goal of a test suite is to provide a safety net for fearless refactoring while ensuring reliability. When tests are tightly coupled to internal code structures, they become a liability—breaking during minor refactors even when the application still works perfectly. By shifting the focus to observable state changes and inputs/outputs, you write resilient tests that act as living documentation.
To confidently exercise every conceivable code path—including edge cases, boundary conditions, and error states—without creating brittle tests, structure your test suites around varying inputs and expected outcomes. Use data-driven testing patterns to pass diverse payloads into your public interfaces. If a specific edge case requires complex logic, don't reach for a mock to force the path; instead, construct the precise input state or leverage dependency injection to naturally guide the execution down that branch. This ensures that every code path is validated by real execution, not simulated assumptions.
Avoid writing tests that spy on internal method calls or verify that a specific collaborator was triggered. This binds your test tightly to the current syntax of the codebase.
# DON'T DO THIS
it "calls the payment service" do
expect(PaymentService).to receive(:call).with(user, amount)
CheckoutService.new(user, amount).process
end
Write your tests to assert that a concrete change happened (e.g., the user's balance updated, or an order record was created).
# DO THIS
it "processes the checkout and updates the user balance" do
expect {
CheckoutService.new(user, amount).process
}.to change { user.reload.balance }.by(-amount)
end
Why this works: By asserting the final state change, you are completely free to refactor
CheckoutServiceand its internal collaborators as much as you want without breaking your test suite, ensuring true agility.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
12 skills in this plugin
/c4-architectureGenerate architecture documentation using C4 model Mermaid diagrams. Use when asked to create architecture diagrams, document system architecture, visualize software structure, create C4 diagrams, or generate context/container/component/deployment diagrams. Triggers include "architecture diagram", "C4 diagram", "system context", "container diagram", "component diagram", "deployment diagram", "document architecture", "visualize architecture"./task-diagramuse when user asks for a "task diagram", or asks for help in performing "Applied Cognitive Task Analysis"/commitCreate a conventional commit message/explain-diff-htmlUse when the user asks for a rich explanation of a code change, diff, branch, or PR. Produces HTML output./fix-dep-auditResolve dependency security audit findings by preferring minor version upgrades to base packages first, then targeted fixes, verifying with pnpm audit after each change. Use when fixing dependency vulnerabilities or remediating a dependency audit./improve-readabilityCode readability principles from John Ousterhout's A Philosophy of Software Design, drawing on Ch. 2 (Nature of Complexity), 4 (Modules Should Be Deep), 10 (Define Errors Out of Existence), 13 (Comments Describe What Isn't Obvious), 14 (Choosing Names), 17 (Consistency), and 18 (Code Should Be Obvious). Covers obvious code, strategic naming, why-not-what comments, eliminating special cases, and visual grouping. Use when improving readability, naming variables, writing comments, or reviewing code for clarity and cognitive load.npx claudepluginhub whoislewys/skills --plugin whoislewys-skills