write-reliable-tests

Implement deterministic unit, integration, or end-to-end tests with setup, mocks, and cleanup.

3|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/alkofu/ai-tpk --skill write-reliable-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-reliable-tests
Source: https://github.com/alkofu/ai-tpk/tree/main/claude/skills/write-reliable-tests
Command: npx skills add https://github.com/alkofu/ai-tpk --skill write-reliable-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing tests that are deterministic, isolation-friendly, and easy to reason about, so CI and local runs produce reliable results.

Core Features & Use Cases

  • Determinism: Eliminate flaky tests by controlling time, randomness, and external dependencies.
  • Isolation & Cleanup: Each test uses isolated fixtures and robust cleanup to prevent interference.
  • Behavior-Oriented Assertions: Verify observable outcomes rather than internal implementation details.

Quick Start

Write a deterministic unit test scaffold for the feature under review, including setup, mocks, and cleanup.

Frequently Asked Questions about write-reliable-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write deterministic tests that don't fail randomly in CI?

Write deterministic tests by controlling time, randomness, and external dependencies through mocking. This eliminates flakiness by enforcing isolation, idempotency, and observable behavior assertions across your test suites.

What is the best way to isolate unit tests and prevent interference between runs?

The best way to isolate unit tests is using isolated fixtures with robust cleanup. This prevents test interference by ensuring each test runs independently without relying on shared state or leftover data from previous executions.

How do I mock external dependencies in integration testing?

Mock external dependencies in integration testing by replacing them with controlled substitutes during setup. This enforces determinism by ensuring tests verify code behavior without relying on unpredictable external systems or network conditions.

Why does my e2e testing fail randomly and how can I fix flaky tests?

E2e testing fails randomly due to uncontrolled time, randomness, or external dependencies causing flaky tests. Fix them by implementing clear setup, mocks, and cleanup to enforce test isolation and determinism.

Should I verify observable outcomes or internal implementation details in unit testing?

Verify observable outcomes rather than internal implementation details in unit testing. Behavior-oriented assertions ensure tests remain reliable and maintainable because they check what the code does, not how it does it internally.

Can I use this approach for both unit and end-to-end test suites?

Yes, you can apply determinism, isolation, and observable assertions across unit, integration, and end-to-end test suites. The approach scales by controlling external dependencies and enforcing idempotency regardless of test scope.