Skip to main content
skill CX Codex

writing-unit-tests — Claude Code skill for unit tests and setup

Guides an agent through writing or revising unit tests around observable behavior. Useful for flaky tests, confusing cases, and new test coverage.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add riekelt/principal-engineer --skill writing-unit-tests -a claude-code
Open on GitHub

What writing-unit-tests does

The skill treats each unit test as a claim about what callers can observe. It recommends a separate, clearly named test for each behavior, with expected values worked out independently of production calculations. Tests should exercise the public contract rather than inspect private state or routine call order.

For repeatable results, it calls for isolating time, randomness, network access, and filesystem work, with mocks placed at boundaries to external resources. Replace timed sleeps with checks for an observable condition and a deadline. The principal-engineering skill is a prerequisite; testing-changes determines which tests a code change needs. If a test mostly wires up mocks, the tested boundary may need to move or be covered by an integration test instead.

What it helps with

  • split multiple behavioral claims into focused tests
  • replace sleep-based waiting with condition checks
  • remove mocks of code owned by the project
  • isolate tests from real time and randomness
  • verify expected values without reproducing production calculations

Example prompts for the agent

  • Rewrite this unit test to check the public contract and state its claim in the test name.
  • Diagnose this flaky test and replace its timed wait with a condition-based check.
  • Add separate tests for the success case and the typed failure.

How to install writing-unit-tests

1Skills CLI (Vercel)

npx skills add riekelt/principal-engineer --skill writing-unit-tests -a claude-code

2Manually: put the files in place

~/.claude/skills/writing-unit-tests/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/writing-unit-tests/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about writing-unit-tests

How do I install writing-unit-tests in Claude Code?

Run npx skills add riekelt/principal-engineer --skill writing-unit-tests -a claude-code. The skill file is available at ~/.claude/skills/writing-unit-tests/SKILL.md.

What does writing-unit-tests do?

It guides an agent to write unit tests around observable behavior, with one claim per test. It favors public contracts and mocks at boundaries to resources outside the code's ownership.

What should I install before using the skill?

The skill requires principal-engineering first. testing-changes governs which tests are needed for a particular change.

Similar skills

All skills for Testing and QA →

From the same set9

guarding-architecture Enforces system boundaries by turning structural invariants into breaking build tests. Useful when code crosses module limits or adds unwanted cross-package imports. CX Codex +1 18,000installs verifying-before-done An agent skill that forces a check on the changed code's real surface and a pasted verify output before any completion claim goes out. CX Codex +1 17,800installs principal-engineering Enforces core engineering discipline for AI agents: mandates pre-change checkpoints, bans silent error suppression, and requires evidence from real code. CX Codex +1 18,000installs adding-dependencies This skill helps decide whether a project needs a dependency and how to assess and update it. Use it before adding a package, SDK, or GitHub Action. CX Codex +1 17,700installs operating-safely Sets safety guards for destructive commands, secret handling, and parallel edits. It activates before dangerous operations like deleting data or restarting live processes. CX Codex +1 17,900installs scoping-changes Keeps a fix tied to the problem that triggered it and makes partial delivery explicit. Use it when a task starts growing or an approved plan needs to be split. CX Codex +1 17,700installs keeping-one-source-of-truth An agent skill that keeps each fact in exactly one place and stops copies from drifting apart. Useful the moment a value begs to be pasted elsewhere. CX Codex +1 17,700installs testing-changes Defines test requirements for code changes, enforcing regression tests for bug fixes, edge-case coverage, and strict checks against empty test diffs. CX Codex +1 17,900installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor