Generate a coherent contract set from a domain description: OpenAPI 3.1.0 spec, JSON Schema files, Pydantic ContractModel classes, contract tests, and JSON test fixtures. Invoke with a domain description and list of /.octon/instance/capabilities/runtime/skills/resources/endpoints.
Generate a complete, cross-validated contract set for an API domain: OpenAPI spec, JSON schemas, Pydantic models, test fixtures, and contract tests.
$ARGUMENTS should include:
v1 unless specifiedExample: A job management API with: POST /v1/jobs (JobSubmitRequest -> 202 JobResponse), GET /v1/jobs/{job_id} (-> JobResponse | 404 ErrorResponse), GET /v1/jobs/{job_id}/artifact (-> ArtifactLinksResponse | 202 ErrorResponse | 404 ErrorResponse)
pyproject.toml to discover the project name and src/<package>/ path.docs/contracts/openapi-v1.yaml already exists. If yes, this is an
additive change — extend rather than overwrite. Read the existing spec first.src/<package>/models/base.py exists. If not, warn that
/scaffold-package should be run first.docs/contracts/versioning-policy.md exists. If yes, read and follow it.tests/conftest.py has load_contract_schema and load_contract_fixture
fixtures. If not, note that /test-harness should be run to get full test coverage.For each domain entity described in $ARGUMENTS, generate
docs/contracts/<entity-name>-v1.schema.json.
Use the skeleton in references/json-schema-skeleton.json.
Rules:
$schema: "https://json-schema.org/draft/2020-12/schema").$id to a project-local URI.additionalProperties: false on all object types.type, required, and property-level constraints (minLength, pattern,
enum, minimum, maximum, etc.).const for schema_version fields.python -m json.tool <file> >/dev/null.Use the skeleton in references/openapi-skeleton.yaml.
If creating new, generate docs/contracts/openapi-v1.yaml:
info (title, version "1.0.0"), servers, security, tags, paths./healthz and /readyz operational endpoints./v1/ prefix.$ref for all schema references in components/schemas.additionalProperties: false on all component schemas.Generate or extend src/<package>/api/contracts.py.
Use the pattern in references/contract-model-pattern.py.
Rules:
ContractModel (from <package>.models.base).Annotated types with StringConstraints for pattern-validated strings.Literal for enum-like fields.Field with default, ge, le, min_length, max_length matching
schema constraints.@field_validator where uniqueness or cross-field constraints apply.JobId = Annotated[str, StringConstraints(pattern=...)]).Generate fixtures in tests/contracts/fixtures/ following the naming convention
in references/fixture-naming.md.
For each contract entity, create at minimum:
<entity>.valid-minimal.json — only required fields, minimal valid values.<entity>.valid-full.json — all fields populated.<entity>.invalid-<field>.json — one per constrained field.Use the patterns in references/contract-test-patterns.py.
Generate or extend these test files:
tests/contracts/test_contract_schemas.py:
Draft202012Validator from jsonschema._validator(), _subschema_validator(), _errors().tests/contracts/test_openapi_contract.py:
/healthz: and /readyz: are present.tests/contracts/test_pydantic_contract_models.py:
model_validate succeeds on valid fixture payloads.model_validate raises ValidationError on invalid fixtures.If a justfile exists, update the validate-schemas target to include
python -m json.tool validation for each new schema file and rg -q checks
for new path segments in the OpenAPI spec.
tests/conftest.py lacks the required fixtures, note that /test-harness
should be run for full test support, but still generate the test files./scaffold-package (for models/base.py and package structure)/test-harness (for test infrastructure)