python-conventions
Skill1 starsChanged 39 days agoMITView on GitHub
Shared conventions for modern Python 3.14 projects. Project layout, typing, linting, testing, and commands. Referenced by python-implementor, python-reviewer, and workflow skills.
- Installs packages
7 other projects use a version of this.
Adopted by
Most recently taken up by
- NicoGenti/opencode-orchestrator-kittheir own version, first seen Nov 8, 2026
- leroyguillaume/claudetheir own version, first seen Oct 30, 2026
- ek33450505/claude-agent-teamtheir own version, first seen Oct 25, 2026
- andr-ca/agentharnesstheir own version, first seen Oct 15, 2026
- techmefr/mentistheir own version, first seen Sep 11, 2026
- HermeticOrmus/python-conventions-skillstheir own version, first seen May 23, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- tae0y/python-project-template★ 14same name
- NicoGenti/opencode-orchestrator-kit★ 9same name
- ek33450505/claude-agent-team★ 8same name
- leroyguillaume/claude★ 7same name
- HermeticOrmus/python-conventions-skills★ 2same name
- andr-ca/agentharness★ 1same name
- techmefr/mentis★ 0same name
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 repository38 other files it gives its agents.
- agent-conductSkill
- bugfixSkill
- code-smellsSkill
- deliverSkill
- final-responseSkill
- frontend-designSkill
- go-conventionsSkill
- go-implementorSkill
- go-reviewerSkill
- go-test-strengthSkill
- implementation-principlesSkill
- nextflow-conventionsSkill
- nextflow-implementorSkill
- nextflow-reviewerSkill
- nextjs-fastapi-conventionsSkill
- nextjs-fastapi-implementorSkill
- nextjs-fastapi-reviewerSkill
- orchestratorSkill
- phase-creatorSkill
- phase-reviewerSkill
- prose-principlesSkill
- pr-resolverSkill
- pr-reviewerSkill
- python-implementorSkill
- python-reviewerSkill
- spec-authorSkill
- spec-proofreaderSkill
- spec-reviewerSkill
- spec-writerSkill
- subagentsSkill
- swift-conventionsSkill
- swift-implementorSkill
- swift-reviewerSkill
- testing-principlesSkill
- tightenSkill
- unslopSkill
- verificationSkill
- writing-for-agentsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 7 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
All new source files must start with:
- Very specific: line 50
All tool config (ruff, pyright, pytest) lives in pyproject.toml.
- Very specific: line 56
PEP 649 deferred annotations are the default: Do NOT add from __future__ import annotations.
- Distinctive: line 58
All annotations are evaluated lazily at runtime automatically.
- Very specific: line 59
PEP 728
TypedDictwithextra_items: Use closed=True on TypedDicts that should reject extra keys. - Very specific: line 65
typestatement (3.12+): Prefer type Alias = ... over TypeAlias: TypeAlias = .... - Very specific: line 68
Generic syntax (3.12+): Use class Foo[T]: and def barT -> T: instead of TypeVar + Generic[T].
- Very specific: line 71
matchstatements (3.10+): Prefer match/case over long if/elif chains for structural pattern matching where appropriate. - Very specific: line 82
Strict mode. No
Any: Every function has full parameter and return type annotations. - Very specific: line 84
Use collections.abc for abstract types (Sequence, Mapping, Callable, Iterator, AsyncIterator), not typing equivalents.
- Distinctive: line 90
No raw dicts for structured data.
- Distinctive: line 102
Import grouping: stdlib | third-party | local (enforced by ruff isort).
- Very specific: line 105
Prefer comprehensions over map/filter with lambdas.
- Very specific: line 128
Never bare except: or except Exception: without re-raise or logging.
- Distinctive: line 137
No mutable global state between tests.
- Very specific: line 138
Test files mirror src/ structure: tests/test_<module>.py.
- Distinctive: line 140
Follow testing-principles for test intent.
- Distinctive: line 142
Every spec.md acceptance test MUST have a corresponding pytest test.
“Common” is measured: kept by at least 6 in 10 of the 7 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 Conventions
Single source of truth for Python code standards. Other skills reference this.
Copyright Boilerplate
All new source files must start with:
# Copyright (c) 2026 Genome Research Ltd.
#
# Author: Sendu Bala <sb10@sanger.ac.uk>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Project Layout
pyproject.toml # single config file (no setup.py, setup.cfg, requirements.txt)
src/<pkg>/ # all source code under src/
__init__.py
py.typed # PEP 561 marker
tests/ # mirrors src/ structure- uv for dependency management and virtualenvs. Never pip install directly.
- All tool config (ruff, pyright, pytest) lives in
pyproject.toml.
Python 3.14 Specifics
LLMs trained on older code will get these wrong. Pay attention.
- PEP 649 deferred annotations are the default. Do NOT add
from __future__ import annotations. It is unnecessary and discouraged. All annotations are evaluated lazily at runtime automatically. - PEP 728
TypedDictwithextra_items. Useclosed=Trueon TypedDicts that should reject extra keys; useextra_items=<type>for known-extra patterns. These replace@finalworkarounds. - PEP 742
TypeIsnarrowing: useTypeIs[T](notTypeGuard[T]) for type-narrowing functions that narrow in both branches.TypeGuardonly narrows the truthy branch.TypeIsis the default choice now. typestatement (3.12+): Prefertype Alias = ...overTypeAlias: TypeAlias = .... Thetypestatement supports forward references natively.- Generic syntax (3.12+): Use
class Foo[T]:anddef bar[T](x: T) -> T:instead ofTypeVar+Generic[T]. Only useTypeVarif you needbound=orconstraints=that can't be expressed inline. matchstatements (3.10+): Prefermatch/caseover long if/elif chains for structural pattern matching where appropriate.- Exception groups and
except*(3.11+): Use for concurrent error handling where multiple exceptions may be raised simultaneously. - f-string improvements (3.12+): Nested quotes and backslashes are allowed inside f-string expressions. No need for workarounds.
Code Quality
Typing
- Strict mode. No
Any. Every function has full parameter and return type annotations. pyright strict must pass clean. - Use
collections.abcfor abstract types (Sequence,Mapping,Callable,Iterator,AsyncIterator), nottypingequivalents. X | None(notOptional[X]).X | Y(notUnion[X, Y]).Annotated[T, ...]for metadata (PydanticField, TyperOption/Argument).- Pydantic models for structured data, dataclasses for plain value objects. No raw dicts for structured data.
Selfreturn type for fluent/builder methods.@overloadfor functions with distinct return types based on input.Neverfor functions that always raise.
Style
- Functions ~30 lines max, excluding type annotations and docstrings.
- Early returns/guard clauses over nested if/else.
- Docstrings on all public modules, classes, functions (imperative mood, one line if sufficient).
- One responsibility per module; filenames describe the responsibility.
- Import grouping: stdlib | third-party | local (enforced by ruff isort).
__all__in every public module.- Context managers (
with) for all resource handling. - Prefer comprehensions over
map/filterwith lambdas. pathlib.Pathoveros.path.
Pydantic v2
model_validator,field_validator(not v1@validator,@root_validator).model_dump()/model_validate()(not.dict()/.parse_obj()).ConfigDictclass attribute (not innerclass Config).Annotated[T, Field(...)]for field metadata.model_json_schema()for JSON Schema export.- Strict mode where appropriate:
model_config = ConfigDict(strict=True).
CLI (Typer)
- Typer app per CLI module. Commands as decorated functions.
Annotated[T, typer.Option(...)]/Annotated[T, typer.Argument(...)]for all params (not default-value style).- Rich help panels for grouped options.
raise typer.Exit(code=1)for errors (notsys.exit).
Error Handling
- Custom exception hierarchy rooted in a project base exception.
- Never bare
except:orexcept Exception:without re-raise or logging. loggingmodule with structured fields, not print statements.
Testing (pytest)
pytestwithpytest-asyncio(auto mode) for async tests.- Fixtures over setup/teardown.
tmp_pathfor filesystem ops. pytest.raisesfor expected exceptions withmatch=pattern.pytest.mark.parametrizefor data-driven tests.- No mutable global state between tests.
- Test files mirror
src/structure:tests/test_<module>.py. - Assertions use plain
assert(pytest introspection rewrites them). - Follow testing-principles for test intent; this section covers pytest mechanics.
- Every spec.md acceptance test MUST have a corresponding pytest test. No stubs, no hardcoded results, no swallowed failures.
Commands
# Deps
uv sync # install/sync all deps
uv add <pkg> # add dependency
uv add --group dev <pkg> # add dev dependency
# Tests
uv run pytest tests/ -v # all tests
uv run pytest tests/ -v -k <name> # specific test
# Lint + format
uv run ruff check --fix src/ tests/ # lint + autofix
uv run ruff format src/ tests/ # format
uv run ruff check src/ tests/ # lint check only
uv run ruff format --check src/ tests/ # format check only
# Type checking
uv run pyright # strict type checkDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

