python-best-practices
Skill2 starsChanged 4 months agoMITView on GitHub
Write idiomatic, typed Python with clear packaging, ruff/pytest defaults, and practical error handling. Use when writing or refactoring Python code, modules, scripts, packages, or APIs, or when the user mentions Python style, typing, or project layout.
15 other projects use a version of this.
Adopted by
Most recently taken up by
- baekenough/oh-my-customcodetheir own version, first seen Oct 3, 2026
- The-AIOS/aiostheir own version, first seen Sep 24, 2026
- excatt/superclaude-plusplustheir own version, first seen Sep 7, 2026
- Madheshvivekanandan/ai-engineering-skillstheir own version, first seen Jul 31, 2026
- tomroberts92/skillstheir own version, first seen Jun 25, 2026
- reformovo/skillstheir own version, first seen Jun 24, 2026
Used with
Projects with it also use frontend-design and skill-creator.
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.
VercelSkillfrontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
Also in 4 projects that use this
MicrosoftSkillskill-creator
Guide for creating effective GitHub Copilot skills (.github/skills/) in this repository. Use when creating a new skill, updating an existing skill, or when asked about skill structure, format, or best practices for the vscode-documentdb project.
Also in 4 projects that use this
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- rohitg00/awesome-claude-code-toolkit★ 2.7ksame name
- The-AIOS/aios★ 69same name
- baekenough/oh-my-customcode★ 43same name
- jefflester/claude-skills-supercharged★ 42same name
- excatt/superclaude-plusplus★ 14same name
- cisco-open/ai-harness-toolkit★ 13same name
- arnabdeypolimi/claude_code_setup★ 4same name
- Sanskar015/claude-skills-supercharged★ 3same name
- b12consulting/skills★ 2same name
- medy-gribkov/arcana★ 1same name
5 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 repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-reviewSkill
- debuggingSkill
- javascript-best-practicesSkill
- nextjs-app-routerSkill
- nextjs-data-fetchingSkill
- python-testingSkill
- react-best-practicesSkill
- tagged-code-commentsSkill
- typescript-best-practicesSkill
- create-skillSkill
- revise-skillSkill
- academic-paperSkill
- latex-scientific-writingSkill
- paper-abstractSkill
- paper-conclusionSkill
- paper-discussionSkill
- paper-introductionSkill
- paper-literature-reviewSkill
- paper-methodsSkill
- paper-peer-reviewSkill
- paper-related-workSkill
- paper-resultsSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Match the repo first: Follow existing layout, tooling, and import style before introducing new conventions.
- Very specific: line 33
Use pathlib and context managers: Prefer pathlib.Path over string paths.
- Distinctive: line 34
Dependencies: Prefer the stdlib. Add third-party libs only when they clearly reduce complexity.
- Distinctive: line 35
Do not over-abstract: Wait for a second real use before extracting shared helpers or base classes.
- Very specific: line 36
Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …).
“Common” is measured: kept by at least 6 in 10 of the 13 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 Best Practices
Defaults
| Concern | Default |
| Style / lint | Ruff (format + lint) |
| Types | Type hints on public APIs; mypy or pyright in CI when the project already uses them |
| Tests | pytest (see python-testing skill) |
| Package layout | src/<package>/ for libraries; flat modules OK for small scripts |
| Python version | Match requires-python / .python-version; prefer 3.11+ |
Instructions
- Match the repo first. Follow existing layout, tooling, and import style before introducing new conventions.
- Prefer clarity over cleverness. Explicit names, small functions, early returns. Avoid deep nesting and clever one-liners.
- Type public surfaces. Annotate function parameters and return types for APIs, shared helpers, and data models. Use
TypedDict/ dataclasses / Pydantic when the project already does. - Handle errors at the boundary. Catch specific exceptions; convert to domain errors or HTTP responses at edges. Do not bare
except:or swallow errors silently. - Use pathlib and context managers. Prefer
pathlib.Pathover string paths; always close resources withwith. - Dependencies. Prefer the stdlib. Add third-party libs only when they clearly reduce complexity; pin in the project's lockfile/tooling.
- Do not over-abstract. Wait for a second real use before extracting shared helpers or base classes.
- Tag unfinished or risky work. Use the global
tagged-code-commentsconvention (🔴 FIXME(P0):,🟠 TODO(P1):, …). Never leave silent stubs. End with an Open follow-ups table so the developer must check P0/P1 before ship.
Project layout (libraries)
src/mypkg/
__init__.py
api.py
models.py
tests/
test_api.py
pyproject.tomlAnti-patterns
- Untyped public APIs in typed codebases
- Mutable default arguments (
def f(x=[])) - Broad
except Exceptionwithout re-raise or logging - Circular imports fixed by hacks instead of restructuring
- Mixing business logic into CLI/
__main__without a callable core
Checklist
See references/checklist.md.
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.

