Agent Skillsjustrach/turboAPI › turbo-route

turbo-route

GitHub

用于快速生成 TurboAPI 路由骨架,包含处理函数、数据模型及对应测试文件。支持按资源名和方法自动创建 CRUD 接口,并分类 Zig 分发路径,提升后端 API 开发效率。

.claude/skills/turbo-route/SKILL.md justrach/turboAPI

触发场景

添加新的 API 端点 创建新路由 为资源生成 CRUD 代码

安装

npx skills add justrach/turboAPI --skill turbo-route -g -y
更多选项

非标准路径

npx skills add https://github.com/justrach/turboAPI/tree/main/.claude/skills/turbo-route -g -y

不安装直接使用

npx skills use justrach/turboAPI@turbo-route

指定 Agent (Claude Code)

npx skills add justrach/turboAPI --skill turbo-route -a claude-code -g -y

安装 repo 全部 skill

npx skills add justrach/turboAPI --all -g -y

预览 repo 内 skill

npx skills add justrach/turboAPI --list

SKILL.md

Frontmatter
{
    "name": "turbo-route",
    "description": "Scaffold a new TurboAPI route with handler, model, and tests. Use when adding a new API endpoint, creating a new route, or scaffolding CRUD for a resource.",
    "argument-hint": "<resource-name> [GET|POST|PUT|DELETE]"
}

Scaffold a TurboAPI Route

Create a new route for the TurboAPI application based on the resource name and HTTP method.

Steps

  1. Determine the resource: Use $ARGUMENTS[0] as the resource name (e.g., users, items, orders)
  2. Determine the method: Use $ARGUMENTS[1] if provided, otherwise scaffold all CRUD methods (GET, POST, PUT, DELETE)
  3. Check existing routes: Read python/turboapi/zig_integration.py to understand the current route registration pattern
  4. Create the model: If it's a POST/PUT route, create a dhi BaseModel for the request body

Template

For each route, generate code following this pattern:

from turboapi import TurboAPI
from dhi import BaseModel, Field

app = TurboAPI()

class {Resource}(BaseModel):
    # fields based on resource name
    name: str = Field(min_length=1, max_length=100)

@app.get("/{resource_plural}")
def list_{resource_plural}():
    return {"{resource_plural}": []}

@app.get("/{resource_plural}/{{{resource}_id}}")
def get_{resource}({resource}_id: int):
    return {"{resource}_id": {resource}_id}

@app.post("/{resource_plural}")
def create_{resource}({resource}: {Resource}):
    return {"{resource}": {resource}.model_dump(), "created": True}

@app.delete("/{resource_plural}/{{{resource}_id}}")
def delete_{resource}({resource}_id: int):
    return {"deleted": True}

Also generate a test file

Create tests/test_{resource_plural}.py with TestClient-based tests for each endpoint. Include both success and error cases.

Handler classification

When creating routes, note which Zig dispatch path they'll use:

  • No params, sync → simple_sync_noargs (fastest, cached)
  • Path/query params, sync → simple_sync (vectorcall)
  • Body with dhi model → model_sync (Zig-native validation)
  • Depends() or middleware → enhanced (full Python)

版本历史

  • 0ef167c 当前 2026-07-25 10:01

同 Skill 集合

.claude/skills/turbo-benchmark/SKILL.md
.claude/skills/turbo-build/SKILL.md
.claude/skills/turbo-db-route/SKILL.md
.claude/skills/turbo-test/SKILL.md
.claude/skills/turbopg/SKILL.md

元信息

文件数
0
版本
1c75a09
Hash
2cd1f3de
收录时间
2026-07-25 10:01

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-02 00:50
浙ICP备14020137号-1 $访客地图$