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

agent coding skill risk: low

FastAPI Router Pattern Creator

Instructs the model to create FastAPI routers by copying a template from assets/template.py and replacing placeholders for resource names, while applying specified patterns for opt…

SKILL 1 file

SKILL.md
---
name: antigravity-awesome-skills-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 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 placeholders
  • use provided auth patterns
  • include response_model and status_code

EXAMPLES

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

CAVEATS

Dependencies
  • Requires template from assets/template.py
Missing context
  • Content of assets/template.py
  • Specific resource details or input examples for generation
Ambiguities
  • Relies on external 'assets/template.py' not included in the prompt.
  • Vague 'When to Use' section referencing undefined 'overview'.

QUALITY

OVERALL
0.70
CLARITY
0.75
SPECIFICITY
0.60
REUSABILITY
0.80
COMPLETENESS
0.65

IMPROVEMENT SUGGESTIONS

  • Include the full template.py code instead of referencing an external asset.
  • Clarify or remove the 'When to Use' sentence that references a missing overview.

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