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.
git clone --depth 1 https://github.com/holtwood/awesome-cursorrules-zhWrote 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/rules/holtwood/awesome-cursorrules-zh/fastapi-file-structure)<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/fastapi-file-structure"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/fastapi-file-structure/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/rules/holtwood/awesome-cursorrules-zh/fastapi-file-structure"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/fastapi-file-structure.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.00004 | $0.01215 |
| Opus 5 | $0.00002 | $0.00607 |
| Sonnet 5 | $0.00001 | $0.00243 |
| Haiku 4.5 | $0.00000 | $0.00121 |
Grade A, and why
fastapi-file-structure 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 6d 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 — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.
FastAPI 文件结构
本规则集定义了在 FastAPI 应用程序中推荐的文件和目录结构,旨在提高代码的可组织性、可维护性和可扩展性。
1. 核心原则
- 模块化: 将应用程序的不同部分(如路由、模型、服务、依赖项)分离到独立的模块中。
- 清晰性: 文件和目录命名应清晰明了,反映其内容和功能。
- 可扩展性: 结构应支持未来功能的添加和团队协作。
2. 推荐的目录结构
以下是一个推荐的 FastAPI 项目结构示例:
my_fastapi_project/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI 应用入口点
│ ├── api/ # API 路由和端点
│ │ ├── __init__.py
│ │ ├── v1/ # API 版本控制 (可选)
│ │ │ ├── __init__.py
│ │ │ ├── endpoints/ # 具体端点实现
│ │ │ │ ├── __init__.py
│ │ │ │ ├── users.py
│ │ │ │ └── items.py
│ │ │ └── deps.py # 版本特定的依赖项
│ │ └── router.py # 聚合所有 API 路由
│ ├── core/ # 核心配置、设置、常量
│ │ ├── __init__.py
│ │ ├── config.py
│ │ └── security.py
│ ├── crud/ # 创建、读取、更新、删除操作 (与数据库交互)
│ │ ├── __init__.py
│ │ ├── user.py
│ │ └── item.py
│ ├── db/ # 数据库相关配置和会话管理
│ │ ├── __init__.py
│ │ ├── base.py # 基础模型或 ORM 声明
│ │ └── session.py # 数据库会话管理
│ ├── models/ # Pydantic 模型和 SQLAlchemy 模型
│ │ ├── __init__.py
│ │ ├── user.py
│ │ └── item.py
│ ├── schemas/ # Pydantic schema (请求/响应模型)
│ │ ├── __init__.py
│ │ ├── user.py
│ │ └── item.py
│ ├── services/ # 业务逻辑服务层
│ │ ├── __init__.py
│ │ ├── user.py
│ │ └── item.py
│ └── tests/ # 单元测试和集成测试
│ ├── __init__.py
│ ├── api/
│ │ └── test_users.py
│ └── crud/
│ └── test_user_crud.py
├── .env # 环境变量 (敏感信息)
├── .gitignore
├── Dockerfile # Docker 容器化配置
├── README.md
├── requirements.txt # Python 依赖包列表
└── uvicorn_run.sh # 启动脚本 (可选)
3. 目录说明
app/main.py: FastAPI 应用的入口文件,通常在这里实例化FastAPI()并包含顶层路由。app/api/: 包含所有 API 路由定义。可以进一步按版本 (v1/,v2/) 或功能模块 (users/,items/) 组织。app/core/: 存放应用程序的核心配置、安全设置、日志配置等。app/crud/: 包含与数据库进行 CRUD 操作的函数。这些函数通常接收 Pydantic 模型作为输入,并返回数据库模型。app/db/: 数据库连接、会话管理和 ORM 基础声明。app/models/: 定义数据库模型(如 SQLAlchemy ORM 模型)。app/schemas/: 定义 Pydantic 模型,用于请求体验证、响应序列化和数据验证。app/services/: 包含业务逻辑。crud层处理数据库交互,而services层则协调crud操作,实现更复杂的业务规则。app/tests/: 存放所有测试文件,结构应与app/目录相对应。requirements.txt: 列出项目所需的所有 Python 依赖。Dockerfile: 用于构建 Docker 镜像的配置文件。
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.
- 6d ago First seen · 101 lines · 4 tokens per session scan A cebacb4c0eae
fastapi-file-structure is a cursor rule published in the GitHub repository holtwood/awesome-cursorrules-zh (233 stars, last pushed 1mo ago), licensed MIT. It adds 4 tokens to every session and 1,215 once invoked, about $0.0000 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-09-03.
Other cursor rules, from other repositories
java-springboot-jpa-cursorrules-prompt-file
Cursor rules for Java development with Springboot and JPA integration.
nodejs-mongodb-cursorrules-prompt-file-tutorial
Cursor rules for Node.js development with MongoDB integration.
skill-layered-design
Layered Design — enforce arquitetura estrita Handler→Service→Repository→Model em todos os projetos DARE, independente de linguagem. Inspirado em "Layered Design for Ruby on Rails Applications" de Vladimir Dementyev (Evil Martians).
architecture
FastAPI layer architecture rules — Router → Service → Repository with Protocol injection.
prisma
Prisma: schema modeling, queries, migrations.
supabase
Supabase: RLS, edge functions, realtime.