Skip to main content
NEW · APP STORE Now on iOS · macOS · iPad Android & Windows soon GET IT
Prompts FastAPI Router Pattern Creator

developer coding skill risk: low

FastAPI Router Pattern Creator

Instructs creation of FastAPI routers by copying a template and replacing placeholders for resource names, while incorporating specified authentication patterns, response models, a…

SKILL 1 file

SKILL.md
---
name: antigravity-awesome-skills-fastapi-router-py-b894cbad
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 name in PascalCase, snake_case, and plural forms

ROLES & RULES

  1. Use this skill only when the task clearly matches the scope described above.
  2. Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  3. Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

EXPECTED OUTPUT

Format
code
Constraints
  • follow template from assets/template.py
  • replace placeholders with provided resource names
  • include proper auth, response models, and status codes

EXAMPLES

Includes code examples for authentication patterns, response models, and HTTP status codes, plus a numbered integration list.

CAVEATS

Dependencies
  • Requires template from assets/template.py
Missing context
  • Full content of assets/template.py
  • Project-specific import paths and dependency names
  • Target Python / FastAPI version
Ambiguities
  • 'established patterns' is referenced but never defined or linked
  • 'When to Use' section is circular and adds no decision criteria

QUALITY

OVERALL
0.77
CLARITY
0.82
SPECIFICITY
0.78
REUSABILITY
0.88
COMPLETENESS
0.65

IMPROVEMENT SUGGESTIONS

  • Replace the generic 'When to Use' paragraph with concrete trigger conditions (e.g., 'Use when a new resource CRUD endpoint set is required').
  • Embed a minimal but complete template.py example instead of only describing placeholder replacement.
  • Add a short checklist of required inputs (resource name, auth type, response models) before generation begins.

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 DEVELOPER