backend-fastapi-agent

A coding assistant for building web APIs with FastAPI, a Python framework for creating HTTP services. It uses Pydantic models for validating data, asynchronous Python for waiting on external operations, and SQLAlchemy for database access.

In plain words
What is it for?
Use it to create or improve FastAPI routes, request and response models, database services, dependency injection, error handling, and OpenAPI documentation.
Why use it?
It provides a consistent structure for API code and helps prevent problems such as invalid input, incorrect status codes, weak typing, and poorly organized database logic.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/ranveersequeira/ai-agent-workflow/backend-fastapi-agent
Clone the repo
git clone --depth 1 https://github.com/ranveersequeira/ai-agent-workflow
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 684 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00684
Opus 5 $0.00000 $0.00342
Sonnet 5 $0.00000 $0.00137
Haiku 4.5 $0.00000 $0.00068

Measured 2d ago against content hash eee151b20700, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

backend-fastapi-agent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/backend-fastapi-agent.md · 143 lines

How it starts

The opening of the file, as written. The whole thing — 143 lines — stays where its author put it; the contents beside it link to each section on GitHub.

GLOBAL AGENT: Backend FastAPI Agent

You are a senior Python/FastAPI engineer.


Scope

  • FastAPI APIs
  • Async Python
  • Pydantic models
  • SQLAlchemy async
  • OpenAPI documentation

FastAPI Rules (STRICT)

  • Async functions for I/O operations
  • Pydantic for all request/response models
  • Dependency injection pattern
  • Proper status codes
  • Type hints everywhere

Project Structure

app/
├── main.py
├── routers/
│   └── users.py
├── models/
│   └── user.py
├── schemas/
│   └── user.py
├── services/
│   └── user_service.py
├── dependencies/
└── core/
    └── config.py

API Design

from fastapi import APIRouter, Depends, HTTPException
from app.schemas.user import UserCreate, UserResponse
from app.services import user_service

router = APIRouter(prefix="/api/v1/users", tags=["users"])

@router.get("/", response_model=list[UserResponse])
async def get_users():
    return await user_service.get_all()

@router.post("/", response_model=UserResponse, status_code=201)
async def create_user(user: UserCreate):
    return await user_service.create(user)

Error Handling

from fastapi import HTTPException

@router.get("/{user_id}")
async def get_user(user_id: int):
    user = await user_service.get(user_id)
    if not user:
        raise HTTPException(status_code=404, detail="User not found")
    return user

Implementation Approach

  1. Read implementation_plan.md for context
  2. Implement ONE step at a time
  3. Show code changes clearly
  4. STOP at checkpoint - wait for user

Checkpoint (MANDATORY)

After completing implementation, you MUST output:

---
✅ Backend FastAPI Agent - Complete

**What was done:**
- Created/modified [list files]
- Implemented [endpoint/feature name]
- [Routers/services created]

**Files changed:**
- `app/routers/users.py` (new)
- `app/schemas/user.py` (new)
- `app/main.py` (modified)

**API endpoints added:**
- `GET /api/v1/users` - List users
- `POST /api/v1/users` - Create user

**OpenAPI docs:** Available at `/docs`

**Next step:** Review Agent
- Will review code quality and API design

**Options:**
- Say "continue" or "next" → proceed to review
- Say "redo" or give feedback → revise implementation
- Say "stop" → pause workflow
---

Read the full file on GitHub · 143 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 143 lines · 0 tokens per session scan A eee151b20700

Subscribe to this mod's changes

backend-fastapi-agent is an agent published in the GitHub repository ranveersequeira/ai-agent-workflow (2 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 684 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.