
Python Code Style
Keep Python repos consistent with ruff, mypy or pyright, PEP 8 naming, and maintained docstrings across writes and reviews.
Overview
python-code-style is a journey-wide agent skill that standardizes Python formatting, linting, naming, and docstrings—usable whenever a solo builder needs consistent quality before committing or merging.
Install
npx skills add https://github.com/wshobson/agents --skill python-code-styleWhat is this skill?
- When to use covers new code, reviews, linters, docstrings, and team standards
- Recommends ruff as combined linter and formatter with pyproject.toml snippets
- PEP 8 naming plus type hints on public APIs
- Docstrings treated as documentation-as-code
- Patterns for configuring ruff line-length and mypy strict mode
- Quick start documents ruff line-length 120 and mypy strict in pyproject.toml
- Four core concepts: automated formatting, consistent naming, documentation as code, and type annotations
Adoption & trust: 9.1k installs on skills.sh; 36.5k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Python project drifts across PEP 8, missing types, and inconsistent docstrings because tooling and standards were never defined in one place.
Who is it for?
One-person or small-team Python products adopting ruff, mypy, and docstring norms without a style guide committee.
Skip if: Codebases in other languages only, or teams that already enforce an incompatible formatter or style system they will not change.
When should I use this skill?
Use when writing new code, reviewing style, configuring linters, writing docstrings, or establishing project standards.
What do I get? / Deliverables
You leave with ruff- and mypy-friendly conventions, clear naming and docstring expectations, and review-ready code that matches documented team standards.
- Documented lint and format configuration for the repo
- Consistent docstring and typing conventions for public APIs
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Configure ruff and mypy in pyproject.toml when bootstrapping a FastAPI service.
Review a PR for PEP 8 naming, missing type hints, and stale docstrings before merge.
Align CI lint steps with the same ruff rules the skill documents for local dev.
Refactor a hotfix module without loosening docstring or typing standards.
Document minimum Python version and style gates before inviting a contractor into the repo.
How it compares
Use for living Python style procedure, not as a one-shot auto-formatter MCP or language-agnostic review rubric.
Common Questions / FAQ
Who is python-code-style for?
Solo and indie Python builders who write, review, or onboard tooling for linting, types, and documentation.
When should I use python-code-style?
Across Build when authoring modules, during Ship review before merge, and in Operate when touching legacy files—anytime Python consistency matters.
Is python-code-style safe to install?
It is documentation and configuration guidance; still review the Security Audits panel on this page before installing any agent skill from the registry.
SKILL.md
READMESKILL.md - Python Code Style
# Python Code Style & Documentation Consistent code style and clear documentation make codebases maintainable and collaborative. This skill covers modern Python tooling, naming conventions, and documentation standards. ## When to Use This Skill - Setting up linting and formatting for a new project - Writing or reviewing docstrings - Establishing team coding standards - Configuring ruff, mypy, or pyright - Reviewing code for style consistency - Creating project documentation ## Core Concepts ### 1. Automated Formatting Let tools handle formatting debates. Configure once, enforce automatically. ### 2. Consistent Naming Follow PEP 8 conventions with meaningful, descriptive names. ### 3. Documentation as Code Docstrings should be maintained alongside the code they describe. ### 4. Type Annotations Modern Python code should include type hints for all public APIs. ## Quick Start ```bash # Install modern tooling pip install ruff mypy # Configure in pyproject.toml [tool.ruff] line-length = 120 target-version = "py312" # Adjust based on your project's minimum Python version [tool.mypy] strict = true ``` ## Fundamental Patterns ### Pattern 1: Modern Python Tooling Use `ruff` as an all-in-one linter and formatter. It replaces flake8, isort, and black with a single fast tool. ```toml # pyproject.toml [tool.ruff] line-length = 120 target-version = "py312" # Adjust based on your project's minimum Python version [tool.ruff.lint] select = [ "E", # pycodestyle errors "W", # pycodestyle warnings "F", # pyflakes "I", # isort "B", # flake8-bugbear "C4", # flake8-comprehensions "UP", # pyupgrade "SIM", # flake8-simplify ] ignore = ["E501"] # Line length handled by formatter [tool.ruff.format] quote-style = "double" indent-style = "space" ``` Run with: ```bash ruff check --fix . # Lint and auto-fix ruff format . # Format code ``` ### Pattern 2: Type Checking Configuration Configure strict type checking for production code. ```toml # pyproject.toml [tool.mypy] python_version = "3.12" strict = true warn_return_any = true warn_unused_ignores = true disallow_untyped_defs = true disallow_incomplete_defs = true [[tool.mypy.overrides]] module = "tests.*" disallow_untyped_defs = false ``` Alternative: Use `pyright` for faster checking. ```toml [tool.pyright] pythonVersion = "3.12" typeCheckingMode = "strict" ``` ### Pattern 3: Naming Conventions Follow PEP 8 with emphasis on clarity over brevity. **Files and Modules:** ```python # Good: Descriptive snake_case user_repository.py order_processing.py http_client.py # Avoid: Abbreviations usr_repo.py ord_proc.py http_cli.py ``` **Classes and Functions:** ```python # Classes: PascalCase class UserRepository: pass class HTTPClientFactory: # Acronyms stay uppercase pass # Functions and variables: snake_case def get_user_by_email(email: str) -> User | None: retry_count = 3 max_connections = 100 ``` **Constants:** ```python # Module-level constants: SCREAMING_SNAKE_CASE MAX_RETRY_ATTEMPTS = 3 DEFAULT_TIMEOUT_SECONDS = 30 API_BASE_URL = "https://api.example.com" ``` ### Pattern 4: Import Organization Group imports in a consistent order: standard library, third-party, local. ```python # Standard library import os from collections.abc import Callable from typing import Any # Third-party packages import httpx from pydantic import BaseModel from sqlalchemy import Column # Local imports from myproject.models import User from myproject.services import UserService ``` Use absolute imports exclusively: ```python # Preferred from myproject.utils import retry_decorator # Avoid relative imports from ..utils import retry_decorator ``` ## Advanced Patt