- Python 3.10+, type hints on all public APIs, avoid
Any— use precise types, generics, ortyping.Protocol. - Formatting/linting: a fast linter/formatter (e.g., Ruff), zero warnings; strict static type checking (e.g., mypy or pyright). Security: a SAST tool (e.g., Bandit).
- Testing:
pytestwith function-based tests,pytest-cov(80%+),hypothesisfor property-based. - Error handling: specific exceptions only, never bare
except:,contextlib.suppressfor intentional ignoring. - Dataclasses or Pydantic for structured data — avoid raw dicts for known schemas.
pathlib.Pathoveros.pathfor filesystem operations. Google-style docstrings on public APIs.- Async:
async/awaitfor I/O, never mix blocking and async,asyncio.gather()for concurrency. - Package management: a fast, lockfile-based package manager (e.g., uv) with the lockfile committed, build with a PEP 517 backend (e.g., maturin or hatchling).
- Security:
pip-auditfor dependency CVE scanning. Zero tolerance for critical/high vulnerabilities. - Logging: structured logging (key=value / JSON) — never f-strings in log calls.
- Pattern matching (
match/case) for multi-branch type dispatch (3.10+). - Anti-patterns: mutable default args,
import *, global state,time.sleepin async.
Python Conventions
Python code conventions covering type hints, Ruff formatting/linting, mypy/pyright, pytest, async I/O, uv packaging, and dependency security scanning. Load when writing or reviewing Python code.
Python Conventions by goldziher · 41225d3
npx skillmds@latest add goldziher/python-conventions File contents
---name: python-conventionsdescription: Python code conventions covering type hints, Ruff formatting/linting, mypy/pyright, pytest, async I/O, uv packaging, and dependency security scanning. Load when writing or reviewing Python code.---- Python 3.10+, type hints on all public APIs, avoid `Any` — use precise types, generics, or `typing.Protocol`.- Formatting/linting: a fast linter/formatter (e.g., Ruff), zero warnings; strict static type checking (e.g., mypy or pyright). Security: a SAST tool (e.g., Bandit).- Testing: `pytest` with function-based tests, `pytest-cov` (80%+), `hypothesis` for property-based.- Error handling: specific exceptions only, never bare `except:`, `contextlib.suppress` for intentional ignoring.- Dataclasses or Pydantic for structured data — avoid raw dicts for known schemas.- `pathlib.Path` over `os.path` for filesystem operations. Google-style docstrings on public APIs.- Async: `async`/`await` for I/O, never mix blocking and async, `asyncio.gather()` for concurrency.- Package management: a fast, lockfile-based package manager (e.g., uv) with the lockfile committed, build with a PEP 517 backend (e.g., maturin or hatchling).- Security: `pip-audit` for dependency CVE scanning. Zero tolerance for critical/high vulnerabilities.- Logging: structured logging (key=value / JSON) — never f-strings in log calls.- Pattern matching (`match`/`case`) for multi-branch type dispatch (3.10+).- Anti-patterns: mutable default args, `import *`, global state, `time.sleep` in async.
goldziher/ai-rulez/tree/main/internal/builtins/languages/python/skills/python-conventions commit 41225d316d
Frequently asked questions
Run npx skillmds@latest add goldziher/python-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Python code conventions covering type hints, Ruff formatting/linting, mypy/pyright, pytest, async I/O, uv packaging, and dependency security scanning. Load when writing or reviewing Python code. It is listed under Security on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
goldziher (@goldziher) published this skill. Their other Agent Skills are listed on their SkillMD profile.