klaussy-agents fastapi.instructions.md

klaussy-agents fastapi.instructions.md is an instructions file for GitHub Copilot from steph-dove/klaussy-agents. It costs 1,171 tokens per session, scanned A, original, MIT.

A set of Python web API conventions for FastAPI, a framework for building web services. It covers URL versioning, data models, server-sent events, and background work.

In plain words
What is it for?
It helps build versioned endpoints, define API and internal data objects, send server-sent events, and process background tasks with FastAPI.
Why use it?
It gives an agent clear patterns for organizing API versions, request data, streamed updates, and tasks that run after a response.

Instructions file for GitHub Copilot

Written for GitHub Copilot: a Copilot chat mode or prompt.

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 instructions/steph-dove/klaussy-agents/fastapi
Clone the repo
git clone --depth 1 https://github.com/steph-dove/klaussy-agents

Made for: GitHub Copilot.

Wrote 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.

agentmods badge for klaussy-agents fastapi.instructions.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/steph-dove/klaussy-agents/fastapi.svg)](https://agentmods.dev/instructions/steph-dove/klaussy-agents/fastapi)
Your own site
<a href="https://agentmods.dev/instructions/steph-dove/klaussy-agents/fastapi"><img src="https://agentmods.dev/badge/instructions/steph-dove/klaussy-agents/fastapi.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,171 This file is loaded in full into every session.
When invoked 1,171 The same file — it is already loaded in full.
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.1 $0.01171 $0.01171
Opus 5 $0.00585 $0.00585
Sonnet 5 $0.00234 $0.00234
Haiku 4.5 $0.00117 $0.00117

Measured 6d ago against content hash 53210074e315, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

klaussy-agents fastapi.instructions.md 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 6d 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.

examples/fastapi/.github/instructions/fastapi.instructions.md · 121 lines

How it starts

The opening of the file, as written. The whole thing — 121 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 Y or raise X from None. Example context from fastapi/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
    

Read the full file on GitHub · 121 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. 6d ago First seen · 121 lines · 1,171 tokens per session scan A 53210074e315

Subscribe to this mod's changes

klaussy-agents fastapi.instructions.md is an instructions file published in the GitHub repository steph-dove/klaussy-agents (16 stars, last pushed 9d ago), licensed MIT. It adds 1,171 tokens to every session, about $0.0059 per session on Opus 5. 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.