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.
npx agentmods add rules/steph-dove/klaussy-agents/fastapigit clone --depth 1 https://github.com/steph-dove/klaussy-agentsWrote 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/steph-dove/klaussy-agents/fastapi)<a href="https://agentmods.dev/rules/steph-dove/klaussy-agents/fastapi"><img src="https://agentmods.dev/badge/rules/steph-dove/klaussy-agents/fastapi.svg" alt="Measured on agentmods" 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 | $0.00000 | $0.01175 |
| Opus 5 | $0.00000 | $0.00588 |
| Sonnet 5 | $0.00000 | $0.00235 |
| Haiku 4.5 | $0.00000 | $0.00118 |
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 5d 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 — 122 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Conventions
- URL-based API versioning: Use URL path versioning (e.g., /v1/, /api/v2/).
Example context from
fastapi/applications.py(lines 214-220):```python from fastapi import FastAPI app = FastAPI(openapi_url="/api/v1/openapi.json") ``` """ ), - Data class style: Pydantic for API + dataclasses for internal: Use Pydantic for API schemas (40) and dataclasses for internal DTOs (10). Good separation.
Example context from
fastapi/sse.py(lines 47-57):if v is not None and "\0" in v: raise ValueError("SSE 'id' must not contain null characters") return _check_single_line(v, "id") class ServerSentEvent(BaseModel): """Represents a single Server-Sent Event. When `yield`ed from a *path operation function* that uses `response_class=EventSourceResponse`, each `ServerSentEvent` is encoded into the [SSE wire format](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream) - Background jobs with FastAPI BackgroundTasks: Use FastAPI BackgroundTasks for background task processing.
Example context from
fastapi/background.py(lines 1-10):from collections.abc import Callable from typing import Annotated, Any from annotated_doc import Doc from starlette.background import BackgroundTasks as StarletteBackgroundTasks from typing_extensions import ParamSpec P = ParamSpec("P") - Data classes: Pydantic models: Use Pydantic models for structured data. 62/80 structured classes use this pattern.
Example context from
fastapi/sse.py(lines 47-57):if v is not None and "\0" in v: raise ValueError("SSE 'id' must not contain null characters") return _check_single_line(v, "id") class ServerSentEvent(BaseModel): """Represents a single Server-Sent Event. When `yield`ed from a *path operation function* that uses `response_class=EventSourceResponse`, each `ServerSentEvent` is encoded into the [SSE wire format](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream) - lowercase constant naming: Name constants using lowercase style.
Example context from
fastapi/params.py(lines 18-22):class ParamTypes(Enum): query = "query" header = "header" path = "path" - Enum usage: Enum: Use Python enums for categorical values. Found 4 enum class(es).
Example context from
fastapi/params.py(lines 14-24):Undefined, ) from .datastructures import _Unset class ParamTypes(Enum): query = "query" header = "header" path = "path" cookie = "cookie" - Custom decorator pattern: @deprecated: Use custom decorator @deprecated (4 usages). Also uses: @asynccontextmanager.
Example context from
fastapi/responses.py(lines 34-44):orjson = cast(_OrjsonModule, importlib.import_module("orjson")) except ModuleNotFoundError: # pragma: nocover orjson = None # type: ignore[assignment] @deprecated( "UJSONResponse is deprecated, FastAPI now serializes data directly to JSON " "bytes via Pydantic when a return type or response model is set, which is " "faster and doesn't need a custom response class. Read more in the FastAPI " "docs: https://fastapi.tiangolo.com/advanced/custom-response/#orjson-or-response-model " "and https://fastapi.tiangolo.com/tutorial/response-model/", - Limited exception chaining: Preserve exception context: use
raise X from Yorraise X from None. Example context fromfastapi/encoders.py(lines 350-356):data = vars(obj) except Exception as e: errors.append(e) raise ValueError(errors) from e return jsonable_encoder( data, include=include, - Mixed validation approaches: Validate inputs and parameters: Use multiple validation approaches: Pydantic validation, Manual validation (ValueError/TypeError), Decorator-based validation..
Example context from
fastapi/encoders.py(lines 21-27):from annotated_doc import Doc from fastapi.exceptions import PydanticV1NotSupportedError from fastapi.types import IncEx from pydantic import BaseModel from pydantic.networks import AnyUrl, NameEmail from pydantic.types import SecretBytes, SecretStr from pydantic_core import PydanticUndefinedType
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.
- 5d ago First seen · 122 lines · 0 tokens per session scan A 46a2320a42c4
fastapi is a cursor rule published in the GitHub repository steph-dove/klaussy-agents (16 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,175 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-30.
Other cursor rules, from other repositories
python_tests
We use the unit tests to cover internal behavior that can work without the web / backend counterpart. We aim for 95%+ unit test coverage of our Python code in lib/streamlit.
python-llm-ml-workflow-cursorrules-prompt-file
Cursor rules for Python LLM & ML development with workflow integration.
python
Python best practices and patterns for modern software development with Flask and SQLite.
python-containerization-cursorrules-prompt-file
Cursor rules for Python development with containerization integration.
django
Definitive guidelines for writing maintainable, performant, and secure Django applications, emphasizing modern best practices, clear code organization, and efficient patterns.
rich
Definitive guidelines for building robust, maintainable, and visually appealing Python CLI applications using the rich library.