| name | add-resource |
| description | Scaffolds a complete CRUD resource — model, schema, service, endpoint, router registration, and tests. Load this skill when asked to add a new resource, entity, or endpoint group. |
| version | 1.0 |
Skill: add new CRUD resource
When this skill activates
- "add a new resource: orders"
- "scaffold CRUD for products"
- "create endpoints for payments"
- "add a [noun] model and API"
Steps the agent must follow in order
1. Create the SQLAlchemy model
File: app/models/<resource>.py
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.orm import DeclarativeBase
from datetime import datetime
class <Resource>(Base):
__tablename__ = "<resources>"
id = Column(Integer, primary_key=True, index=True)
created_at = Column(DateTime, default=datetime.utcnow)
2. Create Pydantic schemas
File: app/schemas/<resource>.py
from pydantic import BaseModel, ConfigDict
class <Resource>Base(BaseModel):
class <Resource>Create(<Resource>Base):
pass
class <Resource>Response(<Resource>Base):
model_config = ConfigDict(from_attributes=True)
id: int
created_at: datetime
3. Create service
File: app/services/<resource>.py
- Class
<Resource>Service receiving AsyncSession
- Methods:
get(id), list(skip, limit), create(data), update(id, data), delete(id)
4. Create endpoint router
File: app/api/v1/endpoints/<resource>.py
- GET
/ → list
- GET
/{id} → get or 404
- POST
/ → create, status 201
- PUT
/{id} → update or 404
- DELETE
/{id} → delete or 404, return 204
5. Register in router
app/api/v1/router.py — add:
from app.api.v1.endpoints import <resource>
api_router.include_router(<resource>.router, prefix="/<resources>", tags=["<resources>"])
6. Generate migration
alembic revision --autogenerate -m "add <resource> table"
alembic upgrade head
7. Write tests
File: tests/api/v1/test_<resource>.py
test_list_<resources>_empty → GET / returns []
test_create_<resource>_returns_201 → POST / with valid body
test_get_<resource>_not_found → GET /999 returns 404
test_create_<resource>_invalid_body → POST / with missing fields returns 422
Verification
After scaffolding, open http://localhost:8000/api/v1/docs in the Antigravity browser agent and confirm the new resource endpoints appear with correct schemas.