Backend python
Skill FairMind-Gen-AI-Studio/fairmind-integration/skills/backend-python
Use when implementing backend features with Python, FastAPI, or Pydantic. This skill covers API design, data validation, async patterns, and testing strategies for Python backend applications.From its SKILL.md
npx -y skills add FairMind-Gen-AI-Studio/fairmind-integration --skill backend-pythonAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.4 KB, as published. Nobody here has run it
Backend Development with Python
Overview
This skill provides guidance for backend development using Python with FastAPI for APIs and Pydantic for data validation.
Announce at start: "I'm using the backend-python skill for this Python backend implementation."
When to Use
Use this skill when:
- Creating FastAPI endpoints
- Implementing Pydantic models for validation
- Writing async Python code
- Building REST APIs with Python
- Implementing background tasks
- Testing Python backend code
Core Workflow
Step 1: Understand API Requirements
Before implementing:
- Review the API contract from user story
- Identify data models and validation rules
- Plan async vs sync operations
- Design error handling strategy
Step 2: Design Data Models
- Define Pydantic models for request/response
- Plan validation rules and constraints
- Consider serialization needs
- Document model relationships
Step 3: Implement Endpoints
Follow this order:
- Models first - Define Pydantic schemas
- Dependencies - Create reusable dependencies
- Business logic - Implement service layer
- Endpoints - Create FastAPI routes
- Error handling - Handle all error cases
Step 4: Test and Document
- Write pytest tests for endpoints
- Verify error handling
- Test async behavior
- Generate OpenAPI docs
Reference Files
| File | Content | When to Use |
|---|---|---|
references/fastapi-patterns.md | API design, dependencies | Creating endpoints |
references/pydantic-models.md | Data validation, schemas | Data modeling |
references/async-patterns.md | Async/await, concurrency | Async operations |
references/testing-patterns.md | Pytest, fixtures | Testing |
Key Principles
API Design
- Use appropriate HTTP methods
- Return consistent response formats
- Use dependency injection
- Document with docstrings
Data Validation
- Validate inputs with Pydantic
- Use custom validators for complex rules
- Handle validation errors gracefully
- Provide meaningful error messages
Performance
- Use async for I/O operations
- Implement connection pooling
- Cache expensive computations
- Profile and optimize hot paths
Integration with Fairmind
When working on Fairmind tasks:
- Use
fairmind-contextskill to gather requirements - Check work package for API specifications
- Reference architectural blueprints
- Update journal with decisions
Example Usage
# Example: User API endpoint
from fastapi import APIRouter, HTTPException, Depends
from pydantic import BaseModel, EmailStr
from typing import Optional
router = APIRouter(prefix="/users", tags=["users"])
class UserCreate(BaseModel):
name: str
email: EmailStr
role: str = "user"
class UserResponse(BaseModel):
id: str
name: str
email: str
role: str
class Config:
from_attributes = True
@router.post("/", response_model=UserResponse, status_code=201)
async def create_user(user_data: UserCreate):
"""Create a new user."""
user = await user_service.create(user_data)
return user
Next Steps
After completing implementation:
- Use
fairmind-tddskill for testing - Request code review
- Document API endpoints