agentleFS
ucdavisucdavis/ai-skills-registry/skills/architecture-python/SKILL.md

architecture-python

Skill9 starsChanged 8 months agoMITView on GitHub

Python architecture: PEP-8, type hints, clean layering, dependency injection, and testing strategy

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 0 are distinctive, and 9 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.

  • 9

    Very specific

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

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

    Follow PEP-8. Use ruff for linting and formatting.

    line 11
  2. Very specific:

    Use type hints everywhere.

    line 12
  3. Very specific:

    Prefer dataclasses or pydantic for structured data over plain dicts.

    line 13
  4. Very specific:

    Factories: use @classmethod factory methods for complex initialization.

    line 42
  5. Very specific:

    Value objects: use @dataclass(frozen=True) for immutable domain objects.

    line 43
  6. Very specific:

    Never use bare except: — always specify the exception type.

    line 48
  7. Very specific:

    Use asyncio + async/await for I/O-bound work (HTTP, DB with asyncpg/SQLAlchemy async).

    line 52
  8. Very specific:

    Don't mix sync and async without asyncio.run_in_executor for blocking calls.

    line 53
  9. Very specific:

    Use asyncio.gather for concurrent independent I/O operations.

    line 54

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Architecture — Python

In addition to general architecture principles, apply these Python-specific patterns:

Code Quality

  • Follow PEP-8. Use ruff for linting and formatting.
  • Use type hints everywhere. Run mypy --strict in CI.
  • Prefer dataclasses or pydantic for structured data over plain dicts.

Project Structure

src/
  myapp/
    domain/          # pure business logic, no I/O
      models.py
      services.py
    application/     # use cases, orchestrates domain
      use_cases.py
    infrastructure/  # DB, HTTP, filesystem
      repositories.py
      http_client.py
    presentation/    # FastAPI routes, CLI, etc.
      routes.py
  tests/
    unit/
    integration/

Patterns

  • Repository: abstract data access behind a protocol/ABC.
    class UserRepository(Protocol):
        def find_by_id(self, user_id: UUID) -> User | None: ...
        def save(self, user: User) -> None: ...
  • Dependency injection: accept dependencies as constructor args, not global imports.
  • Factories: use @classmethod factory methods for complex initialization.
  • Value objects: use @dataclass(frozen=True) for immutable domain objects.

Error Handling

  • Define domain-specific exception classes in domain/exceptions.py.
  • Catch broad exceptions only at the boundary (presentation layer).
  • Never use bare except: — always specify the exception type.
  • Log with context; re-raise when the caller needs to handle it.

Async

  • Use asyncio + async/await for I/O-bound work (HTTP, DB with asyncpg/SQLAlchemy async).
  • Don't mix sync and async without asyncio.run_in_executor for blocking calls.
  • Use asyncio.gather for concurrent independent I/O operations.

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.