REA
Reverse engineer anything from your terminal or agent with one CLI and MCP server.
FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities.
如果你是作者,可把这段代码贴到 README。徽章会链接回本页。
[](https://mcp.popnx.com/en/skills/benavlabs-fastcrud)在同一工作中把 AI 连到服务的 MCP
Reverse engineer anything from your terminal or agent with one CLI and MCP server.
Codebase intelligence for TypeScript and JavaScript, exposed as structured MCP analysis tools.
MCP server for terminal commands, file operations, and process management
同类工作,排序与 Skill 列表相同
| 本项 fastcrud | rea | andrej-karpathy-skills | graphify | MoneyPrinterTurbo | |
|---|---|---|---|---|---|
| 作者 | benavlabs | morluto | multica-ai | Graphify-Labs | harry0703 |
| Skill 数 | 1 | 1 | 1 | 1 | 1 |
| GitHub 星标 | 1,602 | 467,235 | 234,125 | 149,873 | 144,332 |
| 最近代码更新 | 2026年10月12日 | 2026年11月18日 | 2026年4月20日 | 2026年11月18日 | 2026年11月18日 |
| 许可证 | MIT | MIT | – | Apache-2.0 | MIT |
benavlabs 提供的 1 个 Skill(指令集),AI 读取后照做 · 不是 MCP server
MCP = 手
把 AI 连到外部服务或数据,例如读取 Notion 或开发票。需要有程序或服务器在运行。
Skill = 手册
教 AI 怎么做某项工作的文本文件,不连接任何服务。
有些会重叠:少数 Skill 带有调用工具的脚本,少数 MCP 只提供知识。请从你想完成的工作出发。
Claude CodeCodexCursorGitHub CopilotOpenCode
依据开发者 README 和 repo 中的文件夹
GitHub account benavlabs (organization), 1 years old
★ 1,602 stars · code last changed 2026年10月12日
No, plain text files the AI reads and follows
No scripts, so it does not go online by itself
No hooks or writes to machine settings found
Checked automatically from the repo files at commit 27f2cba (read only, nothing was run). Not a safety guarantee: read it and decide for yourself
第一步:你用哪个 AI?
选择你用的应用,本页只显示该应用的安装方法
Uploading to claude.ai would fail: the description is over 200 characters (622). Use "Let the AI install it" instead
复制这句话,粘贴到 Claude Code 的对话中
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
重新打开 Claude Code,输入 /fastcrud,或直接提出相关任务,Claude 会自动选用
Checked against official docs 2026年11月12日 · Source: code.claude.com
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
git clone --depth 1 https://github.com/benavlabs/fastcrud.git /tmp/popnx-skill-benavlabs-fastcrud-27f2cba && mkdir -p ~/.claude/skills && cp -R '/tmp/popnx-skill-benavlabs-fastcrud-27f2cba/fastcrud/.agents/skills/fastcrud' ~/.claude/skills/fastcrudChatGPT 桌面应用内置 Codex,Codex 从 ~/.agents/skills 文件夹读取 Skill
在 ChatGPT 桌面应用中打开 Codex,把这句话粘贴到对话中
The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
把 fastcrud 文件夹放到 ~/.agents/skills/fastcrud
~ 是你的主文件夹($HOME)
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
git clone --depth 1 https://github.com/benavlabs/fastcrud.git /tmp/popnx-skill-benavlabs-fastcrud-27f2cba && mkdir -p ~/.agents/skills && cp -R '/tmp/popnx-skill-benavlabs-fastcrud-27f2cba/fastcrud/.agents/skills/fastcrud' ~/.agents/skills/fastcrudChecked against official docs 2026年11月15日 · Source: learn.chatgpt.com
不能使用你自己安装的 Skill,只能使用目录中插件自带的 Skill
想在 ChatGPT 中使用这个 Skill,请按上面的方法使用 ChatGPT 桌面应用
Checked against official docs 2026年11月15日 · Source: learn.chatgpt.com
复制这句话,粘贴到 Codex 的对话中 · 适用于 ChatGPT 桌面应用中的 Codex、Codex CLI 和 IDE 扩展
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
Codex 会自动发现新安装的 Skill;如果没有出现,请重启 Codex · 使用方法:在 ChatGPT 中输入 @ 并选择 Skill · 在 Codex CLI 或 IDE 扩展中运行 /skills,或输入 $ 加 Skill 名称
Checked against official docs 2026年11月15日 · Source: learn.chatgpt.com
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
git clone --depth 1 https://github.com/benavlabs/fastcrud.git /tmp/popnx-skill-benavlabs-fastcrud-27f2cba && mkdir -p ~/.agents/skills && cp -R '/tmp/popnx-skill-benavlabs-fastcrud-27f2cba/fastcrud/.agents/skills/fastcrud' ~/.agents/skills/fastcrud复制这句话,粘贴到 Cursor 的对话中
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
在 Cursor 的 Agent 聊天中输入 / 并选择 fastcrud
Checked against official docs 2026年11月12日 · Source: cursor.com
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
git clone --depth 1 https://github.com/benavlabs/fastcrud.git /tmp/popnx-skill-benavlabs-fastcrud-27f2cba && mkdir -p ~/.cursor/skills && cp -R '/tmp/popnx-skill-benavlabs-fastcrud-27f2cba/fastcrud/.agents/skills/fastcrud' ~/.cursor/skills/fastcrud适用于其他能读取 Skill 的应用。这句话列出了 Claude Code、Codex 和 Cursor 的路径,AI 会按你的应用选择 · Copy this sentence into the app’s chat
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
Checked against official docs 2026年11月12日 · Source: code.claude.com, learn.chatgpt.com, cursor.com
其他支持 Agent Skills 的应用(如 Gemini CLI、GitHub Copilot)使用不同文件夹,请查看该应用的指南,再把含 SKILL.md 的文件夹复制过去。
已于 2026年11月11日 对照 Claude Code、Codex 和 Cursor 官方指南核实 skill 文件夹
✓ 命令已检查 2026年11月18日
以下文字来自开发者的 repo,不是 PopNx MCP 的指令
显示前 8,000 个字符 · 在 GitHub 打开完整文件
---
name: fastcrud
description: Use when building or modifying CRUD endpoints with FastCRUD (the `fastcrud` PyPI package) in a FastAPI project — covers `FastCRUD`, `crud_router`, `EndpointCreator`, `FilterConfig`, `JoinConfig`, auto-relationship detection, the filter operator syntax (`__gte`, `__in`, `__ilike`, etc.), cursor pagination, soft delete, and how to avoid N+1 queries when fetching related data. Activate when the user mentions FastCRUD, `crud_router`, `FastCRUD()`, `FilterConfig`, `JoinConfig`, or asks how to build CRUD endpoints / generate REST APIs from SQLAlchemy or SQLModel models, even if the user doesn't name the library directly.
license: MIT
metadata:
author: benav-labs
package: fastcrud
---
# FastCRUD
FastCRUD generates async CRUD methods (and optionally CRUD endpoints) for SQLAlchemy 2.0 models inside a FastAPI app. The two entry points are:
- **`FastCRUD(Model)`** — the data-access class. Use this for per-row CRUD operations (single-record get / create / update / delete, paginated lists, joins with relationships). Real codebases use this in services, workers, and custom endpoints.
- **`crud_router(...)`** — returns an `APIRouter` with create/read/update/delete endpoints auto-wired. Use this only when you want generated endpoints; many apps skip it and hand-roll FastAPI routes on top of `FastCRUD` instances.
This skill covers the public API across `fastcrud >= 0.22`; features marked (v0.23+) need `fastcrud >= 0.23`. SQLAlchemy is the default ORM in examples; SQLModel works the same way except where noted.
**Before reaching for FastCRUD, check the [When NOT to use FastCRUD](#when-not-to-use-fastcrud) section below.** Aggregate roll-ups, CTEs, `GROUP BY` projections, and bulk writes are SQLAlchemy's job — FastCRUD is for per-row CRUD.
---
## Canonical setup
The minimal viable pattern. Always start here, then add filters/joins/relationships as needed.
```python
# models.py
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import DeclarativeBase, relationship
class Base(DeclarativeBase): pass
class Tier(Base):
__tablename__ = "tier"
id = Column(Integer, primary_key=True)
name = Column(String, unique=True)
class User(Base):
__tablename__ = "user"
id = Column(Integer, primary_key=True)
name = Column(String)
email = Column(String, unique=True)
tier_id = Column(Integer, ForeignKey("tier.id"))
tier = relationship("Tier")
```
```python
# schemas.py
from pydantic import BaseModel, ConfigDict
class UserCreate(BaseModel):
name: str
email: str
tier_id: int
class UserRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
name: str
email: str
tier_id: int
class UserUpdate(BaseModel):
name: str | None = None
email: str | None = None
```
```python
# main.py
from fastapi import FastAPI
from fastcrud import crud_router
from .db import get_async_session
from .models import User
from .schemas import UserCreate, UserRead, UserUpdate
app = FastAPI()
user_router = crud_router(
session=get_async_session, # callable returning AsyncSession (FastAPI dependency)
model=User,
create_schema=UserCreate,
update_schema=UserUpdate,
select_schema=UserRead, # used for read responses
path="/users",
tags=["users"],
)
app.include_router(user_router)
```
This produces `POST /users`, `GET /users/{id}`, `PATCH /users/{id}`, `DELETE /users/{id}`, `DELETE /users/db_delete/{id}` (hard delete), and `GET /users` (paginated list).
---
## Choosing the right method
When using `FastCRUD(Model)` directly, pick the method that matches the data shape you actually need. **Do not loop over `get_multi()` and call `get_joined()` per row** — that's the canonical N+1.
| Need | Use |
|---------------------------------------------|------------------------------|
| Single row, no joins | `get(db, id=...)` |
| Single row with related data | `get_joined(db, id=...)` |
| Paginated list, no joins | `get_multi(db, offset, limit)` |
| **Paginated list with related data** | **`get_multi_joined(db, ...)`** |
| Cursor-paginated list (infinite scroll) | `get_multi_by_cursor(db, ...)` |
| Insert | `create(db, schema)` |
| Insert-or-update by unique constraint | `upsert(db, schema)` / `upsert_multi(db, list)` |
| Patch by filters | `update(db, schema, **kwargs)` |
| Soft delete (if configured) | `delete(db, **kwargs)` |
| Hard delete (always removes row) | `db_delete(db, **kwargs)` |
| Count | `count(db, **kwargs)` |
| Boolean existence check | `exists(db, **kwargs)` |
---
## Avoiding N+1 — the most common mistake
FastCRUD has two mechanisms to prevent N+1 when fetching related data. **Use one of them — never iterate.**
### 1. Auto-detect relationships (zero config, default for v0.21+)
Set `include_relationships=True` on `crud_router` (or `auto_detect_relationships=True` on the FastCRUD method directly). FastCRUD inspects the SQLAlchemy mapper, builds the joins, and threads them through a single query.
```python
crud_router(
session=get_async_session,
model=User,
create_schema=UserCreate,
update_schema=UserUpdate,
select_schema=UserWithTier, # schema includes nested tier field
include_relationships=True, # auto-include all relationships
path="/users",
)
```
Or pass a list to include only specific relationships:
```python
include_relationships=["tier", "department"] # whitelist
```
**Gotcha:** **One-to-many relationships are excluded by default** because they can return unbounded data. Opt in explicitly:
```python
include_relationships=True,
include_one_to_many=True,
default_nested_limit=10, # cap nested rows per parent (uses SQL window function)
```
`default_nested_limit` uses `row_number() OVER (PARTITION BY ...)` at the database level — it does **not** fetch everything and slice in Python.
### 2. Manual `JoinConfig` (when you need explicit control)
For self-joins, aliases, custom join conditions, or per-join schemas:
```python
from fastcrud import FastCRUD, JoinConfig
orders_with_user = await crud.get_multi_joined(
db=session,
joins_config=[
JoinConfig(
model=User,
join_on=Order.user_id == User.id,
join_prefix="user_", # avoid column collisions
schema_to_select=UserRead,
),
],
offset=0,
limit=20,
)
```
For one-to-many with per-parent capping:
```python
JoinConfig(
model=Article,
join_on=Article.author_id == Author.id,
relationship_type="one-to-many",
sort_columns="created_at",
sort_orders="desc",
nested_limit=5, # 5 most recent articles per author, computed in SQL
)
```
See `references/joins.md` for the full `JoinConfig` spec, polymorphic inheritance, and the auto-detection rules.
---
## `limit=None` — the second biggest footgun
`get_multi(...)` / `get_multi_joined(...)` accept `limit=None` to fetch **every matching row**. This is the single biggest cause of latency cliffs and OOMs in real-world FastCRUD code.
**Rule:** `limit=None` is only safe when a `WHERE` clause domain-bounds the result to a known-small set. Otherwise, always pass an explicit numeric `limit`.
### Safe — scoped by a WHERE clause
```python
# OK: scoped to a single project → bounded by N(clips per project)
clips = await crud_clips.get_multi(db, limit=None, project_id=project.id)
# OK: scoped to a small known set of IDs
tiers = await crud_tiers.get_multi(db, limit=None, id__in=tier_ids)
```
### Unsafe — unbounded growth
```python
# BAD: grows linearly with the user table forever
users = await crud_users.get_multi(db, limit=No提问、分享技巧或报告无法使用。按“有帮助”数量排序。