Skip to content

Commit c096c70

Browse files
committed
docs: mark /api/v1 frozen, direct all new routes to /api/v2
v1 is effectively deprecated — it still runs for existing clients but should not grow. Add a top-level API Version Policy and update the Adding New Features / API Development sections so new entities and routes land on the Huma-backed /api/v2 via the api-v2-routes skill.
1 parent 3ec3740 commit c096c70

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

AGENTS.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@ The project consists of:
1111
- `desktop/` – Electron wrapper application
1212
- `docs/` – Documentation website
1313

14+
## API Version Policy — new work goes to /api/v2
15+
16+
**`/api/v1` is effectively deprecated and frozen.** It still runs and is fully supported for existing clients, but it should not grow.
17+
18+
- **Every new route goes on `/api/v2`** (the Huma-backed API in `pkg/routes/api/v2/`). This includes new CRUDable entities, new custom/non-CRUD endpoints, and new actions on existing resources.
19+
- **Before adding any v2 route, invoke the `api-v2-routes` skill** — it covers both CRUD and non-CRUD shapes.
20+
- **Touch `/api/v1` only to:** fix a bug, or port an existing resource to v2. Do not add net-new functionality there.
21+
- Models in `pkg/models/` are shared by both APIs — a new entity still gets its model + `Can*` methods (invoke `crudable`); only the HTTP surface differs (v2, not v1).
22+
23+
If a task says "add an endpoint for X" without naming a version, it means v2.
24+
1425
## Skills
1526

1627
Before writing code in these areas, invoke the matching skill with the `Skill` tool. They are short checklists derived from recurring review feedback — loading them up front avoids rework.
1728

1829
- Adding or modifying a model in `pkg/models/` (new CRUD, new or changed `Can*` methods, anything touching permissions): invoke `crudable`.
1930
- Creating or editing any file under `pkg/migration/`: invoke `migration`.
20-
- Adding or changing a resource on the Huma-backed `/api/v2` API (new endpoints, porting a v1 resource, editing `pkg/routes/api/v2/`): invoke `api-v2-routes`.
31+
- Adding **any** new API route (new entity, custom action, or porting from v1) — all new routes go on the Huma-backed `/api/v2`, editing `pkg/routes/api/v2/`: invoke `api-v2-routes`. See the API Version Policy above.
2132

2233
## Plans and Worktrees
2334

@@ -173,11 +184,10 @@ Modern Vue 3 composition API application with TypeScript:
173184
### Adding New Features
174185

175186
**Backend Changes:**
176-
1. Create/modify models in `pkg/models/` with proper CRUD and Permissions interfaces as required
177-
2. Add database migration if needed: `mage dev:make-migration <StructName>`
187+
1. Create/modify models in `pkg/models/` with proper CRUD and Permissions interfaces as required (invoke the `crudable` skill)
188+
2. Add database migration if needed: `mage dev:make-migration <StructName>` (invoke the `migration` skill)
178189
3. Create/update services in `pkg/services/` for complex business logic
179-
4. Add API routes in `pkg/routes/api/v1/` following existing patterns
180-
5. Update Swagger annotations
190+
4. Add API routes on **`/api/v2`** in `pkg/routes/api/v2/` — invoke the `api-v2-routes` skill. Do **not** add new routes to `/api/v1`; it is frozen (see API Version Policy above)
181191

182192
**Frontend Changes:**
183193
1. Create TypeScript interfaces in `src/modelTypes/` matching backend models
@@ -193,10 +203,11 @@ Modern Vue 3 composition API application with TypeScript:
193203
4. Update TypeScript interfaces in frontend `src/modelTypes/`
194204

195205
### API Development
196-
- All API endpoints follow RESTful conventions under `/api/v1/`
197-
- Use generic web handlers in `pkg/web/handler/` for standard CRUD operations
198-
- Implement proper permissions checking using the Permissions interface
199-
- Add Swagger annotations for automatic documentation generation
206+
- **New endpoints go on `/api/v2`** (Huma-backed, `pkg/routes/api/v2/`). `/api/v1` is frozen — see the API Version Policy near the top. Invoke the `api-v2-routes` skill before writing v2 routes.
207+
- v2 verb conventions differ from v1: POST creates, PUT/PATCH update (v1 used PUT to create, POST to update).
208+
- Both versions reuse the generic `pkg/web/handler/` `Do*` functions for standard CRUD, which enforce permissions via the model's `Can*` methods.
209+
- Implement permission checks at the model level via the Permissions interface — never in the route handler (the exception: non-CRUD v2 actions must call `Can*` explicitly; the skill covers this).
210+
- v2 generates its OpenAPI spec from Go types automatically — no Swagger annotations. v1's swaggo annotations stay as-is but no new ones are needed.
200211

201212
### Testing
202213
- Backend: Feature tests alongside source files, web tests in `pkg/webtests/`

0 commit comments

Comments
 (0)