python-testing
Skill2 starsChanged 3 months agoApache-2.0View on GitHub
Adds or updates pytest coverage for a Python change by first discovering the repository's existing test layout and conventions, matching them rather than imposing a new structure, deciding whether the change requires a test at all, and running the suite in a bounded verify loop. Use when a Python change adds behavior, fixes a bug, changes a public interface, or touches security-relevant logic, and when deciding where a new test belongs in an unfamiliar repository.
33 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- fmind/dottheir own version, first seen Oct 5, 2026
- ComposioHQ/composiotheir own version, first seen Sep 29, 2026
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- IAbuElRuzz/AgentSkillstheir own version, first seen Sep 16, 2026
- Paldom/python-skillstheir own version, first seen Sep 10, 2026
- konstruktoid/prescrybedited, first seen Aug 15, 2026
Used with
Projects with it also use swift-protocol-di-testing, springboot-tdd and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
InfopibeSkillswift-protocol-di-testing
Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.
Also in 6 projects that use this
FaisalAlqarniSkillspringboot-tdd
Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Use when adding features, fixing bugs, or refactoring.
Also in 9 projects that use this
FaisalAlqarniSkilldjango-verification
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
Also in 9 projects that use this
InfopibeSkillswift-actor-persistence
Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.
Also in 6 projects that use this
johnrtiptonSkilldjango-security
This skill should be used when conducting security reviews, auditing Django applications, hardening security settings, implementing OWASP Top 10 protections, managing secrets, or ensuring multi-tenant security isolation. Provides automated security auditor that scans settings, code, dependencies, and multi-tenant configurations with auto-fix capabilities.
Also in 9 projects that use this
joneqianSkillpostgres-patterns
PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.
Also in 12 projects that use this
- +1 more from FaisalAlqarni
- +3 more from Infopibe
Other versions33 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- konstruktoid/prescryb★ 196% same
Wrote their own version · 32
- ComposioHQ/composio★ 30ksame name
- microsoft/agent-framework★ 14ksame name
- xu-xiang/everything-claude-code-zh★ 2ksame name
- loulanyue/awesome-claude-notes★ 272same name
- Mindrally/skills★ 266same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- Jamkris/everything-gemini-code★ 87same name
- codelably/harmony-claude-code★ 43same name
- noah-sheldon/ai-dev-kit★ 13same name
22 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 6 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 28 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Add pytest coverage that fits the repository it lands in.
- Distinctive: line 48
Discover the existing layout before writing anything: Do not assume a structure.
- Very specific: line 52
Read two or three existing tests near the code being changed.
- Very specific: line 55
Check for markers (slow, integration, network) and what the default run excludes.
- Distinctive: line 65
Keep each test independent: no shared mutable state, no ordering assumptions, no reliance on network or wall-clock time.
- Distinctive: line 67
Keep the machine out of the test.
- Very specific: line 73
Follow instructions/python_coding_instructions.md for the test code itself.
- Very specific: line 93
Run the repository's own entry point, not a bare pytest invocation, when one exists: a tox env, a Makefile target, or the command in …
- Distinctive: line 111
Stop early, before 3 attempts, if the loop is oscillating: the same failures recur, the count stops dropping, or a fix for one failure …
- Distinctive: line 113
When stopping for either reason, report to the user rather than proceeding or silently giving up.
- Very specific: line 116
Never weaken a test, mark it xfail, or skip it to get a green run.
- Very specific: line 119
No hook enforces that rule here.
“Common” is measured: kept by at least 6 in 10 of the 28 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
python-testing
Purpose
Add pytest coverage that fits the repository it lands in. Most test damage comes from writing tests before reading the ones already there: a second fixture style, a parallel directory layout, or a mocking convention the project deliberately avoids. This skill orders the work as discover, decide, write, verify.
When to use this
- A Python change adds behavior, fixes a bug, or changes a public interface.
- A change touches security-relevant logic (input validation, authorization, crypto, secrets).
- Deciding where a test belongs in a repository whose layout is unfamiliar.
When NOT to use this
- Non-Python changes.
- Repositories that use a test framework other than pytest. Follow what is there instead; do not introduce pytest alongside an existing framework.
Steps
- Discover the existing layout before writing anything. Do not assume a structure.
- Find the test root:
tests/,test/, alongside the source astest_*.py, or inside the package. Checkpyproject.toml,pytest.ini,setup.cfg, andtox.inifortestpaths,python_files,addopts, and marker definitions. - Read two or three existing tests near the code being changed. Note the naming pattern, how
fixtures are shared (
conftest.py, factory functions, plain constructors), whether parametrization is used, and what the project mocks versus exercises for real. - Check for markers (
slow,integration,network) and what the default run excludes.
- Find the test root:
- Decide whether a test is required. See the table below. If a test is not required, say so and why, rather than silently skipping it.
- Write the test in the discovered style. Match the existing naming, fixture, and assertion
conventions. Do not introduce a new helper layer, a new mocking library, or a new directory
when the repository already has an answer.
- Assert on behavior and public interfaces, not on internal call sequences, unless the call itself is the contract.
- For a bug fix, write the test so it fails against the unfixed code. Confirm that it does before applying the fix, or by reverting the fix once.
- Keep each test independent: no shared mutable state, no ordering assumptions, no reliance on network or wall-clock time.
- Keep the machine out of the test. A home-directory path, username, hostname, or real email
address baked into a fixture, an expected value, or a recorded snapshot is both a test that
only passes on one machine and information the repository has no reason to publish. Use
tmp_path,monkeypatch, and placeholders, and normalize captured paths before asserting on them or committing a snapshot.
- Run the suite in the bounded verify loop below.
- Follow
instructions/python_coding_instructions.mdfor the test code itself. Test files are source, and the sameruff/tygate applies to them.
When a test is required versus optional
| Change | Test |
| New function, class, or public interface | Required |
| Bug fix | Required, and it must fail without the fix |
| Changed behavior of existing code | Required, updating the existing test rather than adding a parallel one |
| Input validation, authorization, crypto, or secret handling | Required, including the rejection and failure paths |
| Refactor with no behavior change | Not required; existing tests must pass unchanged, and that is the evidence |
| Formatting, comments, docstrings, type annotations | Not required |
| Generated code or vendored dependencies | Not required unless the repository already tests them |
For anything else, ask what would have to break for the change to be wrong, and whether an existing test would catch it.
Verify
Run the repository's own entry point, not a bare pytest invocation, when one exists: a tox
env, a Makefile target, or the command in .github/workflows/*.yml. Through the package manager
where one is configured, for example uv run pytest.
- The full suite passes, not only the new tests.
- The new test fails against the unfixed or unchanged code, for a bug fix or a behavior change.
- Coverage tooling, if the repository has it configured, shows no drop. Do not add a coverage tool that is not already there.
The bounded loop
One attempt is one full fix-and-rerun cycle: apply fixes for the failures from the previous run, then rerun the suite to completion. Reading output, or re-reading a file without changing anything, is not an attempt.
- Baseline the loop at 3 attempts.
- Continue past 3 only while making measurable progress, meaning each cycle ends with strictly fewer failures than the one before it.
- Stop early, before 3 attempts, if the loop is oscillating: the same failures recur, the count stops dropping, or a fix for one failure reintroduces another.
- When stopping for either reason, report to the user rather than proceeding or silently giving up. Name the failing test, include its output, and state what was tried.
Never weaken a test, mark it xfail, or skip it to get a green run. If a test is wrong, fix the
test and say why it was wrong.
No hook enforces that rule here. instructions/agent_configuration_instructions.md covers
which rules need a mechanism rather than prose alone, and where one belongs.
Verification checklist
- Existing test layout and conventions read before writing, and matched
- No new test framework, directory, or mocking library introduced alongside an existing one
- Test required by the table above was written, or its absence explained
- For a bug fix, the test was confirmed to fail without the fix
- Full suite run through the repository's own entry point, to a clean result or to a stop under the loop rules above, with failures reported
ruff check,ruff format --check, andty checkclean on the test files too- No test weakened, skipped, or marked
xfailto obtain a green run - Tests are independent of ordering, network access, and wall-clock time
- No home-directory path, username, hostname, or real email address in test code, fixtures, or committed snapshots; anything machine-specific is generated or normalized
References
Paths starting instructions/ are relative to this library's root. When this skill is installed
as a Claude Code plugin, read them at ${CLAUDE_PLUGIN_ROOT}/instructions/, which resolves to the
installed copy.
instructions/python_coding_instructions.md: theruff/tybaseline, which applies to test code as well.instructions/agent_configuration_instructions.md: choosing between an instruction and a hook, for the rules above that must hold every time rather than most of the time.skills/python/python-secure-coding/SKILL.md: for security-relevant changes, whose rejection and failure paths need coverage.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

