api-builder
Generate complete FastAPI backend scaffolds from OpenAPI 3.x specifications. Automatically creates SQLAlchemy models, Pydantic schemas, FastAPI routers, CRUD operations, database migrations, pytest tests, and Next.js TypeScript clients. Use when user provides an OpenAPI/OpenSpec file (.yaml/.json) or pastes spec content, and wants to generate API code. Triggers on phrases like "generate API from spec", "build backend from OpenAPI", "create FastAPI from this spec", "implement these endpoints", or when user shares OpenAPI specification files. Supports Python 3.12+, FastAPI, SQLite, SQLAlchemy, A
npx skills add majiayu000/claude-skill-registry --skill api-builder --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# API Builder 从 OpenAPI 3.x 规范自动生成完整的 FastAPI 后端脚手架,包括数据库模型、API 路由、测试和 Next.js client。 ## 工作流程 ### 阶段 1:验证输入 1. **获取 OpenAPI Spec** - 询问用户提供 OpenAPI spec: - 文件路径(.yaml 或 .json) - 粘贴 spec 内容(保存为临时文件) - URL(如果可访问,先下载) 2. **验证 Spec 格式** - 运行 `scripts/validate_spec.py`: ```bash python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate_spec.py <spec-file> ``` - 检查 exit code:0=成功,1=失败 **如果验证失败**:停止并告知用户具体错误,询问是否修正 3. **选择生成范围** - 运行 `scripts/parse_openapi.py` 查看可用 endpoints: ```bash python3 ${CLAUDE_PLUGIN_ROOT}/scripts/parse_openapi.py <spec-file> ``` - 询问用户: - 生成全部 endpoints? - 只生成特定的endpoints?(让用户选择,使用 `--resources` 参数) ### 阶段 2:检测现有项目结构 1. **检查是否为现有项目** - 查找 `app/` 或 `src/` 目录 - 检查 `pyproject.toml` - 检查是否已有 `database.py`、`routers/`、`models/` 等 2. **确定集成策略** - **如果是现有项目**: - 复用现有的 `database.py` - 检查文件冲突(如 `app/routers/users.py` 已存在) - 询问用户如何处理冲突:覆盖/合并/重命名/跳过 - **如果是新项目**: - 从 `assets/fastapi-template/` 复制基础结构 - 创建完整的项目脚手架 ### 阶段 3:生成后端代码 **使用 CLI 脚本(推荐)**: 运行完整的生成流程: ```bash cd ${CLAUDE_PLUGIN_ROOT}/scripts python3 cli.py \ --spec <spec-file> \ --output <output-dir> \ [--resources users,posts] # 可选:只生成特定资源 [--conflict-strategy skip|backup|overwrite] # 默认: skip [--dry-run] # 预览模式,不写入文件 ``` **冲突处理
- 工作流程
- 阶段 1:验证输入
- 阶段 2:检测现有项目结构
- 阶段 3:生成后端代码
- 阶段 4:生成测试
- 阶段 5:生成 Next.js Client(可选)
- 阶段 6:验证和测试
- 阶段 7:完成
- 类型映射
- 项目结构
- 最佳实践
- 测试模式
- 错误处理
- 无效的 OpenAPI Spec
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate_spec.py <spec-file>
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/parse_openapi.py <spec-file>
cd ${CLAUDE_PLUGIN_ROOT}/scripts
python3 cli.py \
python3 parse_openapi.py <spec-file> --output parsed.json
python3 generate_code.py \
python3 cli.py --spec <spec-file> --output <output-dir> --setup-alembic
cd <output-dir>
alembic revision --autogenerate -m "Initial tables"
alembic upgrade headWhat does the api-builder skill do?
Generate complete FastAPI backend scaffolds from OpenAPI 3.x specifications. Automatically creates SQLAlchemy models, Pydantic schemas, FastAPI routers, CRUD operations, database migrations, pytest tests, and Next.js TypeScript clients. Use when user provides an OpenAPI/OpenSpec file (.yaml/.json) or pastes spec content, and wants to generate API code. Triggers on phrases like "generate API from spec", "build backend from OpenAPI", "create FastAPI from this spec", "implement these endpoints", or when user shares OpenAPI specification files. Supports Python 3.12+, FastAPI, SQLite, SQLAlchemy, A
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill api-builder --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
