- 使用 Pydantic 模型进行请求和响应模式
- 为共享资源实现依赖注入
- 对非阻塞操作使用 async/await
- 使用路径操作装饰器(@app.get、@app.post 等)
- 使用 HTTPException 实现适当的错误处理
- 使用 FastAPI 内置的 OpenAPI 和 JSON Schema 支持
Fastapi Best Practices
为 'app' 目录中的应用程序代码强制执行 FastAPI 最佳实践,包括数据验证、依赖注入和异步操作。
Fastapi Best Practices by liaosw97 · 2c6e6af
npx skillmds@latest add liaosw97/fastapi-best-practices File contents
---name: fastapi-best-practicesdescription: 为 'app' 目录中的应用程序代码强制执行 FastAPI 最佳实践,包括数据验证、依赖注入和异步操作。---- 使用 Pydantic 模型进行请求和响应模式- 为共享资源实现依赖注入- 对非阻塞操作使用 async/await- 使用路径操作装饰器(@app.get、@app.post 等)- 使用 HTTPException 实现适当的错误处理- 使用 FastAPI 内置的 OpenAPI 和 JSON Schema 支持
liaosw97/awesome-rules-skills/tree/main/plugins/fastapi/skills/fastapi-best-practices commit 2c6e6af049
Frequently asked questions
Run npx skillmds@latest add liaosw97/fastapi-best-practices in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
为 'app' 目录中的应用程序代码强制执行 FastAPI 最佳实践,包括数据验证、依赖注入和异步操作。 It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
liaosw97 (@liaosw97) published this skill. Their other Agent Skills are listed on their SkillMD profile.