pytest-patterns

pytest-patterns is a skill for Claude Code, Codex from ruslan-korneev/claude-plugins. It costs 0 tokens per session (2,150 once invoked), scanned A, original, MIT.

A set of testing patterns for pytest, a Python framework for running automated tests, with examples aimed at FastAPI projects. It follows TDD: write a failing test, make it pass, then refactor the code.

In plain words
What is it for?
Use it when creating pytest tests, fixtures, or mocks, setting up FastAPI testing, or applying a test-first workflow to features and error cases.
Why use it?
It helps you write focused, readable tests instead of tests that are vague, overly broad, or difficult to maintain.

Skill for Claude CodeCodex

Part of the python plugin — 4 skills, 10 commands, 1 agent, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ruslan-korneev/claude-plugins/pytest-patterns
Any agent
npx skills add ruslan-korneev/claude-plugins --skill pytest-patterns
Clone the repo
git clone --depth 1 https://github.com/ruslan-korneev/claude-plugins

Made for: Claude Code, Codex.

Or install python, the plugin that ships this one along with the rest of its 4 skills, 10 commands, 1 agent, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytest-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/ruslan-korneev/claude-plugins/pytest-patterns.svg)](https://agentmods.dev/skills/ruslan-korneev/claude-plugins/pytest-patterns)
Your own site
<a href="https://agentmods.dev/skills/ruslan-korneev/claude-plugins/pytest-patterns"><img src="https://agentmods.dev/badge/skills/ruslan-korneev/claude-plugins/pytest-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,150 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02150
Opus 5 $0.00000 $0.01075
Sonnet 5 $0.00000 $0.00430
Haiku 4.5 $0.00000 $0.00215

Measured 3d ago against content hash 843e879cf727, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pytest-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (examples/conftest.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/python/skills/pytest-patterns/SKILL.md · 351 lines

How it starts

The opening of the file, as written. The whole thing — 351 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pytest Patterns

Quality testing patterns with pytest for FastAPI projects. TDD-first approach.

Triggers

Use this skill when the user:

  • Wants to write tests
  • Asks about pytest, fixtures, mocks
  • Wants to set up testing for FastAPI
  • Uses TDD approach

Main Principle: TDD

  1. Red — write a failing test
  2. Green — write minimal code
  3. Refactor — improve while keeping tests green

What Makes a Good Test

1. Clear Name

# ✅ Good — describes what, when, and expectation
async def test_create_user_with_valid_data_returns_user_with_id():
async def test_create_user_with_duplicate_email_raises_conflict_error():
async def test_get_user_by_id_when_not_exists_raises_not_found():

# ❌ Bad
async def test_create_user():
async def test_user():
async def test_1():

2. Single Responsibility

# ✅ Good — one test = one scenario
async def test_create_user_returns_user_with_id(service):
    result = await service.create(user_data)
    assert result.id is not None

async def test_create_user_saves_email(service):
    result = await service.create(user_data)
    assert result.email == user_data["email"]

# ❌ Bad — tests multiple things
async def test_create_user(service):
    result = await service.create(user_data)
    assert result.id is not None
    assert result.email == user_data["email"]
    assert result.created_at is not None
    assert await service.get(result.id) == result

3. Arrange-Act-Assert

async def test_create_order_calculates_total(service):
    # Arrange — prepare data
    items = [
        {"product_id": 1, "quantity": 2, "price": 100},
        {"product_id": 2, "quantity": 1, "price": 50},
    ]

    # Act — execute action
    order = await service.create(items=items)

    # Assert — verify result
    assert order.total == 250

4. Isolation

Tests should not depend on each other:

# ✅ Good — each test is independent
@pytest.fixture
async def session(engine):
    async with engine.connect() as conn:
        await conn.begin()
        async with AsyncSession(bind=conn) as session:
            yield session
        await conn.rollback()  # Rollback after each test

# ❌ Bad — shared state
_created_user = None

async def test_create_user(service):
    global _created_user
    _created_user = await service.create(data)

async def test_get_user(service):
    user = await service.get(_created_user.id)  # Depends on previous test!

Read the full file on GitHub · 351 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 351 lines · 0 tokens per session scan A 843e879cf727

Subscribe to this mod's changes

pytest-patterns is a skill published in the GitHub repository ruslan-korneev/claude-plugins (4 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,150 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

pest-testing

Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to…

coollabsio/coolify · 171 tokens

write-vibe-tests

Write or refactor Mistral Vibe tests with proper decoupling. Use when adding behavior coverage, testing ports/adapters, replacing brittle mocks, creating fakes, adding characterization tests before refactors, or changing tests under tests/ for vibe/core, vibe/cli, vibe/acp, tools, config, sessions, skills, hooks, MCP…

mistralai/mistral-vibe · 80 tokens

composing-matchers

Build compound Gomega assertions by combining matchers — And/SatisfyAll (all pass), Or/SatisfyAny (any pass), Not (negate), WithTransform to map the actual before matching, Satisfy for an ad-hoc predicate, HaveValue to dereference pointers/interfaces, HaveField for struct fields and method results, HaveEach for every…

onsi/gomega · 136 tokens

adding-dbt-unit-test

Creates unit test YAML definitions that mock upstream model inputs and validate expected outputs. Use when adding unit tests for a dbt model or practicing test-driven development (TDD) in dbt.

dbt-labs/dbt-agent-skills · 44 tokens

testing-guide

Design, write, run, and diagnose Synergy tests with Bun, temporary Scope isolation, deterministic fixtures, and behavior-first assertions. Use for TDD, bug regressions, feature tests, migration tests, flaky tests, coverage, package tests, frontend tests, and selecting verification gates.

SII-Holos/synergy · 60 tokens

test

Generate tests and coverage plans. Triggers: "test", "generate tests and coverage plans.", "test skill".

boshu2/agentops · 25 tokens