write-tests

Write regression tests using TDD, property-based testing, contract testing, and mutation scoring.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/vesviet/agent-skills --skill write-tests-vesviet
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-tests
Source: https://github.com/vesviet/agent-skills/tree/main/core/skills/foundation/write-tests
Command: npx skills add https://github.com/vesviet/agent-skills --skill write-tests-vesviet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing tests that actually catch regressions is hard: tests often mirror the implementation's assumptions, chase line coverage without real assertions, or flake due to shared database state and live network calls. This Skill enforces spec-driven, independently authored tests with verified failure phases, fault injection, and mutation-score quality gates. ## Core Features & Use Cases - Anti-Tautological TDD: Authors tests from immutable contracts (OpenAPI 3.1, Protobuf, Pact) before implementation, verifying a deterministic Red phase against baseline code. - Property-Based & Contract Testing: Verifies invariants like round-trip serialization and idempotency with Hypothesis or fast-check, and consumer-provider compatibility via PactV3 and can-i-deploy gates. - Chaos & Isolation: Injects latency and connection resets with Toxiproxy to verify circuit breakers, and runs Go Kratos services against ephemeral Testcontainers PostgreSQL with transactional rollbacks. - Use Case: When adding a new endpoint to a Go microservice, use this Skill to author failing spec-based tests first, spin up an isolated PostgreSQL container, inject network faults on downstream clients, and emit a test-report.json proving mutation score and race-freedom before release. ## Quick Start Use the write-tests skill to add regression coverage for my new payment endpoint, including property-based invariants and a contract test against the provider.

Frequently Asked Questions about write-tests

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

FAQPage Schema
How do I write tests that actually catch regressions instead of mirroring the code?▼

Author tests directly from immutable contracts like OpenAPI specs, Protobuf schemas, or feature tickets before writing any implementation code. Then run them against the baseline codebase to confirm they fail deterministically, proving the tests verify the specification rather than the implementation.

What is property-based testing and which tools support it?▼

Property-based testing verifies mathematical invariants like round-trip serialization and idempotency across thousands of generated inputs instead of hardcoded examples. Use fast-check for TypeScript, Hypothesis for Python, RapidCheck for C++, and proptest for Rust, all with automatic counter-example shrinking.

How do I test circuit breakers and retries without a real failing service?▼

Inject network faults in tests using Shopify/toxiproxy between the client and a mock service, adding latency, jitter, or connection resets. Then assert the circuit breaker transitions from CLOSED to OPEN to HALF-OPEN and verify fallback handling and single-canary probe recovery.

Why is high line coverage not enough for test quality?▼

Line coverage only proves code was executed, not that assertions verify correctness. Mutation testing introduces deliberate faults like inverted conditionals, and critical packages should kill at least 75-80% of mutants using tools like Stryker, mutmut, or cargo-mutants.

How do I prevent database tests from polluting shared state?▼

Run each subtest inside a GORM transaction and roll it back in cleanup, so no committed data leaks between tests. Combine this with ephemeral Testcontainers PostgreSQL instances and never use global database handles.

Can tests call live external APIs or LLM endpoints in CI?▼

No. Tests must run in an air-gapped sandbox with no network access, stubbing HTTP dependencies with MSW v2 or local fixtures. For LLM features, record real responses once as VCR cassettes and replay them deterministically in CI.