api-design

Designs and audits Kubernetes operator CRDs against kubebuilder marker and API consistency conventions.

4|Updated Dec 1, 2025
One-click install
npx skills add https://github.com/simplyblock/simplyblock-operator --skill api-design-simplyblock
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design
Source: https://github.com/simplyblock/simplyblock-operator/tree/main/.claude/skills/api-design
Command: npx skills add https://github.com/simplyblock/simplyblock-operator --skill api-design-simplyblock

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Designing Custom Resource Definitions for a Kubernetes operator involves dozens of conventions—Entity versus Ops kinds, spec versus status ownership, typed enums, immutability markers, printcolumns, and observedGeneration—that are easy to get wrong and hard to review by eye across many types. This Skill encodes those conventions and ships a checker that audits every CRD type against them, catching defects at admission-design time instead of after a release. ## Core Features & Use Cases - CRD Design Guidance: Decision rules for whether a change should be a field, an action on an <Entity>Ops kind, or a new kind, plus the full kubebuilder marker set every type must carry. - Automated Consistency Auditing: The check-crds.py script audits Go type files (or design document appendices via --design) for unenforced immutability, untyped phases, enum casing, toggle naming, missing observedGeneration, and more, exiting non-zero on errors so it can gate an API change. - Use Case: When adding a new action to StorageNodeOps, use this Skill to add the enum verb, per-action parameters, step constants, and CEL immutability rules, then run check-crds.py --changed to verify the change before regenerating manifests. ## Quick Start Ask the AI to design a new CRD or review an API change using the api-design skill, then run its checker script with the --changed flag to audit the modified type files.

Frequently Asked Questions about api-design

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

FAQPage Schema
How do I design a new CRD for a Kubernetes operator?

First decide whether the change is a field, an action on an existing Ops kind, or a new kind, based on whether it has its own lifecycle and is watched or referenced. Then apply the standard marker set: subresource:status, printcolumns, typed enums, and observedGeneration in status.

How do I enforce immutability on a Kubernetes CRD field?

Use the +k8s:immutable marker, which controller-gen turns into CEL validation rules. On an optional field it means immutable once set; on a required field it means immutable from creation. A doc comment saying immutable enforces nothing.

When should I create a new CRD versus adding a field?

Create a new CRD only when something watches it or references it by name and it has its own lifecycle and status. A thing with no independent lifecycle belongs as a field or nested struct on its owner, since each CRD costs a controller, RBAC, and a chart entry.

What is the difference between spec and status in a CRD?

Spec is the user's desired state and is never written by a controller; status is the controller's reconstructable record of progress, including phase, observedGeneration, and restart state. A field both parties set must be split into separate spec and status fields.

What counts as a breaking change to a shipped CRD?

Removing or renaming a field, removing an enum value, narrowing validation, tightening a default, or changing a field's type or meaning are breaking. Adding optional fields, enum values, printcolumns, or status fields is safe.

How do I audit CRD types for convention violations?

Run the check-crds.py script with --changed to audit only the type files modified against HEAD, or --design to audit Go types in a design document's appendix. It reports errors like untyped phases and unenforced immutability, exiting non-zero so it can gate a change.