Guide · Agent skill
How to use the Python Testing with pytest agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The python-testing skill is a set of written pytest guidance and code examples that an AI agent reads when you ask it to write or improve Python tests. It is useful for Python developers, teams adding coverage to an existing project, and people learning pytest conventions. After this guide you will know how to install the skill, how to phrase requests so it triggers, and what to check before trusting the output.
Quick start
- 1Download the ZIP. Download the python-testing ZIP from the skill page on this site.
- 2Unzip the skill folder. Unzip it so the folder containing SKILL.md sits in ~/.claude/skills/ or the project's .claude/skills/ folder.
- 3Or upload it in the apps. In the Claude apps, go to Settings → Capabilities → Skills and upload the skill.
- 4Make sure pytest is available. Install pytest and any optional plugins your project needs, such as pytest-cov or pytest-mock, in your own environment.
- 5Ask for tests in plain language. Describe the code to test and the kind of tests you want, such as fixtures, parametrized cases or coverage.
- 6Run the tests yourself. Have the agent run pytest, then read the results and failures before accepting the changes.
What the skill makes the agent do
Once installed, the agent follows pytest best practices when you ask it to write or improve Python tests. The skill covers how to structure test files and functions, reuse setup code with fixtures, run one test with many inputs using parametrization, replace real dependencies with mocks, measure coverage, and test async code.
The skill is written guidance and examples. It does not run anything by itself, so the agent must still execute pytest commands in your environment.
- Test discovery conventions: files named test_*.py or *_test.py, functions and methods named test_*, and classes named Test*
- Fixtures with scopes (function, class, module, session) and fixture dependencies
- Parametrization with @pytest.mark.parametrize, including custom ids
- Markers such as unit, integration and slow, plus skip and skipif
- Mocking with unittest.mock and the pytest-mock plugin
- Coverage commands with pytest-cov, including HTML reports and branch coverage
- Async tests with pytest-asyncio and conftest.py organisation
Install the python-testing skill
Download the ZIP from the skill page on this site and unzip it. The skill is a folder containing SKILL.md. Put that folder in one of two places depending on how you want to use it.
For a personal setup available across projects, unzip it into ~/.claude/skills/. For a single project, unzip it into the project's .claude/skills/ folder so it applies only there.
You can also upload the skill in the Claude apps under Settings → Capabilities → Skills.
- Personal: ~/.claude/skills/
- Project only: .claude/skills/ inside your project folder
- Claude apps: Settings → Capabilities → Skills, then upload
Check what the skill needs
The skill assumes a Python project that uses pytest. The source lists pytest as required and these as optional, used depending on the task: pytest-mock, pytest-cov, pytest-asyncio, and SQLAlchemy for the database example.
The skill does not run scripts and does not use the network. Install any optional packages your project needs in your own environment before asking the agent to run tests.
- Required: Python and pytest
- Optional: pytest-mock, pytest-cov, pytest-asyncio, SQLAlchemy
Trigger the skill with natural requests
The skill's description says to use it when writing or improving Python tests, so ordinary requests tend to trigger it. Name the file or behaviour you care about and say what kind of test you want. You do not need special syntax.
Good requests say what to test, where the code lives, and any constraints such as speed or coverage targets.
- "Write pytest tests for validate_email in src/validators.py, covering empty and malformed inputs."
- "Add a fixture for the database session in tests/conftest.py and write repository tests with it."
- "Improve the tests in tests/unit/test_services.py using mocks for the email service."
- "Add async tests for fetch_user and report branch coverage for src."
Example: asking for coverage and markers
For coverage, the skill shows commands such as pytest --cov=src --cov-report=term-missing and a branch coverage variant. It also shows how to set a minimum with --cov-fail-under in a pytest.ini or pyproject.toml configuration.
For selective runs, the skill shows marker commands. Ask the agent to mark slow tests and run only the fast ones, then have it execute the commands to confirm.
pytest --cov=src --cov-report=term-missing
pytest -m "not slow"Safety notes and tips
The skill contains no scripts and makes no network calls, but the agent that uses it can run commands on your machine. Review any command it proposes before approving it, especially ones that modify files or install packages.
Check generated tests by running them. The skill tells the agent how to write tests, not whether the code under test is correct. Keep tests in version control so you can review changes.
Some examples in the source are sketches that depend on your own code, such as User, UserRepository and validate_email. Replace these with your real names and imports.
- Read proposed commands before the agent runs them
- Run the generated tests and review failures rather than assuming they pass
- Adapt example imports and names to your project
What people use it for
- Writing unit tests for validation functions using parametrized inputs
- Adding fixtures for a database session in a shared conftest.py
- Replacing real email or repository dependencies with mocks in service tests
- Measuring branch coverage and enforcing a minimum threshold for a Python project
- Writing async tests for coroutine functions with pytest-asyncio
Frequently asked questions
Is the python-testing skill free?
The skill is published under the MIT licence, according to this listing. Check the licence file in the source repository for the full terms before redistributing it.
What do I need to use the python-testing skill?
You need Python and pytest. Optional packages such as pytest-mock, pytest-cov, pytest-asyncio and SQLAlchemy are used by some examples. The skill runs no scripts and uses no network.
Where do I install a Claude skill?
Unzip the skill folder into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder for one project. You can also upload it in the Claude apps under Settings → Capabilities → Skills.
Does the skill run my tests for me?
No. The skill is written guidance and examples. The agent must still execute pytest commands in your environment to run tests or check coverage.
Can I use this skill if my project uses unittest?
It is not a good fit. The skill recommends pytest as the primary tool, so its conventions assume pytest rather than unittest-only patterns.
How does this compare with asking an agent to write tests without a skill?
The skill gives the agent a consistent set of pytest conventions for fixtures, parametrization, mocks, markers and coverage. Without it, the agent chooses its own patterns, which may vary between sessions.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Choose this skill if you work in Python with pytest and want an agent to produce consistent, idiomatic tests with fixtures, parametrization and coverage commands. Pick something else if your project does not use Python or pytest, or if you need unittest-only conventions, since the skill recommends pytest as its primary tool. It will not run tests on its own, so you still need to execute and review the results.
Download the skill