fastapi-python — скилл для Claude Code: правила FastAPI-бэкенда
Задаёт агенту стиль разработки на FastAPI: async, Pydantic v2, обработка ошибок и структура роутеров. Пригодится, когда пишете API на Python.
npx skills add Mindrally/skills --skill fastapi-python -a claude-codeЧто делает fastapi-python
Скилл превращает ассистента в FastAPI-разработчика с набором правил. Он просит писать короткие ответы с рабочими примерами на Python, ставить async def там, где есть ввод-вывод, и использовать Pydantic-модели вместо сырых словарей.
Внутри — разделы про стандарты кода, обработку ошибок, специфику FastAPI и производительность. Для ошибок советуется ранний возврат и guard clauses, а не вложенные else. Роуты объявляются с аннотациями возвращаемого типа, для старта и остановки приложения берётся lifespan-контекст, ожидаемые сбои отдаются через HTTPException.
Скилл называет зависимости: FastAPI, Pydantic v2, asyncpg или aiomysql и SQLAlchemy 2.0. Если в проекте другая ORM или Pydantic первой версии, советы по моделям и сериализации придётся адаптировать — это повод проверить, что у вас стоит.
Какие задачи решает
- разложить роуты FastAPI по модулям без дублирования
- перевести блокирующие вызовы БД на async
- описать схемы запроса и ответа через Pydantic v2
- вынести обработку ошибок в guard clauses с ранним возвратом
- настроить lifespan вместо событий startup и shutdown
Примеры запросов агенту
- добавь эндпоинт создания заказа в
routers/order_routes.py, валидацию сделай через Pydantic - перепиши этот обработчик на async и убери блокирующий вызов базы
- проверь мой роутер: где тут стоит добавить guard clause и HTTPException
Как установить fastapi-python
1Через Skills CLI (Vercel)
npx skills add Mindrally/skills --skill fastapi-python -a claude-code2Вручную: положить файлы
~/.claude/skills/fastapi-python/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/fastapi-python/
1Через Skills CLI (Vercel)
npx skills add Mindrally/skills --skill fastapi-python -a codex2Вручную: положить файлы
.agents/skills/fastapi-python/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add Mindrally/skills --skill fastapi-python -a cursor2Вручную: положить файлы
.cursor/skills/fastapi-python/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install Mindrally/skills fastapi-python2Вручную: положить файлы
.github/skills/fastapi-python/SKILL.md1Через Skills CLI (Vercel)
npx skills add Mindrally/skills --skill fastapi-python -a gemini-cli2Командой платформы
gemini skills install https://github.com/Mindrally/skills --path fastapi-pythonВручную: положить файлы
.devin/skills/fastapi-python/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add Mindrally/skills --skill fastapi-python -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора168
Похожие
Рядом в теме «Бэкенд и API»
Всё по теме «Бэкенд и API» →Вопросы о fastapi-python
Как установить fastapi-python в Claude?
Выполните npx skills add Mindrally/skills --skill fastapi-python -a claude-code. После этого файл скилла появится по пути ~/.claude/skills/fastapi-python/SKILL.md.
Что делает скилл fastapi-python?
Он задаёт агенту правила разработки на FastAPI: async для операций ввода-вывода, Pydantic-модели для валидации, ранний возврат при ошибках, lifespan для старта и остановки приложения.
Какие зависимости нужны для работы скилла?
В нём названы FastAPI, Pydantic v2, asyncpg или aiomysql и SQLAlchemy 2.0. Если у вас Pydantic первой версии, примеры моделей и сериализации придётся переписывать.
Исходный текст
SKILL.md · Apache-2.0
--- name: fastapi-python description: Expert in FastAPI Python development with best practices for APIs and async operations metadata: maintainer: Mindrally source: https://github.com/Mindrally/skills --- # FastAPI Python You are an expert in FastAPI and Python backend development. ## Key Principles - Write concise, technical responses with accurate Python examples - Favor functional, declarative programming over class-based approaches - Prioritize modularization to eliminate code duplication - Use descriptive variable names with auxiliary verbs (e.g., `is_active`, `has_permission`) - Employ lowercase with underscores for file/directory naming (e.g., `routers/user_routes.py`) - Export routes and utilities explicitly - Follow the RORO (Receive an Object, Return an Object) pattern ## Python/FastAPI Standards - Use `def` for pure functions, `async def` for asynchronous operations - Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries - Structure: exported router, sub-routes, utilities, static content, types (models, schemas) - Omit curly braces for single-line conditionals - Write concise one-line conditional syntax ## Error Handling - Handle edge cases at function entry points - Employ early returns for error conditions - Place happy path logic last - Avoid unnecessary else statements; use if-return patterns - Implement guard clauses for preconditions - Provide proper error logging and user-friendly messaging ## FastAPI-Specific Guidelines - Use functional components (plain functions) and Pydantic models for input validation - Declare routes with clear return type annotations - Prefer lifespan context managers for managing startup and shutdown events - Leverage middleware for logging, error monitoring, and optimization - Use HTTPException for expected errors and model them as specific HTTP responses - Apply Pydantic's BaseModel consistently for validation ## Performance Optimization - Minimize blocking I/O; use async for all database and API calls - Implement caching with Redis or in-memory stores - Optimize Pydantic serialization/deserialization - Use lazy loading for large datasets ## Key Conventions 1. Rely on FastAPI's dependency injection system 2. Prioritize API performance metrics (response time, latency, throughput) 3. Structure routes and dependencies for readability and maintainability ## Dependencies FastAPI, Pydantic v2, asyncpg/aiomysql, SQLAlchemy 2.0
© Mindrally · Apache-2.0 · Mindrally/skills