agentleFS
michaelsvanbeekmichaelsvanbeek/personal-agent-skills/skills/python/SKILL.md

python

Skill1 starsChanged 8 months agoMITView on GitHub

Python project conventions and coding standards. Use when: creating a new Python project, writing Python modules, setting up pyproject.toml, configuring Python dependencies, writing Python tests, scaffolding Python Lambda functions, auditing Python code for type safety and convention compliance, or improving an existing Python codebase. Covers type hints, pydantic, docstrings, and dependency management.

  • Reads credentials

26 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use fastapi, code-quality and 4 more.

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.
  • martinholovskySkill

    fastapi

    REST API and WebSocket development with FastAPI emphasizing security, performance, and async patterns

    Also in 3 projects that use this

  • MicrosoftSkill

    code-quality

    Statically check changed C# against the same deterministic rules github-code-quality[bot] runs on pull requests, so a contributor can fix likely findings before opening the PR and keep the bot's inline comments to a minimum. Activate when a contributor asks to "check code quality", "run code quality on my changes", "will the code quality bot complain", "pre-check before I open the PR", "code quality check", or similar. Scoped to C#. Reads the diff and compares it against the enumerated csharp-code-quality rule set below — no CodeQL download or build required. This is a fast approximation of a dataflow engine, not a reproduction; report accordingly. Does NOT apply fixes unless explicitly asked.

    Also in 3 projects that use this

  • AnthropicSkill

    documentation

    Write and maintain technical documentation. Trigger with "write docs for", "document this", "create a README", "write a runbook", "onboarding guide", or when the user needs help with any form of technical writing — API docs, architecture docs, or operational runbooks.

    Also in 3 projects that use this

  • BlockSkill

    debugging

    Debugging guidelines and best practices

    Also in 3 projects that use this

  • MicrosoftSkill

    skill-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 5 projects that use this

  • VercelSkill

    frontend-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 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 7 are distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the latest Python language features:

    line 25
  2. Very specific:

    Use uv as the package and project manager.

    line 36
  3. Very specific:

    Use pyproject.toml as the single source for all project metadata and dependencies.

    line 56
  4. Very specific:

    Use Pydantic BaseModel as the default for all structured data that crosses a function or module boundary: API request/response models, …

    line 83
  5. Very specific:

    Use pydantic-settings for environment-based configuration.

    line 106
  6. Very specific:

    Never use plain dict for structured data that crosses a function or module boundary.

    line 131
  7. Distinctive:

    Write docstrings following Google docstring standards.

    line 135
  8. Very specific:

    Use specific exception types rather than bare except.

    line 157
  9. Very specific:

    Use the logging module, never print() for operational output.

    line 161
  10. Distinctive:

    Use appropriate log levels: DEBUG for detail, INFO for progress, WARNING for recoverable issues, ERROR for failures.

    line 162
  11. Distinctive:

    Use Ruff for both linting and formatting.

    line 166
  12. Distinctive:

    Use pytest as the test framework.

    line 183
  13. Distinctive:

    Use descriptive test class and method names that read as specifications.

    line 185
  14. Very specific:

    Use tmp_path fixture for file system tests.

    line 187
  15. Distinctive:

    Test edge cases: empty inputs, missing config, error conditions, boundary values.

    line 188

“Common” is measured: kept by at least 6 in 10 of the 24 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Project Standards

When to Use

  • Creating a new Python project or module
  • Setting up pyproject.toml and dependency management
  • Writing Python functions, classes, or scripts
  • Scaffolding Python-based AWS Lambda functions
  • Auditing an existing Python project for type hint coverage, missing Ruff config, or dependency management gaps
  • Upgrading Python projects to modern conventions (union types, pathlib, pydantic v2)

Python Version

Target Python 3.12+ unless constraints require otherwise.

Language Features

Use the latest Python language features:

  • Type hints on all function signatures and return types
  • f-strings for string formatting
  • List and dict comprehensions where they improve readability
  • Union types using X | Y syntax (Python 3.10+)
  • Match statements where appropriate (Python 3.10+)
  • Walrus operator (:=) where it improves readability

