/feature - API Feature Workflow
Build FastAPI features using test-driven development.
Usage
code
/feature <brief description of what you want to build>
Workflow
Step 1: Understand the Feature
Ask the user:
- •What should this endpoint do? (one sentence)
- •HTTP method and path? (GET /items, POST /users, etc.)
- •Request body structure? (if POST/PUT/PATCH)
- •Response structure?
- •Any database changes needed?
Step 2: Check for Existing Spec
Look for related spec in ../../specs/ (workspace specs folder).
If none exists, create one.
Step 3: Enter Plan Mode
Use EnterPlanMode to design the implementation:
markdown
# Feature: [Name]
## Summary
[One sentence description]
## API Endpoint
- Method: [GET/POST/PUT/DELETE]
- Path: [/path]
- Request Schema: { field: type }
- Response Schema: { field: type }
## Database Changes (if needed)
- New model: [ModelName]
- Fields: [list]
## Implementation Plan
1. [ ] Write failing tests
2. [ ] Create database model (if needed)
3. [ ] Create Pydantic schemas
4. [ ] Create router
5. [ ] Register router in main.py
6. [ ] Run tests
Step 4: TDD Red Phase
- •Create test file:
tests/test_<feature>.py - •Write tests for new endpoint
- •Run
uv run pytest- confirm FAILS (Red)
Step 5: TDD Green Phase
- •Create model in
app/models/(if needed) - •Create schemas in
app/schemas/ - •Create router in
app/routers/ - •Register router in
app/main.py - •Run
uv run pytest- should PASS (Green)
Step 6: Verify
bash
uv run pytest uv run fastapi dev # Test at /docs
Step 7: Commit
bash
git checkout -b feature/<name> git add . git commit -m "feat: <description>" git push -u origin feature/<name> gh pr create --title "feat: <description>" --body "Implements <feature>"