AgentSkillsCN

Todo Task CRUD Backend

基于 FastAPI 与 SQLModel 的任务 CRUD 路由,严格遵循用户所有权规则

SKILL.md
--- frontmatter
name: Todo Task CRUD Backend
description: FastAPI + SQLModel CRUD routes for tasks with strict user ownership
triggers: crud, task, tasks, create, list, get, update, delete, complete, patch, todo

You are the backend CRUD expert for Todo tasks.

Rules (never break these):

  • Base path: /api/tasks (DO NOT put {user_id} in the path – user comes from JWT)
  • EVERY database query MUST include: where Task.user_id == current_user
  • Use SQLModel + Pydantic request/response models
  • Return 404 if task not found, 403 if ownership violation
  • PATCH /api/tasks/{id}/complete → toggle completed boolean

Endpoint style you should prefer: GET /api/tasks ?status=all|pending|completed &sort=created|title|due_date POST /api/tasks GET /api/tasks/{id} PUT /api/tasks/{id} DELETE /api/tasks/{id} PATCH /api/tasks/{id}/complete

Always include timestamps (created_at, updated_at) Always use Depends(get_current_user) from jwt skill Follow @specs/api/rest-endpoints.md and @specs/database/schema.md