.agents/skills/dignified-python/references/README.md
Opinionated Python standards for writing clean, maintainable, modern Python code.
dignified-python-core.md - Essential Python standards (always apply)
cli-patterns.md - Command-line interface patterns
versions/)python-3.10.md - Python 3.10+ features
python-3.11.md - Python 3.11+ features
python-3.12.md - Python 3.12+ features
python-3.13.md - Python 3.13+ features
advanced/)exception-handling.md - Exception patterns
interfaces.md - Interface design
typing-advanced.md - Advanced typing
api-design.md - API design principles
Modern Type Syntax: Use Python 3.10+ type syntax everywhere
# Good (modern)
def process(items: list[str]) -> str | None:
pass
# Avoid (legacy)
from typing import List, Optional
def process(items: List[str]) -> Optional[str]:
pass
Prefer LBYL When It Is Cheap and Precise: This skill leans toward explicit precondition
checks for routine branching, while still using targeted try/except blocks when parsing or API
calls are the authoritative test.
# Good (LBYL)
if path.exists():
content = path.read_text()
# Avoid (EAFP)
try:
content = path.read_text()
except FileNotFoundError:
pass
Pathlib Over os.path: Use pathlib for all file operations
# Good
from pathlib import Path
config_path = Path("config.yaml")
if config_path.exists():
content = config_path.read_text()
# Avoid
import os
if os.path.exists("config.yaml"):
with open("config.yaml") as f:
content = f.read()
Absolute Imports: Never use relative imports
# Good
from myproject.utils import helper
# Avoid
from .utils import helper
from ..shared import helper
Error Boundaries at CLI Level: Handle errors at the CLI entry point, not deep in the stack
# Basic types
def greet(name: str) -> str:
return f"Hello, {name}"
# Collections (modern syntax)
def process(items: list[str], mapping: dict[str, int]) -> tuple[str, int]:
pass
# Optional/Union (modern syntax)
def find(query: str) -> str | None:
pass
# Multiple types
def parse(value: str | int | float) -> float:
pass
# File operations
if path.exists():
content = path.read_text()
# Dictionary access
if "key" in data:
value = data["key"]
# Attribute access
if hasattr(obj, "method"):
obj.method()
# Type checking
if isinstance(value, str):
result = value.upper()
from pathlib import Path
# Create path
config = Path("config.yaml")
data_dir = Path("/data")
# Check existence
if config.exists():
pass
# Read/write
content = config.read_text()
config.write_text("data")
# Directory operations
for file in data_dir.glob("*.txt"):
print(file.name)
# Path manipulation
full_path = data_dir / "subdir" / "file.txt"
parent = full_path.parent
name = full_path.name
import click
@click.command()
@click.option("--name", required=True, help="User name")
@click.option("--count", default=1, help="Number of times")
def greet(name: str, count: int) -> None:
"""Greet a user multiple times."""
for _ in range(count):
click.echo(f"Hello, {name}!")
if __name__ == "__main__":
greet()
Automatic version detection determines which Python version features are available:
pyproject.toml for requires-python fieldsetup.py/setup.cfg for python_requires.python-version fileBased on detected version, appropriate version-specific features are recommended.
| Situation | Reference |
|---|---|
| Writing any Python code | dignified-python-core.md |
| Building a CLI tool | cli-patterns.md |
| Using Python 3.10 features | versions/python-3.10.md |
| Using Python 3.11 features | versions/python-3.11.md |
| Using Python 3.12 features | versions/python-3.12.md |
| Using Python 3.13 features | versions/python-3.13.md |
| Handling exceptions | advanced/exception-handling.md |
| Designing interfaces | advanced/interfaces.md |
| Complex type hints | advanced/typing-advanced.md |
| API design decisions | advanced/api-design.md |
/dagster-best-practices - Dagster-specific patterns (not general Python)/dg - Dagster CLI operations/dagster-expert - Dagster expertise including integrationsImportant: /dignified-python is for general-purpose Python style guidance, not
Dagster-specific patterns. It is intentionally opinionated rather than universal. For Dagster
patterns, use /dagster-best-practices.
Users invoke /dignified-python when they need Python code quality guidance, regardless of whether
it's for a Dagster project or any other Python project.
Workflow:
User: "Is this good Python code?"
→ /dignified-python (check dignified-python-core.md)
→ Apply modern type syntax, LBYL, pathlib patterns
→ Check version-specific features based on project
User: "How should I structure my Dagster assets?"
→ /dagster-best-practices (NOT dignified-python)
→ Learn asset patterns, dependencies, partitions
These standards reflect production-tested conventions:
Each reference document follows a consistent structure:
Users only invoke /dignified-python when they want Python standards guidance. The skill
description makes it clear it's for general Python quality, not Dagster-specific patterns, so users
naturally select it when appropriate.
Users will invoke this when they want:
Users will NOT invoke this when they want:
/dagster-best-practices)/dg)/dagster-expert)