Skip to content
Development
Skill

/server-skills

Server-specific best practices for FastAPI, Celery, and Pydantic. Extends python-skills with framework-specific patterns.

From plugin
llamafarm
83619 skills1 MCP

Claude Code

$ npx -y skills add llama-farm/llamafarm --skill server-skills --agent claude-code

SKILL.md

server-skills.SKILL.md
name: server-skills
description: Server-specific best practices for FastAPI, Celery, and Pydantic. Extends python-skills with framework-specific patterns.
allowed-tools: Read, Grep, Glob, Bash
user-invocable: false

Server Skills for LlamaFarm

Framework-specific patterns and code review checklists for the LlamaFarm Server component.

Overview

| Property | Value | |----------|-------| | Path | `server/` | | Python | 3.12+ | | Framework | FastAPI 0.116+ | | Task Queue | Celery 5.5+ | | Validation | Pydantic 2.x, pydantic-settings | | Logging | structlog with FastAPIStructLogger |

Links to Shared Skills

This skill extends the shared Python skills. See:

  • [Python Patterns](../python-skills/patterns.md) - Dataclasses, comprehensions, imports
  • [Async Patterns](../python-skills/async.md) - async/await, asyncio, concurrency
  • [Typing Patterns](../python-skills/typing.md) - Type hints, generics, Pydantic
  • [Testing Patterns](../python-skills/testing.md) - Pytest, fixtures, mocking
  • [Error Handling](../python-skills/error-handling.md) - Exceptions, logging, context managers
  • [Security Patterns](../python-skills/security.md) - Path traversal, injection, secrets

Server-Specific Checklists

| Topic | File | Key Points | |-------|------|------------| | FastAPI | [fastapi.md](fastapi.md) | Routes, dependencies, middleware, exception handlers | | Celery | [celery.md](celery.md) | Task patterns, error handling, retries, signatures | | Pydantic | [pydantic.md](pydantic.md) | Pydantic v2 models, validation, serialization | | Performance | [performance.md](performance.md) | Async patterns, caching, connection pooling |

Architecture Overview

server/
├── main.py                 # Uvicorn entry point, MCP mount
├── api/
│   ├── main.py             # FastAPI app factory, middleware setup
│   ├── errors.py           # Custom exceptions + exception handlers
│   ├── middleware/         # ASGI middleware (structlog, errors)
│   └── routers/            # API route modules
│       ├── projects/       # Project CRUD endpoints
│       ├── datasets/       # Dataset management
│       ├── rag/            # RAG query endpoints
│       └── ...
├── core/
│   ├── settings.py         # pydantic-settings configuration
│   ├── logging.py          # structlog setup, FastAPIStructLogger
│   └── celery/             # Celery app configuration
│       ├── celery.py       # Celery app instance
│       └── rag_client.py   # RAG task signatures and helpers
├── services/               # Business logic layer
│   ├── project_service.py  # Project CRUD operations
│   ├── dataset_service.py  # Dataset management
│   └── ...
├── agents/                 # AI agent implementations
└── tests/                  # Pytest test suite

Quick Reference

Settings Pattern (pydantic-settings)

from pydantic_settings import BaseSettings

class Settings(BaseSettings, env_file=".env"):
    HOST: str = "0.0.0.0"
    PORT: int = 14345
    LOG_LEVEL: str = "INFO"

settings = Settings()  # Module-level singleton

Structured Logging

from core.logging import FastAPIStructLogger

logger = FastAPIStructLogger(__name__)
logger.info("Operation completed", extra={"count": 10, "duration_ms": 150})
logger.bind(namespace=namespace, project=project_id)  # Add context

Custom Exceptions

# Define exception hierarchy
class NotFoundError(Exception): ...
class ProjectNotFoundError(NotFoundError):
    def __init__(self, namespace: str, project_id: str):
        self.namespace = namespace
        self.project_id = project_id
        super().__init__(f"Project {namespace}/{project_id} not found")

# Register handler in api/errors.py
async def _handle_project_not_found(request: Request, exc: Exception) -> Response:
    payload = ErrorResponse(error="ProjectNotFound", message=str(exc))
    return JSONResponse(status_code=404, content=payload.model_dump())

def register_exception_handlers(app: FastAPI) -> None:
    app.add_exception_handler(ProjectNotFoundError, _handle_project_not_found)

Service Layer Pattern

class ProjectService:
    @classmethod
    def get_project(cls, namespace: str, project_id: str) -> Project:
        project_dir = cls.get_project_dir(namespace, project_id)
        if not os.path.isdir(project_dir):
            raise ProjectNotFoundError(namespace, project_id)
        # ... load and validate

Review Checklist Summary

1. **FastAPI Routes** (High priority)

  • Proper async/sync function choice
  • Response model defined with `response_model=`
  • OpenAPI metadata (operation_id, tags, summary)
  • HTTPException with proper status codes

2. **Celery Tasks** (High priority)

  • Use signatures for cross-service calls
  • Implement proper timeout and polling
  • Handle task failures gracefully
  • Store group metadata for parallel tasks

3. **Pydantic Models** (Medium priority)

  • Use Pydantic v2 patterns (model_config, Field)
  • Proper validation with field constraints
  • Serialization with model_dump()

4. **Performance** (Medium priority)

  • Avoid blocking calls in async functions
  • Use proper connection pooling for external services
  • Implement caching where appropriate

See individual topic files for detailed checklists with grep patterns.

Read more
@llama-farm
Ships withllamafarm

Enterprise AI capabilities on your own hardware. No cloud required. LlamaFarm is an open-source AI platform that runs entirely on your hardware.

83619 skills1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
836
Star history of llama-farm/llamafarm on GitHub, a chart by star-history.com

Other skills on llamafarm.

cli-skills

cli-skills

CLI best practices for LlamaFarm. Covers Cobra, Bubbletea, Lipgloss patterns for Go CLI development.

code-review

code-review

Comprehensive code review for diffs. Analyzes changed code for security vulnerabilities, anti-patterns, and quality issues.…

commit-push-pr

commit-push-pr

Commit changes, push to GitHub, and open a PR. Includes quality checks (security, patterns, simplification). Use --quick to skip…

common-skills

common-skills

Best practices for the Common utilities package in LlamaFarm. Covers HuggingFace Hub integration, GGUF model management, and…

config-skills

config-skills

Configuration module patterns for LlamaFarm. Covers Pydantic v2 models, JSONSchema generation, YAML processing, and validation.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills12d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about server-skills.

Which coding agents can use server-skills?
server-skills installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.