claude-copilot: Skill for Claude Code

.claude/skills/testing/pytest-patterns/SKILL.md

pytest-patterns is a skill for Claude Code from Everyone-Needs-A-Copilot/claude-copilot. It costs 129 tokens per session (4,225 once invoked), scanned A, original, MIT.

A collection of pytest patterns and quality rules for Python test files. Pytest is a Python tool for running tests; the material covers fixtures, parameterized tests, mocks, and automatic checks for common test smells.

In plain words
What is it for?
Use it when writing or reviewing pytest tests, including fixtures, test data variations, mocked dependencies, and test-quality checks.
Why use it?
It helps keep tests clear, independent, and meaningful while consistently detecting empty tests, missing assertions, sleeps, and other structural problems.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths.

This is Everyone-Needs-A-Copilot/claude-copilot's own configuration. It tells Claude Code how to work on claude-copilot itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-copilot configures →

Part of the claude-copilot plugin — 73 skills, 18 commands, 16 agents, 6 hooks shipped together

Reuse

Borrowing it

Nothing to install: this file belongs to Everyone-Needs-A-Copilot/claude-copilot. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Everyone-Needs-A-Copilot/claude-copilot/main/.claude/skills/testing/pytest-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/Everyone-Needs-A-Copilot/claude-copilot

Made for: Claude Code.

Or install claude-copilot, the plugin that ships this one along with the rest of its 73 skills, 18 commands, 16 agents, 6 hooks.

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/everyone-needs-a-copilot/claude-copilot/pytest-patterns/github.svg)](https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns)
Your own site
<a href="https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns"><img src="https://agentmods.dev/badge/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pytest-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns"><img src="https://agentmods.dev/badge/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 129 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,225 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Data Exfiltration · line 287
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
How audits are shown
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.1 $0.00129 $0.04225
Opus 5.5 $0.00052 $0.01690
Sonnet 5.5 $0.00026 $0.00845
Haiku 4.5 $0.00013 $0.00422

Measured 1mo ago against content hash 85e10117406a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pytest-patterns scanned grade A with 1 finding 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 1mo ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/pytest_smell.py, scripts/test_pytest_smell.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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

mock_get = mocker.patch("requests.get")
.claude/skills/testing/pytest-patterns/SKILL.md · 470 lines

How it starts

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

Pytest Patterns

Modern pytest testing patterns, anti-patterns, and quality rules for Python.

pytest_smell.py detects structural test smells deterministically. The prose sections below cover judgment-level guidance that the script cannot evaluate. Never re-derive smell detection by eye when the script can do it; always run the script for consistent, auditable findings.

Core Principles

Principle Description
Fixtures over setup Use fixtures for test dependencies
Parametrize Test multiple cases without duplication
Explicit is better Clear test names and assertions
Fast isolation Each test runs independently

Patterns vs Anti-Patterns

Fixtures

# GOOD: Fixtures for test dependencies
@pytest.fixture
def db_session():
    """Provide a clean database session."""
    session = create_session()
    yield session
    session.rollback()
    session.close()

@pytest.fixture
def sample_user(db_session):
    """Create a sample user for tests."""
    user = User(name="John", email="[email protected]")
    db_session.add(user)
    db_session.commit()
    return user

def test_get_user(db_session, sample_user):
    result = get_user_by_id(db_session, sample_user.id)
    assert result.name == "John"

# BAD: Setup in each test
def test_get_user():
    session = create_session()
    user = User(name="John", email="[email protected]")
    session.add(user)
    session.commit()
    # ... test code
    session.rollback()  # Easy to forget cleanup!

Fixture Scopes

# GOOD: Appropriate fixture scopes
@pytest.fixture(scope="session")
def docker_db():
    """Start database container once per test session."""
    container = start_postgres_container()
    yield container
    container.stop()

@pytest.fixture(scope="module")
def api_client():
    """Create API client once per test module."""
    return APIClient(base_url="http://test.local")

@pytest.fixture  # Default: function scope
def clean_data(db_session):
    """Fresh data for each test."""
    yield
    db_session.query(User).delete()

# BAD: Wrong scope causes test pollution
@pytest.fixture(scope="session")  # DANGER!
def user():
    return User(name="John")  # Shared across all tests!

Read the full file on GitHub · 470 lines

Files

What ships with it

2 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. 1mo ago First seen · 470 lines · 129 tokens per session scan A 85e10117406a

Subscribe to this mod's changes

pytest-patterns is a skill published in the GitHub repository Everyone-Needs-A-Copilot/claude-copilot (14 stars, last pushed yesterday), licensed MIT. It adds 129 tokens to every session and 4,225 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.