test-writer

Enforce test-first development with strict mocking in Polibase projects.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/trust-chain-organization/polibase --skill test-writer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-writer
Source: https://github.com/trust-chain-organization/polibase/tree/main/.claude/skills/test-writer
Command: npx skills add https://github.com/trust-chain-organization/polibase --skill test-writer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, pytest-asyncio, and includes references (resource) and assets (resource) components.

What problem does it solve?

This Skill ensures that all tests in the Polibase project adhere to strict quality standards, preventing flaky tests, CI/CD failures, and unnecessary API costs. It guides developers through best practices like Test-Driven Development (TDD), proper mocking, and async testing, significantly reducing debugging time.

Core Features & Use Cases

  • TDD Workflow Guidance: Promotes a "Red-Green-Refactor" cycle, ensuring tests are written before implementation.
  • Critical Mocking Enforcement: Strictly forbids real external API calls in tests, enforcing AsyncMock with spec= to guarantee test isolation and determinism.
  • Async Test Best Practices: Guides on using pytest-asyncio for asynchronous code, preventing common pitfalls.
  • Use Case: When you're developing a new feature, this skill helps you write the initial failing test, then guides you to implement just enough code to pass it, and finally assists in refactoring, ensuring your code is robust and well-tested from the start.

Quick Start

I need to write a new unit test for the CreatePoliticianUseCase. Guide me through the TDD workflow and ensure I mock all external dependencies correctly.

Frequently Asked Questions about test-writer

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

FAQPage Schema
How do I write unit tests with proper mocking in pytest?

Writing unit tests with proper mocking in pytest means using AsyncMock with spec= to isolate external dependencies and prevent real API calls. This ensures tests are deterministic, fast, and independent of external services.

What's the best way to structure async tests with pytest-asyncio?

Structure async tests using pytest-asyncio by defining async test functions, applying the Arrange-Act-Assert pattern, using AsyncMock for external service calls, and enforcing await patterns throughout. This prevents common async pitfalls and ensures test reliability.

How do I implement Test-Driven Development with TDD workflows?

Test-Driven Development follows a Red-Green-Refactor cycle: write a failing test first, implement minimal code to pass it, then refactor. This approach ensures code is well-tested from the start and reduces debugging time significantly.

Why should I mock external services instead of making real API calls in tests?

Mocking external services prevents flaky tests, eliminates unnecessary API costs, ensures test determinism, and enables faster test execution. Strict mocking with spec= guarantees test isolation and reproducible results.

Can I use pytest-asyncio with strict mocking requirements?

Yes, pytest-asyncio works with strict mocking by combining AsyncMock with spec= for all external dependencies. This enforces test isolation and prevents accidental real API calls while supporting asynchronous test patterns.

What are the limitations of relying solely on unit tests for CI/CD quality?

Unit tests alone don't catch integration issues or infrastructure problems. Combine unit tests with integration and infrastructure layer tests, apply consistent mocking standards, and use CI/CD pipelines to ensure comprehensive coverage and prevent deployment failures.