Package Management

Use uv as the package and project manager. It is substantially faster than pip and handles virtual environments, lockfiles, and workspaces in a single tool.

# Create a new project
uv init my-project && cd my-project

# Add runtime dependencies
uv add fastapi mangum pydantic pydantic-settings

# Add dev-only dependencies (not bundled in Lambda)
uv add --dev pytest ruff mypy boto3

# Run tools within the project environment
uv run pytest
uv run ruff check .

# Sync environment from lockfile (CI / fresh checkout)
uv sync
  • Use pyproject.toml as the single source for all project metadata and dependencies.
  • The uv.lock lockfile must be committed to version control for reproducible installs.
  • For AWS Lambda deployment, packages already in the Lambda runtime (boto3, botocore) belong in [dependency-groups] dev — not bundled in the artifact.
[project]
name = "my-project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
    "fastapi",
    "mangum",
    "pydantic",
    "pydantic-settings",
]

[dependency-groups]
dev = [
    "boto3",
    "pytest",
    "ruff",
    "mypy",
]

Data Modeling with Pydantic

Use Pydantic BaseModel as the default for all structured data that crosses a function or module boundary: API request/response models, configuration, and any externally-sourced data.

Request and Response Models

from datetime import datetime
from pydantic import BaseModel, Field

class CreateProjectRequest(BaseModel):
    name: str = Field(..., min_length=1, max_length=100)
    description: str = Field(default="", max_length=500)
    is_public: bool = False

class ProjectResponse(BaseModel):
    id: str
    name: str
    description: str
    is_public: bool
    created_at: datetime

Configuration with BaseSettings

Use pydantic-settings for environment-based configuration. It reads env vars automatically and validates types at startup — fail fast before any work begins:

from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    service_name: str = "my-api"
    stage: str = "dev"
    database_url: str        # required — no default
    api_key: str             # required — no default
    max_retries: int = 3

    model_config = {"env_file": ".env", "env_prefix": "APP_"}

settings = Settings()  # reads APP_DATABASE_URL, APP_API_KEY, etc.

Choosing the Right Type

UseWhen
BaseModelValidation needed, API boundaries, config, JSON parsing
@dataclassPure data containers with no validation or serialization
TypedDictTyping only — no runtime instances, plain dict interop

Never use plain dict for structured data that crosses a function or module boundary.

Documentation

  • Write docstrings following Google docstring standards.
def process_items(items: list[str], max_count: int = 10) -> dict[str, int]:
    """Process a list of items and return frequency counts.

    Args:
        items: List of item names to process.
        max_count: Maximum number of items to include in results.

    Returns:
        Dictionary mapping item names to their frequency counts.

    Raises:
        ValueError: If items list is empty.
    """

Error Handling

  • Wrap main logic in try/except blocks.
  • Log errors before re-raising or returning error codes.
  • Use specific exception types rather than bare except.

Logging

  • Use the logging module, never print() for operational output.
  • Use appropriate log levels: DEBUG for detail, INFO for progress, WARNING for recoverable issues, ERROR for failures.

Linting and Formatting

  • Use Ruff for both linting and formatting.
  • Configure Ruff in pyproject.toml:
[tool.ruff]
line-length = 100
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP", "B", "SIM"]

[tool.mypy]
strict = true

Testing

  • Use pytest as the test framework.
  • Name test files test_<module>.py and test functions test_<behavior>.
  • Use descriptive test class and method names that read as specifications.
  • Mock external dependencies (APIs, file systems, databases).
  • Use tmp_path fixture for file system tests.
  • Test edge cases: empty inputs, missing config, error conditions, boundary values.

IDE Integration

For VS Code / Cursor configuration with Pylance type checking, Ruff format-on-save, uv virtual environment discovery, and pytest test runner, see the ide-setup skill. For FastAPI web server patterns and Lambda deployment, see the python-web-server skill. For general testing strategy and coverage thresholds, see the testing skill. For data pipeline development with dlt, see the data-pipelines skill. For DataFrame analysis workflows with pandas, Polars, and DuckDB, see the data-analysis skill.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.