agent coding skill risk: low
FastAPI Router Template Generator
Instructs the model to create FastAPI routers by copying a template from assets/template.py, replacing placeholders for resource names, and applying patterns for authentication, re…
SKILL 1 file
SKILL.md
---
name: fastapi-router-py
description: "Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes."
---
# FastAPI Router
Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.
## Quick Start
Copy the template from assets/template.py and replace placeholders:
- `{{ResourceName}}` → PascalCase name (e.g., `Project`)
- `{{resource_name}}` → snake_case name (e.g., `project`)
- `{{resource_plural}}` → plural form (e.g., `projects`)
## Authentication Patterns
```python
# Optional auth - returns None if not authenticated
current_user: Optional[User] = Depends(get_current_user)
# Required auth - raises 401 if not authenticated
current_user: User = Depends(get_current_user_required)
```
## Response Models
```python
@router.get("/items/{item_id}", response_model=Item)
async def get_item(item_id: str) -> Item:
...
@router.get("/items", response_model=list[Item])
async def list_items() -> list[Item]:
...
```
## HTTP Status Codes
```python
@router.post("/items", status_code=status.HTTP_201_CREATED)
@router.delete("/items/{id}", status_code=status.HTTP_204_NO_CONTENT)
```
## Integration Steps
1. Create router in `src/backend/app/routers/`
2. Mount in `src/backend/app/main.py`
3. Create corresponding Pydantic models
4. Create service layer if needed
5. Add frontend API functions
## When to Use
This skill is applicable to execute the workflow or actions described in the overview.
## Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
INPUTS
- {{ResourceName}} REQUIRED
PascalCase resource name
e.g. Project
- {{resource_name}} REQUIRED
snake_case resource name
e.g. project
- {{resource_plural}} REQUIRED
plural form of resource
e.g. projects
REQUIRED CONTEXT
- resource names in PascalCase, snake_case and plural forms
ROLES & RULES
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
EXPECTED OUTPUT
- Format
- code
- Constraints
- follow provided authentication patterns
- use specified response_model and status_code conventions
- replace all placeholders with user-supplied names
EXAMPLES
Includes code snippets demonstrating authentication patterns, response models, HTTP status codes, and placeholder replacement instructions.
CAVEATS
- Dependencies
- Requires template from assets/template.py
- Missing context
- Actual content of assets/template.py
- Concrete success criteria or validation steps for generated routers
- Ambiguities
- "When to Use" section contains generic phrasing ('execute the workflow or actions described in the overview') that does not match the rest of the prompt.
- References 'assets/template.py' without specifying its location or contents.
QUALITY
- OVERALL
- 0.72
- CLARITY
- 0.70
- SPECIFICITY
- 0.75
- REUSABILITY
- 0.85
- COMPLETENESS
- 0.65
IMPROVEMENT SUGGESTIONS
- Replace the mismatched 'When to Use' and 'Limitations' paragraphs with task-specific usage guidance.
- Embed the template.py content directly or provide a self-contained example instead of an external file reference.
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR AGENT
- Rapid App MVP Prototyperagentcoding
- AI-First Design Handoff Specs Generatoragentcoding
- Test-Driven Development Workflow Rulesagentcoding
- Structured Autonomy Implementation Agentagentcoding
- PROGRESS.md Manager for Agentic Codingagentcoding
- Hard Bug Diagnosis Disciplineagentcoding
- Git Development Branch Finisheragentcoding
- Code Review Feedback Reception Protocolagentcoding
- Systematic Debugging Process Guideagentcoding
- Matplotlib Python Plotting Guideagentcoding
- LaTeX Paper PDF Compileragentcoding
- Full Output Enforcement for Code Generationagentcoding
- PyTorch Geometric GNN Implementation Guideagentcoding
- Premium React UI Design Architectagentcoding
- Astropy Python Astronomy Library Guideagentcoding
- Book SFT Style Transfer Pipelineagentcoding
- Event Sourcing and CQRS Architectagentcoding
- FluidSim Python CFD Simulation Guideagentcoding
- NetworkX Python Graph Analysis Toolkitagentcoding
- Phase-Gated Debugging Protocol Enforceragentcoding
- SimPy Discrete-Event Simulation Guideagentcoding
- Phase-Gated Code Debugging Protocolagentcoding
- Biopython Molecular Biology Toolkit Guideagentcoding
- Haskell Advanced Type Systems Expertagentcoding
- Anime.js Complex Animation Workflowagentcoding