Agent skill
python
Develops Python 3.11+ backend services for Bookkeep using FastAPI, SQLAlchemy, and async patterns. Use when: writing routers, models, schemas, background tasks, or database operations in backend/app/
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/python-boludo00-bookkeep
SKILL.md
Python Skill
This codebase uses Python 3.11+ with FastAPI for async REST APIs, SQLAlchemy 2.x for ORM, and Pydantic for validation. All code lives in backend/app/. Use uv for package management and structlog for logging.
Quick Start
Router Pattern
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from app import models, schemas, database
import structlog
logger = structlog.get_logger()
router = APIRouter()
@router.get("/{book_id}", response_model=schemas.BookResponse)
async def get_book(book_id: int, db: Session = Depends(database.get_db)):
book = db.query(models.Book).filter(models.Book.id == book_id).first()
if not book:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Book not found")
return book
Async Service Pattern
async def check_availability(book: models.Book, db: Session) -> dict:
for server in get_servers(db):
try:
async with create_client(server) as client:
result = await client.lookup(book.hardcover_id)
if result:
return {"available": True, "source": server.name}
except Exception as e:
logger.warning("availability_check_failed", server_id=server.id, error=str(e))
return {"available": False}
Key Concepts
| Concept | Usage | Example |
|---|---|---|
| Dependency Injection | Database sessions | db: Session = Depends(get_db) |
| Auth dependencies | Current user | user: models.User = Depends(get_current_user) |
| Response models | Type validation | response_model=schemas.BookResponse |
| ORM mode | Schema config | from_attributes = True |
File Naming
- Files:
snake_case.py(e.g.,download_settings.py) - Classes:
PascalCase(e.g.,BookRequest) - Functions/variables:
snake_case(e.g.,check_availability) - Constants:
SCREAMING_SNAKE(e.g.,CACHE_TTL)
See Also
- patterns - Async, dependency injection, error handling
- types - Pydantic schemas, SQLAlchemy models
- modules - Router structure, services, downloads
- errors - HTTPException patterns, logging
Related Skills
See the fastapi skill for router patterns and OpenAPI integration. See the sqlalchemy skill for ORM queries and relationships. See the pytest skill for testing patterns.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?