governing-field-lifecycle

Enforces API field lifecycle semantics including nullability and input/output separation via Pydantic models and OpenAPI 3.1 mapping.

Updated Mar 6, 2026
One-click install
npx skills add https://github.com/musher-dev/bundles --skill governing-field-lifecycle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: governing-field-lifecycle
Source: https://github.com/musher-dev/bundles/tree/main/api-route-governance/skills/governing-field-lifecycle
Command: npx skills add https://github.com/musher-dev/bundles --skill governing-field-lifecycle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enforces consistent and predictable behavior for API fields, preventing common issues like mass assignment vulnerabilities, confusing null/absence semantics, and schema inconsistencies.

Core Features & Use Cases

  • Null vs. Absence Distinction: Clearly defines and enforces the difference between a field being intentionally null and a field being absent.
  • Field Behavior Annotations: Manages field states like REQUIRED, OPTIONAL, OUTPUT_ONLY, and IMMUTABLE.
  • Schema Separation: Promotes the use of distinct Pydantic models for different API operations (create, update, patch, response) to enhance security and clarity.
  • OpenAPI 3.1 Nullability: Correctly maps Pydantic models to OpenAPI specifications for robust API documentation.
  • Use Case: When designing a new API endpoint, use this Skill to ensure that fields like id are OUTPUT_ONLY and cannot be sent by the client, and that immutable fields like slug are protected from modification after creation.

Quick Start

Use the governing-field-lifecycle skill to review the nullability and behavior annotations for the 'user_id' field in the API response schema.

Frequently Asked Questions about governing-field-lifecycle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I distinguish between null and absent fields in a Pydantic API schema?

Distinguishing null versus absence in a Pydantic API schema requires enforcing field lifecycle semantics that clearly define whether a field is intentionally null or simply omitted. This prevents confusing API interactions and schema inconsistencies by applying explicit field behavior annotations.

What is the best way to prevent mass assignment vulnerabilities in a Pydantic API?

Preventing mass assignment vulnerabilities in a Pydantic API is best achieved by enforcing schema separation between input and output models. By marking fields like `id` as OUTPUT_ONLY, you ensure clients cannot send or modify restricted fields during creation or update operations.

How do I map Pydantic models to OpenAPI 3.1 nullability correctly?

Mapping Pydantic models to OpenAPI 3.1 nullability involves applying specific field behavior annotations to govern output rules and input rules. This ensures your API documentation accurately reflects whether a field is required, optional, or explicitly accepts null values.

How do I configure immutable fields for API updates using Pydantic?

Configuring immutable fields for API updates using Pydantic involves applying IMMUTABLE field behavior annotations and utilizing distinct schema models for patch or update operations. This protects fields like `slug` from being modified after the initial resource creation.

Does separating input and output Pydantic models improve API security?

Separating input and output Pydantic models improves API security by strictly governing field lifecycle semantics for each operation. This schema separation prevents clients from injecting sensitive data into input payloads while controlling exactly what is exposed in responses.

Why do my API response schema and OpenAPI documentation have mismatched nullability?

Mismatched nullability between an API response schema and OpenAPI documentation occurs when Pydantic models lack enforced field lifecycle semantics. Correctly mapping output rules and field behavior annotations resolves these inconsistencies for robust API documentation.