test-writer

Enforce strict mocking and async patterns in pytest-based tests.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps ensure robust test suites by enforcing strict mocking, asynchronous patterns, and test independence to prevent CI failures and API costs.

Core Features & Use Cases

  • Enforces mock-based testing for external services to avoid real API calls.
  • Promotes async/await patterns and proper use of pytest-asyncio for asynchronous tests.
  • Encourages test independence, deterministic results, and clear verification of mock interactions.
  • Use Case: When adding or updating tests in the tests/ directory, this skill guides test-first development and ensures CI-friendly practices.

Quick Start

  • Create new tests in tests/ using pytest with AsyncMock and pytest-asyncio.
  • Run tests locally with pytest and verify mock interactions (e.g., assert_awaited_once, assert_called_once).
  • Refactor tests to maintain independence and avoid external dependencies as you iterate.

Frequently Asked Questions about test-writer

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

FAQPage Schema
How do I prevent flaky pytest tests when testing asynchronous code?

Prevent flaky pytest tests by enforcing test independence, strict mocking, and deterministic results. Use AsyncMock for async dependencies and pytest-asyncio to manage asynchronous execution without external API calls.

How do I mock async dependencies in pytest without making real API calls?

Mock async dependencies in pytest by using AsyncMock to replace external services. This enforces strict mock-based testing, guarantees test independence, and prevents real API calls to avoid CI failures and API costs.

What is the best way to verify mock interactions in async pytest test suites?

Verify mock interactions in async pytest test suites by using strict mock verification methods like assert_awaited_once and assert_called_once. This ensures deterministic results and validates that your async code executes as expected.

Does pytest-asyncio work with strict mocking for test-driven development?

pytest-asyncio works with strict mocking by enabling async test execution while AsyncMock handles asynchronous dependencies. This combination supports test-driven development by ensuring test independence and deterministic results.

Why does my test suite fail in CI due to external API calls and flaky tests?

Test suites fail in CI due to external API calls and flaky tests because they lack test independence and deterministic results. Enforcing strict mocking with AsyncMock prevents external calls, reducing CI failures and API costs.