claude-desktop-skills/python-architect/SKILL.md
You are an expert at Python application architecture and best practices.
npx skillsauth add ViggyV/claude-skills Python ArchitectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert at Python application architecture and best practices.
This skill activates when the user needs help with:
myproject/
├── src/
│ └── myproject/
│ ├── __init__.py
│ ├── __main__.py
│ ├── api/
│ │ ├── __init__.py
│ │ ├── routes.py
│ │ └── schemas.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── config.py
│ │ └── security.py
│ ├── domain/
│ │ ├── __init__.py
│ │ ├── models.py
│ │ └── services.py
│ ├── infrastructure/
│ │ ├── __init__.py
│ │ ├── database.py
│ │ └── repositories.py
│ └── utils/
│ ├── __init__.py
│ └── helpers.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── unit/
│ └── integration/
├── scripts/
├── docs/
├── pyproject.toml
├── README.md
└── .env.example
# pyproject.toml
[project]
name = "myproject"
version = "0.1.0"
description = "My Python Project"
requires-python = ">=3.11"
dependencies = [
"fastapi>=0.104.0",
"pydantic>=2.0",
"sqlalchemy>=2.0",
]
[project.optional-dependencies]
dev = [
"pytest>=7.0",
"pytest-cov",
"ruff",
"mypy",
]
[tool.ruff]
target-version = "py311"
line-length = 100
select = ["E", "F", "I", "N", "W", "UP"]
[tool.mypy]
python_version = "3.11"
strict = true
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v --cov=src"
# Dependency Injection
from abc import ABC, abstractmethod
from dataclasses import dataclass
class UserRepository(ABC):
@abstractmethod
async def get(self, user_id: str) -> User | None: ...
@abstractmethod
async def save(self, user: User) -> User: ...
class PostgresUserRepository(UserRepository):
def __init__(self, session: AsyncSession):
self.session = session
async def get(self, user_id: str) -> User | None:
return await self.session.get(User, user_id)
class UserService:
def __init__(self, repo: UserRepository):
self.repo = repo
async def get_user(self, user_id: str) -> User:
user = await self.repo.get(user_id)
if not user:
raise UserNotFoundError(user_id)
return user
# Factory Pattern
class NotificationFactory:
_notifiers = {}
@classmethod
def register(cls, type_: str, notifier_class):
cls._notifiers[type_] = notifier_class
@classmethod
def create(cls, type_: str, **kwargs) -> Notifier:
return cls._notifiers[type_](**kwargs)
# Singleton (thread-safe)
from functools import lru_cache
@lru_cache(maxsize=1)
def get_config() -> Config:
return Config()
# config.py
from functools import lru_cache
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
app_name: str = "MyApp"
debug: bool = False
database_url: str
redis_url: str | None = None
secret_key: str
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
@lru_cache
def get_settings() -> Settings:
return Settings()
# Usage
settings = get_settings()
from typing import TypeVar, Generic, Protocol
from collections.abc import Sequence
T = TypeVar("T")
class Repository(Protocol[T]):
async def get(self, id: str) -> T | None: ...
async def list(self) -> Sequence[T]: ...
async def save(self, entity: T) -> T: ...
# Use modern syntax (Python 3.10+)
def process(items: list[str] | None = None) -> dict[str, int]:
items = items or []
return {item: len(item) for item in items}
# TypedDict for structured dicts
from typing import TypedDict
class UserDict(TypedDict):
id: str
name: str
email: str
# Custom exceptions
class AppError(Exception):
def __init__(self, message: str, code: str | None = None):
self.message = message
self.code = code
super().__init__(message)
class NotFoundError(AppError):
def __init__(self, resource: str, id: str):
super().__init__(f"{resource} with id {id} not found", "NOT_FOUND")
class ValidationError(AppError):
def __init__(self, errors: list[str]):
super().__init__("Validation failed", "VALIDATION_ERROR")
self.errors = errors
# Context manager for cleanup
from contextlib import asynccontextmanager
@asynccontextmanager
async def database_transaction():
session = await get_session()
try:
yield session
await session.commit()
except Exception:
await session.rollback()
raise
finally:
await session.close()
Provide:
data-ai
Use this skill for reinforcement learning tasks including training RL agents (PPO, SAC, DQN, TD3, DDPG, A2C, etc.), creating custom Gym environments, implementing callbacks for monitoring and control,
testing
You are an expert at optimizing SQL queries for performance and efficiency.
tools
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a G
tools
21 production-ready scripts for iOS app testing, building, and automation. Provides semantic UI navigation, build automation, accessibility testing, and simulator lifecycle management. Optimized for A