agentleFS
ai-enhanced-engineerai-enhanced-engineer/aiee-skills/skills/arch-python-modern/SKILL.md

arch-python-modern

Skill4 starsChanged 5 months agoMITView on GitHub

Modern Python 3.10+ development standards including type hints, async patterns, pathlib, dataclasses, and recommended tooling (uv, Ruff, pytest). Use for Python code review, new feature implementation, refactoring legacy code, or making architecture decisions about Python projects.

  • Installs packages

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use asyncio with TaskGroup for structured concurrency (3.11+)

    line 33
  2. Very specific:

    Use StrEnum for status fields.

    line 58
  3. Very specific:

    Use @computed_field @property — included in .model_dump() and JSON schema.

    line 61

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Modern Python Standards

Development practices for Python 3.10+ focusing on type safety, modern idioms, and efficient tooling.

Recommended Stack

CategoryTool
Package Managementuv (preferred) or Poetry
Linting/FormattingRuff
Type Checkingmypy (strict mode)
Testingpytest with coverage
Web APIsFastAPI
Data ProcessingPolars or Pandas

Key Patterns

Type Hints

  • Public functions use type hints — enables static analysis and IDE tooling
  • X | None for nullable (3.10+), list[X] over List[X] (3.9+)
  • TypeVar for generics, Protocol for structural typing

Async

  • Use asyncio with TaskGroup for structured concurrency (3.11+)
  • Blocking calls in async context stall the event loop — use asyncio.gather() for concurrent I/O

Path Handling

  • pathlib.Path over os.path; use .read_text(), .write_text()
  • Sanitize user-controlled filenames: replace("/", "_").replace("\\", "_") before Path(name).name. See reference.md → User-Controlled Filename Sanitization.
  • Resolve vault/repo roots from a config file, not Path(__file__).parents[N] — relocation silently breaks __file__-relative walks. See reference.md → Config-Resolved Roots.

Error Handling

  • Specific exceptions over bare except: — bare form catches SystemExit and KeyboardInterrupt
  • Context managers for resources; logging with structlog
  • logging.error("msg", exc_info=e) — preserves traceback; not f-string interpolation

Pydantic Settings Validation

@property (lazy) → @field_validator (per-field) → @model_validator (cross-field, after parse). Use @model_validator for cross-field security controls. See reference.md → Pydantic Validators.

Pydantic Dual-Purpose Models

Storage + API response in one model: use a thin response model, not serialization_alias — alias changes affect GCS/DB output. See reference.md → Pydantic Dual-Purpose Models.

Pydantic Value Objects

Compare with str() on both sides: str(a) != str(b) — prevents silent type-mismatch failures.

StrEnum for Status Fields

Use StrEnum for status fields. ORM defaults: default=WidgetStatus.ACTIVE, not default="active" (bare strings go out of sync).

Computed Fields

Use @computed_field @property — included in .model_dump() and JSON schema. Avoid __init__ assignment (bypasses Pydantic validation lifecycle).

Module Dispatch

  • Per-module MODE constant + uniform render() / write() / main() triple lets one orchestrator dispatch heterogeneous modules with no per-module branching.
  • Registry-driven orchestrator: dict mapping selector → (callable, mode, defaults) — adding a module is a one-line change. See reference.md → Module Dispatch Patterns.

Experiment Script Isolation

[project.optional-dependencies] groups keep AI/ML deps out of the production image. Install via uv pip install -e ".[experiments]"; pair with mypy exclude + pytest norecursedirs. See reference.md → Experiment Script Isolation.

Anti-Patterns

Anti-PatternPattern
os.path.join()Path() / "file"
% formattingf-strings
pip installuv add
flake8Ruff
List[str]list[str]
Optional[X]X | None
populate_by_name=True on request modelsKeep False — widens API input surface by accepting both alias and field name
Mutable default argsfield(default_factory=list)
time.time() for elapsedtime.perf_counter()
Custom http_client= without lifecycleLet library manage client
default="active" (bare string)default=WidgetStatus.ACTIVE (StrEnum)
except Exception as err: logging.exception("msg")except Exception: logging.exception("msg") — err unused (ruff F841); exception captured from call stack
Path(__file__).parents[N] for repo rootResolve root from config file — __file__-relative walks break on relocation

See reference.md for: type hints, dataclasses, async patterns, path handling, error handling, docstrings, resource leaks, tooling config, git tracking in ignored dirs, LRU cache with model_copy(), config-resolved roots, module dispatch patterns.

See examples.md for: project structure, type-safe config, async HTTP client, repository pattern, modern testing, FastAPI endpoints, structured logging, Django+OpenCV pipeline.

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.