# Fastapi response contract boundary

> Fastapi response contract boundary is an open-source agent skill for analytics and data. Guides fixing FastAPI response validation errors and analytics metric drift. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/JinNing6/Noosphere/tree/main/shared_skills/active/fastapi-response-contract-boundary
- **Repository:** https://github.com/jinning6/noosphere
- **GitHub stars:** 18
- **License:** Apache-2.0
- **Skill name:** fastapi-response-contract-boundary
- **Collection:** https://github.com/JinNing6/Noosphere
- **Categories:** [analytics and data](https://ai-powered.com/categories/analytics-and-data), [legal and government](https://ai-powered.com/categories/legal-and-government), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

This skill helps an agent keep strict FastAPI and Pydantic response models while stopping old or externally written JSON from crashing user-facing endpoints. It walks through reproducing the failing call against the real API, locating where the contract breaks between input schema, stored data, service serializer and response schema, and adding a single service-level normalizer rather than patching endpoints one by one.

The workflow also covers analytics endpoints where dashboard, trend and report APIs disagree. It asks the agent to pick one canonical metric, derive secondary totals from it, and test that cross-endpoint identities hold in real output. Regression guidance covers unit tests for malformed legacy JSON, validating serialized output through the actual response model, and a smoke run that includes test-data cleanup.

The skill is written for Python backends using FastAPI and Pydantic v2 and tells the agent to consult the official docs before editing code. It bundles no scripts and expects a working backend test suite and, where production runs in Docker, access to rebuild that service.

## When your agent uses it

> Audit and fix FastAPI/Pydantic response contract failures and analytics metric drift. Use when endpoints return ResponseValidationError/500, legacy JSON rows miss required response fields, response_model schemas need compatibility normalizers, or dashboard/trend/report APIs disagree on a canonical metric.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/JinNing6/Noosphere/tree/HEAD/shared_skills/active/fastapi-response-contract-boundary)
- [License: Apache-2.0](https://github.com/JinNing6/Noosphere/tree/HEAD/shared_skills/active/fastapi-response-contract-boundary)

## Features

- **Response model boundary:** Explains where strict validation should sit between input schemas, stored data and the serializer.
- **Legacy JSON normalization:** Fills missing required fields with explicit safe defaults and coerces or drops invalid optional values.
- **Keep strict models:** Warns against removing response_model and treats ResponseValidationError as a release gate.
- **Canonical metric rules:** Defines one source of truth for analytics totals and derives other figures from it.
- **Regression test checklist:** Lists unit, response-model and real API smoke checks, including test data cleanup.

## Good for

- Fix a 500 ResponseValidationError on an endpoint returning old database rows
- Add a normalizer so legacy JSON validates against a Pydantic response model
- Make dashboard and trend API totals agree on the same metric
- Write regression tests for malformed stored JSON in a FastAPI service
- Smoke-test an API after a fix and verify test data is removed

## Install

### Claude Code

Copy the skill folder to `~/.claude/skills/fastapi-response-contract-boundary` to use it in all your projects:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/JinNing6/Noosphere.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/fastapi-response-contract-boundary &&
cp -R "$tmp/shared_skills/active/fastapi-response-contract-boundary" ~/.claude/skills/fastapi-response-contract-boundary &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/fastapi-response-contract-boundary` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/fastapi-response-contract-boundary` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/JinNing6/Noosphere.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/fastapi-response-contract-boundary &&
cp -R "$tmp/shared_skills/active/fastapi-response-contract-boundary" ~/.agents/skills/fastapi-response-contract-boundary &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/fastapi-response-contract-boundary` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/fastapi-response-contract-boundary` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/JinNing6/Noosphere.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/fastapi-response-contract-boundary &&
cp -R "$tmp/shared_skills/active/fastapi-response-contract-boundary" ~/.cursor/skills/fastapi-response-contract-boundary &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/fastapi-response-contract-boundary` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/JinNing6/Noosphere.git --path shared_skills/active/fastapi-response-contract-boundary
```

Or copy the folder to `~/.gemini/skills/fastapi-response-contract-boundary` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/fastapi-response-contract-boundary`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/JinNing6/Noosphere.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/fastapi-response-contract-boundary &&
cp -R "$tmp/shared_skills/active/fastapi-response-contract-boundary" ~/.copilot/skills/fastapi-response-contract-boundary &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/fastapi-response-contract-boundary` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/JinNing6/Noosphere.git
```

Then copy `Noosphere/shared_skills/active/fastapi-response-contract-boundary` into your agent's skills folder as `fastapi-response-contract-boundary`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Fastapi response contract boundary trigger?

It is meant for cases where endpoints return ResponseValidationError or 500, legacy JSON rows miss required response fields, response_model schemas need compatibility normalizers, or dashboard, trend or report APIs disagree on a canonical metric.

### Should I remove response_model to stop the errors?

No. The skill says to keep strict response models and make the returned data conform to them, using a service-level normalizer.

### Does Fastapi response contract boundary include scripts?

No. The skill folder contains only its SKILL.md and no scripts or reference files.

### Does Fastapi response contract boundary change new write validation?

It says to preserve new-write validation so malformed new payloads are still rejected at the input boundary.

### How do I install Fastapi response contract boundary in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/fastapi-response-contract-boundary to use it in all your projects, or to .claude/skills/fastapi-response-contract-boundary in one project.

### Does Fastapi response contract boundary run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Fastapi response contract boundary?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Fastapi response contract boundary?

The closest alternatives to Fastapi response contract boundary are Python backend, Testing conventions, API integration, Backend repo architecture and API design.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Python backend](https://ai-powered.com/skills/python-backend): Python backend is an open-source agent skill for developer tools.
- [Testing conventions](https://ai-powered.com/skills/testing-conventions): Testing conventions is an open-source agent skill for developer tools.
- [API integration](https://ai-powered.com/skills/api-integration-ajyadav013): API integration is an open-source agent skill for developer tools.
- [Backend repo architecture](https://ai-powered.com/skills/backend-repo-architecture): Backend repo architecture is an open-source agent skill for developer tools.
- [API design](https://ai-powered.com/skills/api-design-fmarzochi): API design is an open-source agent skill for developer tools.
- [API compliance checker](https://ai-powered.com/skills/api-compliance-checker): API compliance checker is an open-source agent skill for security.
- [API health monitoring](https://ai-powered.com/skills/api-health-monitoring): API health monitoring is an open-source agent skill for health and science.
- [API design](https://ai-powered.com/skills/api-design-abdullayevtemurmalik): API design is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/fastapi-response-contract-boundary
