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.
git clone --depth 1 https://github.com/bernierllc/agents-environment-configWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/bernierllc/agents-environment-config/fastapi)<a href="https://agentmods.dev/rules/bernierllc/agents-environment-config/fastapi"><img src="https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/fastapi/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/bernierllc/agents-environment-config/fastapi"><img src="https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/fastapi.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.00763 |
| Opus 5.5 | $0.00000 | $0.00305 |
| Sonnet 5.5 | $0.00000 | $0.00153 |
| Haiku 4.5 | $0.00000 | $0.00076 |
Grade A, and why
fastapi 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 1mo 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.
How it starts
The opening of the file, as written. The whole thing — 129 lines — stays where its author put it; the contents beside it link to each section on GitHub.
FastAPI Patterns
File Organization
Directory Structure
routers/- API route handlersschemas/- Pydantic models for request/response validationrepositories/- Data access layer
project/
├── routers/
│ ├── users.py
│ └── items.py
├── schemas/
│ ├── user.py
│ └── item.py
└── repositories/
├── user_repository.py
└── item_repository.py
Pydantic Models
Pydantic v2 Standards
- Use Pydantic v2 BaseModel with
model_config - Define schemas for all request/response models
- Use proper field types and validators
from pydantic import BaseModel, Field
class UserCreate(BaseModel):
email: str = Field(..., description="User email address")
name: str = Field(..., min_length=1, max_length=100)
model_config = {
"json_schema_extra": {
"example": {
"email": "[email protected]",
"name": "John Doe"
}
}
}
Route Handlers
Response Models
- All routes return
response_model- Define explicit response types - Use proper HTTP status codes
- Handle errors consistently
from fastapi import APIRouter, HTTPException, status
from typing import List
router = APIRouter(prefix="/api/users", tags=["users"])
@router.post(
"/",
response_model=UserResponse,
status_code=status.HTTP_201_CREATED
)
async def create_user(user_data: UserCreate) -> UserResponse:
# Implementation
Background Tasks
Long-Running Operations
- Use background tasks for long jobs
- Use FastAPI's BackgroundTasks for non-critical operations
- Use task queues (Celery, etc.) for critical background work
from fastapi import BackgroundTasks
@router.post("/process")
async def process_data(
data: ProcessingRequest,
background_tasks: BackgroundTasks
):
background_tasks.add_task(long_running_operation, data)
return {"status": "processing", "message": "Task queued"}
Security
CSRF Protection
- Don't disable CSRF on JWT cookie endpoints - Maintain security
- Use proper authentication mechanisms
- Validate all inputs
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.
- 1mo ago First seen · 129 lines · 0 tokens per session scan A c68b999819da
fastapi is a cursor rule published in the GitHub repository bernierllc/agents-environment-config (11 stars, last pushed 9d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 763 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.
Other cursor rules, from other repositories
python-conventions
Python coding style, FastAPI endpoint template, code organisation sections.
best-practices
FastAPI Best Practices - enforces current best practices when working with FastAPI code.
backend-python
Python and FastAPI standards for the backend.
api-design-and-implementation
API Design and Implementation Rules for FastAPI Endpoints.
python
You are an expert in Python, FastAPI, and scalable API development.
python--typescript-guide-cursorrules-prompt-file
Cursor rules for Python development with TypeScript guide integration.