Python Architecture
ASecurityNo. A Python domain rule should not import `psycopg2` directly; that couples domain policy to the database adapter. Define a repository port in the domain/application layer, inject it into the rule or service, and implement it with a thin `psycopg2` adapter at the edge. Compose the dependency in startup/wiring code. ```python from typing import Protocol class TaskRepository(Protocol): def get_task(self, task_id: str) -> "Task": ... class StatusRule: def __init__(self, tasks: TaskRepository): ...
- 584 stars
- 0 votes
- 0 copies
- 3 views
- Added September 5, 2026
Security analysis
100/100Pro scans all 9 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill python-architecture --agent claude-codeAre you the author of Python Architecture?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-python-architecture)No. A Python domain rule should not import `psycopg2` directly; that couples domain policy to the database adapter.
Define a repository port in the domain/application layer, inject it into the rule or service, and implement it with a thin `psycopg2` adapter at the edge. Compose the dependency in startup/wiring code.
```python
from typing import Protocol
class TaskRepository(Protocol):
def get_task(self, task_id: str) -> "Task": ...
class StatusRule:
def __init__(self, tasks: TaskRepository):
self.tasks = tasks # injected dependency
def decide(self, task_id: str) -> str:
task = self.tasks.get_task(task_id)
return "done" if task.completed else "pending"
```
Keep DB imports out of domain policy, place workflow orchestration in a service, and add focused tests using an in-memory or mock repository.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.