python-clean-code
Skill0 starsChanged 59 days agoMITView on GitHub
Enforces strict architecture, modern type hints, clean code standards, and quality tooling for Python codebases. Mandates exclusive use of the uv package manager, 100% type annotations, automated ruff linting, isort import sorting, formatting on every change, zero dead code, strict file/function size limits, and role-based folder hierarchy.
- Installs packages
8 other projects use a version of this.
Adopted by
Most recently taken up by
- phanijapps/memextheir own version, first seen Oct 17, 2026
- ramybarsoum/claude-skillstheir own version, first seen Oct 13, 2026
- dathuynh1108/agent-skillstheir own version, first seen Oct 11, 2026
- FlorianBruniaux/google-search-console-mcptheir own version, first seen Oct 10, 2026
- CasLubbers/code-design-skillstheir own version, first seen Aug 25, 2026
- jenreh/appkittheir own version, first seen Jul 8, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- ertugrul-dmr/clean-code-skills★ 193same name
- FlorianBruniaux/google-search-console-mcp★ 22same name
- dathuynh1108/agent-skills★ 4same name
- jenreh/appkit★ 4same name
- CasLubbers/code-design-skills★ 2same name
- JoseVelazcoH/python-skills★ 0same name
- phanijapps/memex★ 0same name
- ramybarsoum/claude-skills★ 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 repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/AGENTS.mdAGENTS.md
- kurokoSkill
- tayoriSkill
- xerjSkill
- aesthetic-readme-craftSkill
- cli-builderSkill
- codebase-digestSkill
- git-release-craftSkill
- git-repo-craftSkill
- karakuriSkill
- rust-clean-codeSkill
- rust-style-pythonSkill
- systematic-code-verificationSkill
- compose-clean-codeSkill
- bash-clean-codeSkill
- tui-designSkill
- frontend-designSkill
- web-design-guidelinesSkill
- unslopSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 4 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Never: use raw pip install, poetry, or pipenv.
- Distinctive: line 38
Always execute automated quality checks on any file edit:
- Distinctive: line 62
All code must include explicit type annotations on variables, function signatures, and return values:
- Very specific: line 65
Use int | str | None instead of Optional[Union[int, str]].
- Very specific: line 66
Use built-in generics: list[str], dict[str, Any], tuple[int, ...], set[Path].
- Very specific: line 68
Every function and method must declare its return type: def process(...) -> None:.
- Distinctive: line 71
Avoid untyped nested dictionaries.
- Very specific: line 72
Prefer @dataclass(frozen=True, slots=True) or pydantic.BaseModel for data transfer objects.
- Distinctive: line 78
Keep modules and functions focused on a single responsibility:
- Very specific: line 120
models: must never perform network or disk I/O. - Very specific: line 123
cli: only parses input and presents output. - Very specific: line 129
Pathlib over
os.path: Always use pathlib.Path for file manipulation, path joining, and existence checks. - Very specific: line 130
Context Managers: Always use with statements for files, sockets, locks, and network sessions to guarantee resource release.
- Very specific: line 132
Pattern Matching: Use match / case statements where appropriate instead of long chains of if/elif isinstance(...).
“Common” is measured: kept by at least 6 in 10 of the 8 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-clean-code Skill: Quality, Typing & Architecture Standards
Enforces high-rigor production standards for Python projects. Code must be strictly typed, formatted, organized into role-based submodules, and managed exclusively via uv.
1. Package Management via uv (Mandatory)
Never use raw pip install, poetry, or pipenv. Always manage dependencies and environments through uv:
# Initialize a project or add dependencies
uv init
uv add <package>
uv add --dev ruff mypy pytest
# Execute commands within virtualenv
uv run <command>
uv run python -m <module>
# Sync dependencies
uv sync2. On Every Change: Lint, Sort Imports & Format
Always execute automated quality checks on any file edit:
# 1. Lint and auto-fix violations (including unused imports, code smells)
uv run ruff check --fix
# 2. Sort imports according to isort standard
uv run ruff check --select I --fix
# 3. Format code style (black-compatible, 88 char line length)
uv run ruff format
# 4. Strict static type check
uv run mypy .Zero-Tolerance Rules:
- No
# noqaor# type: ignoresuppressions without an explicit comment explaining the unfixable upstream reason. - Zero dead code: Unused imports, unreachable blocks, and abandoned helper functions must be deleted immediately.
3. 100% Modern Type Hinting
All code must include explicit type annotations on variables, function signatures, and return values:
- Modern Union & Collection Syntax (Python 3.10+):
- Use
int | str | Noneinstead ofOptional[Union[int, str]]. - Use built-in generics:
list[str],dict[str, Any],tuple[int, ...],set[Path].
- Use
- Explicit Return Types:
- Every function and method must declare its return type:
def process(...) -> None:. - Generator functions must declare
Iterator[T]orGenerator[Y, S, R].
- Every function and method must declare its return type:
- Structured Data:
- Avoid untyped nested dictionaries.
- Prefer
@dataclass(frozen=True, slots=True)orpydantic.BaseModelfor data transfer objects.
4. Quantitative Size Limits & Modularity
Keep modules and functions focused on a single responsibility:
| Metric | Target | Hard Limit | Action if Exceeded |
| File Length | 100–200 lines | 300 lines | Decompose into submodules by domain/role |
| Function Length | 15–30 lines | 45 lines | Extract sub-routines or pipeline steps |
| Functions per File | 4–6 functions | 8 functions | Separate responsibilities into dedicated files |
| Files per Subpackage | 3–5 files | 7 files | Group related logic into a subfolder with __init__.py |
| Function Parameters | 1–3 parameters | 4 parameters | Encapsulate parameters in a @dataclass or config model |
5. Role-Based Directory Architecture
Structure packages by responsibility instead of a flat dump of scripts:
src/<package_name>/
├── __init__.py
├── __main__.py # Entrypoint invocation (python -m <pkg>)
├── exceptions.py # Domain-specific typed exception classes
├── cli/ # CLI parsing (Click, Typer, or Argparse)
│ ├── __init__.py
│ └── main.py
├── models/ # Pure data structures (Dataclasses / Pydantic)
│ ├── __init__.py
│ └── entity.py
├── services/ # Core business logic and orchestration
│ ├── __init__.py
│ └── processor.py
├── client/ (or api/) # External HTTP/network clients (httpx, requests)
│ ├── __init__.py
│ └── remote.py
├── storage/ (or db/) # File persistence, SQLite, caching
│ ├── __init__.py
│ └── repository.py
└── utils/ # Reusable formatters, time helpers, validators
├── __init__.py
└── format.pyModule Boundaries:
modelsmust never perform network or disk I/O.storageencapsulates file read/write operations and schema migrations.servicescoordinates business workflows by calling clients and storage.clionly parses input and presents output; no domain logic inside CLI handlers.
6. DRY & Modern Idioms
- Pathlib over
os.path: Always usepathlib.Pathfor file manipulation, path joining, and existence checks. - Context Managers: Always use
withstatements for files, sockets, locks, and network sessions to guarantee resource release. - Structured Exceptions: Define clear, custom exceptions in
exceptions.pyinheriting fromExceptionrather than raising genericRuntimeErrororValueError. - Pattern Matching: Use
match / casestatements where appropriate instead of long chains ofif/elif isinstance(...).
7. Pre-Commit Verification Checklist
# Auto-fix linting & import sorting
uv run ruff check --fix
uv run ruff check --select I --fix
# Format code
uv run ruff format
# Static type verification
uv run mypy .
# Run test suite
uv run pytestDoes 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.

