Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add guyulong/cn-agent-skills --skill fastapi-best-practicesgit clone --depth 1 https://github.com/guyulong/cn-agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/guyulong/cn-agent-skills/fastapi-best-practices)<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/fastapi-best-practices"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/fastapi-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/fastapi-best-practices"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/fastapi-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00013 | $0.00783 |
| Opus 5 | $0.00006 | $0.00392 |
| Sonnet 5 | $0.00003 | $0.00157 |
| Haiku 4.5 | $0.00001 | $0.00078 |
Grade A, and why
fastapi-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.
FastAPI 中文最佳实践
项目结构
├── app/
│ ├── __init__.py
│ ├── main.py # 入口文件
│ ├── config.py # 配置
│ ├── database.py # 数据库连接
│ ├── models/ # 数据模型
│ │ ├── user.py
│ │ └── order.py
│ ├── schemas/ # Pydantic模型
│ │ ├── user.py
│ │ └── order.py
│ ├── api/ # API路由
│ │ ├── v1/
│ │ │ ├── user.py
│ │ │ └── order.py
│ │ └── deps.py # 依赖注入
│ ├── services/ # 业务逻辑
│ │ └── user.py
│ └── utils/ # 工具函数
│ └── security.py
├── tests/
├── alembic/ # 数据库迁移
├── requirements.txt
└── .env
路由模板
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from app.api.deps import get_db, get_current_user
from app.schemas.user import UserCreate, UserResponse
from app.services.user import UserService
router = APIRouter(prefix="/users", tags=["用户"])
@router.post("/", response_model=UserResponse, summary="创建用户")
async def create_user(
user_in: UserCreate,
db: Session = Depends(get_db)
):
"""
创建新用户
- **username**: 用户名,3-20个字符
- **password**: 密码,至少8位
- **phone**: 手机号,11位数字
"""
service = UserService(db)
user = await service.create(user_in)
return user
@router.get("/{user_id}", response_model=UserResponse, summary="获取用户信息")
async def get_user(
user_id: int,
db: Session = Depends(get_db),
current_user = Depends(get_current_user)
):
"""根据用户ID获取用户信息"""
service = UserService(db)
user = await service.get_by_id(user_id)
if not user:
raise HTTPException(status_code=404, detail="用户不存在")
return user
错误处理
from fastapi import HTTPException
from fastapi.responses import JSONResponse
class AppException(Exception):
def __init__(self, code: int, message: str):
self.code = code
self.message = message
@app.exception_handler(AppException)
async def app_exception_handler(request, exc):
return JSONResponse(
status_code=200,
content={"code": exc.code, "message": exc.message, "data": None}
)
# 使用
raise AppException(code=1001, message="用户名已存在")
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 9d ago First seen · 110 lines · 13 tokens per session scan A ee3be7e3f98d
fastapi-best-practices is a skill published in the GitHub repository guyulong/cn-agent-skills (3 stars, last pushed 3mo ago), licensed MIT. It adds 13 tokens to every session and 783 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
fastapi-expert
Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.
fastapi
Operational skill for FastAPI: Pydantic models, dependency injection, async routes, OpenAPI, authentication hooks, and TestClient-based testing.
python
Use when building FastAPI applications, implementing async endpoints, setting up Pydantic schemas, working with SQLAlchemy, or writing pytest tests for Python backend services.
fastapi-patterns
FastAPI production patterns — routing, dependency injection, background tasks, streaming, error handling, and async. Use when building or reviewing a FastAPI service.
FastAPI Patterns
Use this skill when building Python APIs with FastAPI and you want consistent boundary validation, async correctness, and maintainable dependency injection patterns.
fastapi-rest-api
Build a FastAPI REST API — routers, Pydantic models, dependency injection, error handling, and testing.