architecture-python
Skill9 starsChanged 8 months agoMITView on GitHub
Python architecture: PEP-8, type hints, clean layering, dependency injection, and testing strategy
In this repository31 other files it gives its agents.
- git-workflow-releaseSkill
- skill-authoring-generalSkill
- git-workflow-releaseSkill
- skill-authoring-generalSkill
- accessibility-generalSkill
- accessibility-react-nativeSkill
- architecture-generalSkill
- assistant-rocky-lti-assistSkill
- assistant-ucd-mobileSkill
- ci-cd-github-actionsSkill
- code-review-generalSkill
- code-review-pythonSkill
- code-review-typescriptSkill
- data-science-pythonSkill
- design-frontendSkill
- documentation-projectSkill
- documentation-readmeSkill
- git-workflow-generalSkill
- git-workflow-monorepoSkill
- git-workflow-pr-generatorSkill
- git-workflow-releaseSkill
- infrastructure-terraformSkill
- package-management-pythonSkill
- project-management-jiraSkill
- refactoring-typescriptSkill
- security-generalSkill
- skill-authoring-generalSkill
- testing-generalSkill
- testing-javaSkill
- testing-pythonSkill
- testing-typescriptSkill
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
- Very specific: line 11
Follow PEP-8. Use ruff for linting and formatting.
- Very specific: line 12
Use type hints everywhere.
- Very specific: line 13
Prefer dataclasses or pydantic for structured data over plain dicts.
- Very specific: line 42
Factories: use @classmethod factory methods for complex initialization.
- Very specific: line 43
Value objects: use @dataclass(frozen=True) for immutable domain objects.
- Very specific: line 48
Never use bare except: — always specify the exception type.
- Very specific: line 52
Use asyncio + async/await for I/O-bound work (HTTP, DB with asyncpg/SQLAlchemy async).
- Very specific: line 53
Don't mix sync and async without asyncio.run_in_executor for blocking calls.
- Very specific: line 54
Use asyncio.gather for concurrent independent I/O operations.
≈ “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.
Files
Architecture — Python
In addition to general architecture principles, apply these Python-specific patterns:
Code Quality
- Follow PEP-8. Use
rufffor linting and formatting. - Use type hints everywhere. Run
mypy --strictin CI. - Prefer
dataclassesorpydanticfor 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
@classmethodfactory 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/awaitfor I/O-bound work (HTTP, DB with asyncpg/SQLAlchemy async). - Don't mix sync and async without
asyncio.run_in_executorfor blocking calls. - Use
asyncio.gatherfor concurrent independent I/O operations.
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
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.

