mcpField
P
python-project-guidelines

python-project-guidelines

github.com/streamofronDevelopment071 installsUpdated 3w ago
Repository

About python-project-guidelines

Python Project Guidelines is a skill for creating multi-module Python applications and libraries with pyproject.toml. It guides project structure, uv-based environments, dependency choices, and checks; single-file scripts are explicitly directed elsewhere.

Key features

  1. 01Uses uv for environments and dependencies
  2. 02Sets Python version using current EOL status
  3. 03Prefers minimal justified dependencies
  4. 04Uses src layout and pyproject.toml
  5. 05Recommends async web frameworks
  6. 06Includes setup verification checks

Use cases

  1. 01Scaffolding a Python library with tests
  2. 02Starting a multi-module Python application
  3. 03Choosing dependencies for a new project
  4. 04Checking project structure and runtime setup

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/streamofron/agent-skills --skill python-project-guidelines

After installing, type/python-project-guidelinesin Claude Code to confirm it loaded.

Bundled filesreferences/library-docs.md

Details

From the project README

Python Project Guidelines

Overview

Core principle: Create Python projects with uv-managed environments, minimal dependencies, modern Python versions, and async-first architecture for web applications.

Key distinction: This skill applies to full Python projects with pyproject.toml. For standalone single-file scripts, use the standalone-python-scripts skill instead.

When to Use

  • Starting a new Python project with multiple modules
  • Scaffolding a Python application or library
  • Setting up project structure with pyproject.toml
  • When the project requires multiple files, tests, or complex dependencies

When NOT to use:

  • Single-file standalone scripts → use standalone-python-scripts skill
  • Quick utility scripts → use standalone-python-scripts skill
  • Existing projects without pyproject.toml that don't need restructuring

Standalone Script Check

Before proceeding: If the project is a single-file tool or script (not a multi-module application), STOP and use the standalone-python-scripts skill instead.

Decision rule:

  • Single .py file for standalone execution → standalone-python-scripts
  • Multiple modules, tests, or complex structure → continue with this skill

Environment Management with uv

Use uv for Python version management and virtual environment handling.

Project Initialization
# Initialize new project
uv init myproject
cd myproject

# Specify Python version (see version policy below)
uv init myproject --python 3.12
Adding Dependencies
# Add production dependencies
uv add click arrow sqlalchemy

# Add development dependencies
uv add --dev pytest ruff mypy

# Add with version constraints
uv add 'httpx>=0.24,<0.27'
Running Commands
# Run Python scripts
uv run python myscript.py

# Run installed tools
uv run pytest
uv run ruff check .

Python Version Policy

Rule: Never target Python versions that are end-of-life or have less than one year until end-of-life.

Check current status: https://devguide.python.org/versions/

Current safe minimum (as of 2026-08-27): Python 3.11

  • 3.10: EOL 2026-10 (less than 1 year) → DO NOT TARGET
  • 3.11: EOL 2027-10 (more than 1 year) → OK
  • 3.12+: OK

In pyproject.toml:

[project]
requires-python = ">=3.11"

Verification: Before setting requires-python, check the devguide URL above. If a version's EOL is within 12 months of today, do not use it.

Dependency Discipline

Principle: Take only the minimum necessary external requirements to efficiently accomplish the task.

Decision process:

  1. Can stdlib handle this? → Use stdlib
  2. Is there a well-established, maintained library? → Use it
  3. Is the dependency adding significant value over stdlib? → Justify it

Examples:

  • JSON parsing → stdlib json (no external dep needed)
  • HTTP client → httpx or requests (stdlib urllib is cumbersome)
  • Date/time → arrow (per preference table)
  • CLI parsing → click (per preference table)

Library Preferences

When external dependencies are needed, prefer these libraries:

NeedLibraryNotes
Argument parsingClickDecorator-based, clean API
Date/time handlingArrowBetter than stdlib datetime
Database ORMSQLAlchemyDo not write raw SQL unless absolutely necessary
Database migrationsAlembicWorks with SQLAlchemy
Web (async)Quart, FastAPI, or AioHttpChoose based on project needs; prefer async frameworks

Web framework selection:

  • FastAPI: Best for APIs with automatic OpenAPI docs, type validation
  • Quart: Async Flask alternative, good for traditional web apps
  • AioHttp: Lower-level, good for high-performance services

Database rule: Use SQLAlchemy ORM. Write raw SQL only when:

  • Complex queries that ORM cannot express efficiently
  • Performance-critical paths where raw SQL is measurably faster
  • Legacy database integration requiring specific SQL features

Project Structure

myproject/
├── pyproject.toml
├── src/
│   └── myproject/
│       ├── __init__.py
│       ├── main.py
│       └── ...
├── tests/
│   └── ...
└── README.md

Key conventions:

  • Use src/ layout for packages
  • Keep tests separate from source
  • Use pyproject.toml for all project metadata (no setup.py or setup.cfg)

Common Mistakes

MistakeCorrect Pattern
Using pip instead of uvAlways use uv for environment management
Targeting Python 3.10 or olderCheck devguide; use 3.11+
Writing raw SQL queriesUse SQLAlchemy ORM
Using sync web frameworks (Flask, Django)Use async frameworks (FastAPI, Quart, AioHttp)
Using argparse for CLIUse Click
Using stdlib datetime extensivelyUse Arrow
Bloated dependenciesAudit and remove unused packages
Using setup.pyUse pyproject.toml only

Red Flags - STOP and Check

  • Using Python version with EOL < 1 year away
  • Writing raw SQL instead of using SQLAlchemy
  • Using sync web framework for new project
  • Adding dependencies without justification
  • Using pip/venv instead of uv
  • Missing requires-python in pyproject.toml
  • Using deprecated packaging tools (setup.py, setup.cfg)

Verification

Before completing project setup:

  1. Check Python version: uv run python --version → should be 3.11+
  2. Check dependencies: uv tree → review for unnecessary packages
  3. Verify structure: ls src/ → should use src layout
  4. Test run: uv run python -m myproject → should execute without errors

References

Comments

Markdown supported