模板详情

Python FastAPI 服务规则

面向后端团队,帮助 AI agent 生成更小的端点、安全迁移和明确契约。

Claude CodeCursorCodexCLAUDE.mdAGENTS.md.cursor/rules
512投票
8,310安装量
已验证状态

安装预览

命令仍是 MVP 预览。真实使用前请检查目标文件和覆盖行为。

npx rulesmarket add python-fastapi-service
返回模板库
CLAUDE.md or AGENTS.md
# FastAPI Service Rules

- Keep API schemas explicit with Pydantic models and clear response contracts.
- Separate route handlers, domain services and persistence code.
- Prefer dependency injection for database sessions and authenticated user context.
- Do not silently swallow exceptions; map expected errors to typed HTTP responses.
- Use async only when the downstream library is async-safe.
- Add tests for validation, authorization and failure paths before broad refactors.
- Never log credentials, bearer tokens, cookies or personally identifiable data.

可以用它生成数据库迁移吗?

它可以指导迁移工作,但迁移命令仍然需要人工审查并有意识地执行。

它是框架专用的吗?

是的。它默认使用 FastAPI、Pydantic 和服务层风格。