backend-fastapi-python
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "backend-fastapi-python" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-cb8ff6ac47512717f7e8509fc424a26f94c958cbdf3b4aa61b74e969958c88ef. Verify the upstream source and version against https://github.com/avibebuilder/claude-prime before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
For any Python backend work in this project: building FastAPI endpoints, writing service functions, defining Pydantic/SQLModel schemas, running Alembic migrations, or debugging 422 errors. Emphasizes authentication and authorization patterns (get_current_user, is_superuser checks, admin-only guards, role-based access control, dependency chains like Depends()), plus middleware, background tasks, async SQLAlchemy sessions, ORM relationship loading, and request/response design. Activate only for Python API code, FastAPI patterns, or backend architecture in this project — not for frontend, Docker, CI/CD, or infrastructure.
Introduction source: third_party · avibebuilder · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Use this skill for any Python backend work in this project: building FastAPI endpoints, writing service functions, defining Pydantic/SQLModel schemas, running Alembic migrations, or debugging 422 errors. Essential for authentication and authorization patterns — setting up get_current_user, is_superuser checks, admin-only guards, role-based access, and dependency injection chains like Depends(). Also covers middleware, background tasks, async SQLAlchemy sessions, ORM relationship loading, and request/response design. Activate whenever the question involves Python API code, FastAPI patterns, or backend architecture in this codebase. Not for frontend, Docker, CI/CD, or infrastructure.
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- Not specified in the source documentation.
- Software, accounts and paid services
- Not specified in the source documentation.
- Limits and differences
- Not specified in the source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: backend-fastapi-python
description: "Use this skill for any Python backend work in this project: building FastAPI endpoints, writing service functions, defining Pydantic/SQLModel schemas, running Alembic migrations, or debugging 422 errors. Essential for authentication and authorization patterns — setting up get_current_user, is_superuser checks, admin-only guards, role-based access, and dependency injection chains like Depends(). Also covers middleware, background tasks, async SQLAlchemy sessions, ORM relationship loading, and request/response design. Activate whenever the question involves Python API code, FastAPI patterns, or backend architecture in this codebase. Not for frontend, Docker, CI/CD, or infrastructure."Backend FastAPI Python
Project-specific conventions for FastAPI with SQLModel, pydantic-settings, and async SQLAlchemy.
Architecture Decisions
- Services are stateless functions — Not classes. First param is
db: AsyncSession. - Generic response wrapper — Always use
ApiResponse[T]for consistency. - Dependencies chain —
get_current_user->require_auth->require_admin. - Module-scoped config — Each module can have its own
{module}_config.py. - Error codes for frontend —
AppException(status, message, error_code).
Gotchas
- SQLModel
Relationship()fields are NOT included in API responses by default. You must explicitly add them tomodel_configor use a separate response schema with those fields. AsyncSession.refresh()does not load relationships. After commit, re-query with.options(selectinload(...))if you need related objects.- Pydantic V2 uses
model_validatornotvalidator. The@validatordecorator is V1 and will break silently or raise deprecation warnings. Depends()in FastAPI creates a NEW instance per request — don't store state in dependency return values expecting it to persist.- Background tasks (
BackgroundTasks) run AFTER the response is sent. If they fail, the client already got a 200. Use proper task queues (Celery, ARQ) for anything that must not silently fail. - Alembic
--autogeneratemisses: table renames (generates drop+create), index changes on existing columns, andEnumtype modifications in PostgreSQL. Always review generated migrations. async defendpoints block the event loop if you call sync I/O inside them. Userun_in_executorfor sync libraries or define the endpoint asdef(FastAPI runs sync endpoints in a threadpool).HTTPExceptionfrom FastAPI andHTTPExceptionfrom Starlette are different classes. Importing the wrong one causes middleware to miss exception handlers.- SQLAlchemy's
lazy="selectin"on relationships causes N+1 queries in async sessions. Use explicitselectinload()in queries instead. Optional[str] = Nonein query params makes the field optional.str = Nonealso works but loses type information — prefer the explicitOptionalform.- When using
response_model, FastAPI filters OUT any fields not in the model. If your response is missing data, check that the response model includes all fields, not just the ORM model.
References
| When you need... | Read |
|---|---|
| Directory layout | file-structure.md |
| Settings and env vars | configuration.md |
| Database sessions and connections | database.md |
| ORM models | models.md |
| Request/response schemas | schemas.md |
| Router and endpoint patterns | routing.md |
| Service layer patterns | services.md |
| Dependency injection | dependencies.md |
| Middleware setup | middleware.md |
| Error handling | error-handling.md |
| Auth flow example | auth.md |
Version history
-
v1.2.9
GitHub ↗
Original release notes
## 1.2.9 - 🔧 Enforce sequential skill optimization and tighten description char hint
-
v1.2.8
GitHub ↗
Original release notes
## 1.2.8 - 🔧 Stop ask-rule from blocking on facts Claude can look up itself - 🔧 Rebalance discuss skill so pushback is contextual, not default
-
v1.2.7
GitHub ↗
Original release notes
## 1.2.7 - ✨ Add humanizer starter skill - 🔧 Note skill description char limits (soft ~650, hard 1024) in skill-creator - 🔧 Sharpen optimus-prime skill scoping and placement guidance
-
v1.2.6
GitHub ↗
Original release notes
## 1.2.6 - 🐛 Ignore pycache in self-improve hook
-
v1.2.5
GitHub ↗
Original release notes
## 1.2.5 - 🔧 Remove allow-claude-dir hooks as claude-code already fixed it - 🔧 Add .tasks/ to gitignore entries
Only the five most recent versions are shown. View full version history at the source ↗
Current listing version
0.0.1
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 FastAPI 后端开发的详细架构决策与规范
- 涵盖认证授权、依赖注入、ORM 关系加载等关键场景
- 针对常见陷阱给出明确解决方案
Highlights
- 触发词精准限定于 Python 后端工作,排除前端与基础设施
- 覆盖 FastAPI、SQLModel、Pydantic、Alembic 等核心技术栈
Highlights
- 文档结构清晰,含架构决策、陷阱提示与参考链接
- frontmatter 完整,章节划分合理
Highlights
- 工具来源明确,依赖注入链与错误处理描述准确
- 提及的异步 SQLAlchemy 与会话管理规范可靠
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Not specified in the source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.