fastapi-response-contract-boundary

fastapi-response-contract-boundary is a skill for Claude Code, Codex from JinNing6/Noosphere. It costs 61 tokens per session (651 once invoked), scanned A, original, Apache-2.0.

A workflow for keeping FastAPI response data—API output validated by Pydantic models—consistent with its declared schema.

In plain words
What is it for?
It reproduces the failing request, identifies the contract boundary, normalizes legacy data before validation, and preserves strict response models.
Why use it?
It prevents old or externally stored records from causing response-validation errors and keeps analytics endpoints from using different definitions of the same metric.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It reproduces the failing request, identifies the contract boundary, normalizes legacy data before validation, and preserves strict response models.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jinning6/noosphere/fastapi-response-contract-boundary
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.

Any agent
npx skills add JinNing6/Noosphere --skill fastapi-response-contract-boundary
Clone the repo
git clone --depth 1 https://github.com/JinNing6/Noosphere

Made for: Claude Code, Codex.

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 fastapi-response-contract-boundary

README.md
[![agentmods](https://agentmods.dev/badge/skills/jinning6/noosphere/fastapi-response-contract-boundary.svg)](https://agentmods.dev/skills/jinning6/noosphere/fastapi-response-contract-boundary)
Your own site
<a href="https://agentmods.dev/skills/jinning6/noosphere/fastapi-response-contract-boundary"><img src="https://agentmods.dev/badge/skills/jinning6/noosphere/fastapi-response-contract-boundary.svg" alt="Measured on agentmods" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 651 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00061 $0.00651
Opus 5 $0.00030 $0.00326
Sonnet 5 $0.00012 $0.00130
Haiku 4.5 $0.00006 $0.00065

Measured 7d ago against content hash 97170e446bdc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

fastapi-response-contract-boundary 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 7d 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.

shared_skills/active/fastapi-response-contract-boundary/SKILL.md · 62 lines

How it starts

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

FastAPI Response Contract Boundary

Use this skill to keep strict FastAPI response models without letting old or external data crash user-facing endpoints.

Workflow

  1. Reproduce with the real API first.

    • Create or identify a real row that triggers the endpoint.
    • Capture the HTTP status and backend traceback.
    • If test data is created, clean it through the public deletion path and verify database counts.
  2. Check official docs before code edits.

    • FastAPI response model validation/filtering behavior.
    • Pydantic v2 model validation, field defaults, and validators.
    • SQLAlchemy/ORM serialization docs only when the fix touches ORM loading or mapped attributes.
  3. Locate the contract boundary.

    • Input schema: rejects invalid new writes.
    • Stored data: may contain legacy or externally written JSON.
    • Service serializer: should normalize legacy stored data before FastAPI validates the response.
    • Response schema: should remain strict unless the product contract truly changed.
  4. Do not "fix" by removing response_model.

    • A 500 from ResponseValidationError is a useful release gate.
    • Keep strict response models and make returned data conform to them.
    • Prefer one service-level normalizer over scattered endpoint patches.
  5. Normalize legacy JSON deliberately.

    • Fill missing required response fields with explicit safe defaults such as target_window, legacy_signal, or unknown.
    • Drop or coerce invalid optional fields such as weights outside accepted ranges.
    • Preserve new-write validation so malformed new payloads are still rejected.
    • Add regression tests that validate the final dict with the response Pydantic model.
  6. For analytics metrics, define one canonical source.

    • Identify the invariant, for example net_balance == -life_hours_delta.
    • Derive secondary totals from the canonical metric, not from a competing raw sum.
    • Keep explanatory category fields separate from canonical totals when schemas have legacy display fields.
    • Test cross-endpoint identity, not only each endpoint shape.

Read the full file on GitHub · 62 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. 7d ago First seen · 62 lines · 61 tokens per session scan A 97170e446bdc

Subscribe to this mod's changes

fastapi-response-contract-boundary is a skill published in the GitHub repository JinNing6/Noosphere (18 stars, last pushed 7d ago), licensed Apache-2.0. It adds 61 tokens to every session and 651 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

add-backend

Guide for adding a backend (Rust or Python) to the agent-sec-core security middleware. Use when creating new backends, integrating Rust or Python code into the security middleware, or extending with new backend actions.

alibaba/anolisa · 46 tokens

claude-api

Build, debug, and optimize Claude API / Anthropic SDK apps. Apps built with this skill should include prompt caching. Also handles migrating existing Claude API code between Claude model versions (4.5 → 4.6, 4.6 → 4.7, retired-model replacements). TRIGGER when: code imports anthropic/@anthropic-ai/sdk; user asks for…

Prismer-AI/PrismerCloud · 193 tokens

csharp-patterns

C#/.NET: LINQ, async/await, DI, records, nullable refs, ASP.NET Core, EF Core, MediatR. Triggers: C#, .NET, dotnet, ASP.NET, EF Core, LINQ, record type, IServiceCollection.

softspark/ai-toolkit · 61 tokens

java-patterns

Java: Spring Boot, CompletableFuture, records, sealed types, JPA/Hibernate, virtual threads. Triggers: Java, Spring, JPA, Hibernate, Maven, Gradle, virtual thread, sealed class.

softspark/ai-toolkit · 48 tokens

api-patterns

API design: naming, versioning, pagination, idempotency, OpenAPI, error contracts and safe retries. Triggers: API design, REST, GraphQL, OpenAPI, Swagger, error response, HTTP status, rate limit.

softspark/ai-toolkit · 52 tokens

verify

Build, launch, and drive a local Honcho stack to verify a change at its runtime surface (the /v3 HTTP API and the deriver queue). Use when verifying a diff or confirming a change works in the running app.

plastic-labs/honcho · 49 tokens