python
Adaptive Python development guide with tiered complexity levels (Minimal/Standard/Full). Automatically selects appropriate guidance based on project context - from simple scripts (just clean Python code) to full production systems (complete tooling ecosystem). Covers modern conventions, testing, tooling, security, and best practices. Use when writing Python code, converting scripts, setting up projects, or building production systems. Keywords: PEP-8, Ruff, pytest, mypy, simple scripts, project structure, PyPI, packaging, type hints, clean code
What this skill does
# Python Development Skill Comprehensive guide to modern Python development covering conventions, testing, tooling, security, performance, and ecosystem best practices (2024-2025 standards). ## Tier 2 Quick Start **For multi-file projects, team collaboration, and maintained code:** ```bash # Install Python 3.12 and uv (see Installation guides) # Windows: winget install Python.Python.3.12 && winget install astral-sh.uv # macOS: brew install [email protected] uv # Linux: apt install python3.13 && curl -LsSf https://astral.sh/uv/install.sh | sh # Create new project with modern structure uv init my-project cd my-project # Add dependencies uv add requests httpx pydantic # Add development dependencies uv add --dev pytest pytest-cov ruff mypy # Set up code quality (create pyproject.toml config - see assets/pyproject-toml-template.toml) # Configure Ruff, mypy, pytest # Write tests (pytest) # tests/test_example.py - mirror src/ structure # Run quality checks uv run ruff check . # Linting uv run ruff format . # Formatting uv run mypy . # Type checking uv run pytest # Run tests uv run pytest --cov # With coverage ``` ## When to Use This Skill Invoke this skill when you need guidance on: - **Installation & Setup**: Installing Python 3.12/3.14, uv, setting up development environment - **Code Style**: Following PEP-8, configuring Ruff/Black, naming conventions - **Project Structure**: Organizing code with src/ layout, imports, package structure - **Dependency Management**: Using uv, Poetry, pip, virtual environments, pyproject.toml - **Testing**: Writing pytest tests, fixtures, parametrization, coverage, mocking - **Type Hints**: Modern typing patterns, mypy configuration, protocols, generics - **Code Quality**: Setting up Ruff, mypy, Bandit, pre-commit hooks, CI/CD - **Async Programming**: asyncio patterns, async/await, TaskGroup, structured concurrency - **Security**: OWASP best practices, input validation, dependency scanning - **Performance**: Profiling, optimization patterns, Cython - **Packaging**: pyproject.toml, PyPI publishing, versioning, distribution - **Common Libraries**: Standard library essentials, ecosystem overview - **Documentation**: Docstrings (PEP-257), Sphinx, documentation generation ## Overview This skill provides modern Python development guidance aligned with current best practices (2024-2025): **Core Standards:** - **Style**: PEP-8 (enforced via Ruff) - **Type Hints**: PEP-484, PEP-526, modern syntax (PEP-604: `str | None`) - **Packaging**: PEP-517, PEP-518 (pyproject.toml) - **Docstrings**: PEP-257 - **Testing**: pytest (industry standard) - **Dependency Management**: uv (fastest) or Poetry (feature-rich) **Modern Tooling (2024-2025):** - **Linter/Formatter**: Ruff (replaces flake8, isort, optionally Black) - **Type Checker**: mypy with strict mode - **Test Framework**: pytest - **Dependency Manager**: uv or Poetry - **Security Scanner**: Bandit + pip-audit - **Project Config**: pyproject.toml (universal) **Project Structure:** - src/ layout (modern standard, not flat layout) - Absolute imports preferred over relative - Tests mirror src/ structure - pyproject.toml for all configuration **Official Sources:** All guidance backed by official Python documentation, PEPs, and tool documentation: - docs.python.org - peps.python.org - docs.astral.sh/ruff - docs.astral.sh/uv - mypy-lang.org - docs.pytest.org ## Quick Tier Selection **Choose your complexity level:** ### ๐ฏ Tier 1: Minimal (Simple Scripts) โ Single-file utilities, converting scripts, one-off automation โ Just Python code - no tooling overhead โ [Jump to Minimal Guidance](#tier-1-minimal-simple-scripts) ### ๐ฆ Tier 2: Standard (Organized Projects) โ Multi-file modules, team projects, maintained code โ Modern project structure + testing โ [Jump to Standard Guidance](#tier-2-standard-organized-projects) ### ๐ Tier 3: Full (Production Systems) โ PyPI packages, enterprise systems, production deployments โ Complete tooling ecosystem โ [Jump to Full Guidance](#tier-3-full-production-systems) **Not sure?** Default to Tier 2 (Standard) - it covers most use cases. --- ## Tier 1: Minimal (Simple Scripts) **For:** Single-file utilities, script conversions, and simple automation. ### Setup Just Python 3.12+ - no additional tooling required: - โ No uv, no virtual environment needed - โ No pyproject.toml, no src/ layout - โ Optional: Install Ruff for quick linting (`pip install ruff`) ### Code Standards Follow these simple principles: - **PEP-8 naming**: `snake_case` for functions/variables, `PascalCase` for classes - **Type hints**: Add for clarity (helps readers understand your code) - **Docstrings**: Simple descriptions of what functions do - **pathlib**: Use `pathlib.Path` for file operations (not `os.path`) - **Built-ins**: Use Python's built-in `json`, `datetime`, `sys` modules ### Example: Simple Logging Script ```python #!/usr/bin/env python3 """Simple logging utility - converts event to JSON.""" import json import sys from datetime import datetime, timezone from pathlib import Path def log_event(event_name: str, data: dict) -> None: """ Log an event to daily JSONL file. Args: event_name: Name of the event data: Event data to log """ log_dir = Path(__file__).parent / "logs" log_dir.mkdir(exist_ok=True) now = datetime.now(timezone.utc) log_file = log_dir / f"{now:%Y-%m-%d}.jsonl" entry = { "timestamp": now.isoformat(), "event": event_name, "data": data } with open(log_file, "a", encoding="utf-8") as f: f.write(json.dumps(entry) + "\n") if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: script.py <event_name>", file=sys.stderr) sys.exit(1) event_name = sys.argv[1] data = json.loads(sys.stdin.read()) log_event(event_name, data) ``` ### Optional: Quick Linting If you want to check your code style: ```bash # Install Ruff (optional) pip install ruff # Check code ruff check script.py # Format code ruff format script.py ``` ### When to Upgrade to Tier 2 Consider upgrading to Tier 2 (Standard) when: - โ Script grows to 3+ files - โ Multiple people working on code - โ Need automated testing - โ Managing external dependencies - โ Code will be maintained long-term --- ## Tier 2: Standard (Organized Projects) **For:** Multi-file modules, team projects, and maintained code. Modern Python project setup with proper structure, testing, and quality tools. ### Installation Install Python 3.12+ and uv (modern dependency manager). See platform-specific guides: - [Installation Overview](references/installation/overview.md) - Concepts and version policy - [Windows Installation](references/installation/windows.md) - WinGet, Python Launcher - [macOS Installation](references/installation/macos.md) - Homebrew installation - [Linux Installation](references/installation/linux.md) - apt/dnf or build from source ### Project Setup and Organization **Conventions and Style** - Follow PEP-8 with Ruff for linting and formatting: - See [Conventions and Style Guide](references/conventions-and-style.md) **Project Structure** - Use modern src/ layout for proper packaging: - See [Project Structure Guide](references/project-structure.md) **Dependency Management** - Choose between uv (fastest), Poetry (feature-rich), or pip+venv: - See [Dependency Management Guide](references/dependency-management.md) ### Testing and Quality **Testing** - Use pytest with fixtures, parametrization, and coverage: - See [Testing Methodology Guide](references/testing-methodology.md) **Type Hints** - Modern typing with mypy, protocols, and generics: - See [Type Hints Guide](references/type-hints.md) **Code Quality** - Set up Ruff, mypy, Bandit, and pre-commit hooks: - See [Code Quality Tools Guide](references/code-quality-tools.md) ### Advanced Development **Async Programming** - asy
Related in Security
mac-ops
IncludedComprehensive macOS workstation operations โ diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.