project-api-patterns
Use when adding or changing Django REST Framework serializers, viewsets, nested routes, schema docs, or project-scoped endpoints in core/api.py, core/api_urls.py, or core/serializers.py. Trigger phras
SKILL.mdpackages/canonical-repo-assets/templates/agents/_skills/project-api-patterns/SKILL.md
GitHubProject API Patterns Skill
Use this skill when changing the project-scoped REST API.
Rules
- Treat
Projectas the isolation boundary. - Top-level project resources live on the base router; most other resources are nested under
/api/v1/projects/{project_id}/.... - Reuse
ProjectOwnedQuerysetMixinincore/api.pyfor nested resources. - Pass
projectthrough serializer context and enforce cross-project relationship validation in serializers. - Keep API field names in
snake_caseto match current serializers and frontend types. - Update drf-spectacular metadata in
core/api.pywhen the endpoint contract changes.
Implementation Guidance
- Add or update serializers in
core/serializers.py. - Add or update viewsets and schema decorators in
core/api.py. - Register routes in
core/api_urls.pyusing the existing nested router pattern. - If the frontend consumes the API, update
frontend/src/lib/types.tsandfrontend/src/lib/api.ts. - Add or update focused tests near the changed behavior, usually under
core/tests/.
References
core/api.pycore/api_urls.pycore/serializers.pyfrontend/src/lib/types.tsfrontend/src/lib/api.ts