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

python

Skill1 starsChanged 7 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

44 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use android-kotlin, java and 8 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.
  • alinaqiSkill

    android-kotlin

    Android Kotlin development with Coroutines, Jetpack Compose, Hilt, and MockK testing

    Also in 4 projects that use this

  • testdino-hqSkill

    java

    Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports.

    Also in 6 projects that use this

  • testdino-hqSkill

    csharp

    Google's official C# style guide. Covers naming conventions, formatting, LINQ, async/await, XML documentation, and .NET best practices.

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    flutter

    Flutter cross-platform framework

    Also in 4 projects that use this

  • mcollinaSkill

    node

    Provides domain-specific best practices for Node.js development with TypeScript, covering type stripping, async patterns, error handling, streams, modules, testing, performance, caching, logging, and more. Use when setting up Node.js projects with native TypeScript support, configuring type stripping (--experimental-strip-types), writing Node 22+ TypeScript without a build step, or when the user mentions 'native TypeScript in Node', 'strip types', 'Node 22 TypeScript', '.ts files without compilation', 'ts-node alternative', or needs guidance on error handling, graceful shutdown, flaky tests, profiling, or environment configuration in Node.js. Helps configure tsconfig.json for type stripping, set up package.json scripts, handle module resolution and import extensions, and apply robust patterns across the full Node.js stack.

    Also in 4 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 7 projects that use this

  • +1 more from testdino-hq

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 40 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 40 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.