Enforces type hints, docstrings, and Python best practices. Use when writing or refactoring Python code, creating new functions, or when user mentions "production-ready" or "type-safe" code.
When writing Python code in this project, ALWAYS follow these rules:
Type hints are mandatory
from collections.abc import for generic types (list, dict, set)Any type - if type is unknown, use object or create proper ProtocolDocstrings are required
Modern Python syntax (3.12+)
list[str] instead of List[str] from typingdict[str, int] instead of Dict[str, int]X | None instead of Optional[X]X | Y for Union typesBefore finishing ANY code changes, run these checks:
# 1. Format with Ruff
poetry run ruff format .
# 2. Lint with Ruff
poetry run ruff check . --fix
# 3. Type check with mypy (if available)
poetry run mypy app/ --ignore-missing-imports
def get_user(id):
user = db.get(id)
return user
def get_user(user_id: int) -> User | None:
"""Fetch user by ID from database.
Args:
user_id: The unique identifier of the user
Returns:
User object if found, None otherwise
Raises:
DatabaseError: If database connection fails
"""
user = db.get(user_id)
return user
# Always use dependency injection
@router.get("/users/{user_id}")
async def get_user(
user_id: int,
db: DatabaseSession = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> UserResponse:
"""Get user by ID."""
...
# Always define explicit response models
class UserResponse(BaseModel):
id: int
username: str
email: EmailStr
created_at: datetime
class Config:
from_attributes = True
Before ANY commit:
If any check fails, FIX IT before showing me the code.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer