Spec 022 promoted this skill from a deliberate stub
(ADR-0002)
to jig's team baseline for external-interface contract artifacts,
following the reframing in
ADR-0005.
Like /jig:pr-review (spec 012), /jig:arch-review (spec 014), and
/jig:vision-elicitation (spec 017), it ships as SKILL.md only — no
.py helper. The skill recommends the canonical industry-standard
schema per external surface and points at the ecosystem tools that
validate it. It does not write schemas, not scaffold a
contracts/ directory, and not enforce contracts via PreToolUse
hooks. Enforcement is structural via the spec-author's first-pass
attention and the independent-review reviewer prompt's second-pass
check — both wired in slice 022-02.
What this skill does
For each external surface a project exposes (HTTP API, event bus, RPC,
GraphQL, internal data shapes, CLI output, config), this skill
recommends:
- The canonical artifact — what to put on disk (e.g.,
openapi.yaml, *.schema.json, *.proto, schema.graphql).
- The validation tool — what runs in CI to keep code and artifact
in sync (e.g.,
spectral lint, ajv validate, buf lint,
graphql-inspector diff).
- The codegen tool — what produces typed clients / server stubs /
TS types from the artifact, when ecosystem-appropriate (e.g.,
openapi-typescript, quicktype, buf generate).
The skill is breadth over depth: catch the right artifact per
surface, leave language-specific niceties (Zod vs JSON Schema vs
Pydantic vs TypeBox for internal shapes) to a richer user-installed
contracts skill or to the dev's judgment. The recommendations are a
nudge; the dev decides whether to follow them.
When to use vs. when to defer
- Any other installed contracts skill. Common location:
~/.claude/skills/contracts/ — but the deferral is category-based,
not name-based, so a skill named anything (contracts,
schema-design, contract-first, api-contracts, etc.) whose
description claims external-interface contract artifacts, API schema
design, or contract-first workflow will be preferred. If one is
present, defer to it. The Claude Code skill router should route
to the more specific skill automatically; if you want to be sure,
explicitly invoke it.
/jig:arch-review — sibling jig skill that reviews the
design of an API surface (the proposal, the trade-offs, the
failure modes). This skill is downstream: once the design is locked,
formalize the resulting interface as a contract artifact. Reach for
/jig:arch-review to debate whether the API should exist; reach for
this skill once it does.
/jig:adr-workflow — if the dev decides to systematically opt
out of the canonical recommendation for a surface (e.g., "we'll keep
our bespoke env-contract checker, not migrate to a JSON Schema +
ajv triple"), capture the rationale in an ADR. This skill nudges;
ADRs document the choice when the nudge is declined.
- The deferred ADR-0002 stub concept (internal module-boundary
enforcement, cross-module Python imports, kitchen-sink scaffolding).
Not this skill. ADR-0002 stays in force for the internal-boundary
problem; ADR-0005 carved out external-interface artifacts as the
separate concern this skill addresses.
Rule of thumb: external interface a caller depends on → this skill.
Internal Python imports → not this skill.
Per-surface artifact recommendations
The table below is the canonical reference. Each row prescribes the
recommended artifact + validation tool + codegen tool (where the
ecosystem affords one). Rationale: the most portable artifact with the
richest ecosystem tooling, biased toward stack-agnostic choices when
possible.
| Surface |
Recommended artifact |
Validation |
Codegen |
Rationale |
| HTTP API |
OpenAPI 3.x (openapi.yaml) |
spectral lint, redocly lint |
openapi-typescript, openapi-generator, orval |
De facto industry standard; richest ecosystem; vendor-neutral. |
| Event bus / async messaging |
AsyncAPI (asyncapi.yaml) |
asyncapi/parser, spectral (AsyncAPI ruleset) |
asyncapi/generator (clients, docs, code) |
Same shape as OpenAPI from the same maintainers; portable across Kafka / NATS / MQTT / WebSocket. |
| RPC |
Protocol Buffers .proto (or Smithy for AWS-native) |
buf lint, buf breaking |
buf generate (Go / TS / Java / Python / etc.) |
Schema-first by design; codegen is the primary workflow, not an afterthought. |
| GraphQL |
SDL (schema.graphql) |
graphql-inspector diff, spectral-graphql |
graphql-codegen |
Native to the GraphQL toolchain; SDL is the single source of truth across server and client. |
| Internal data shapes |
JSON Schema (*.schema.json) |
ajv validate |
quicktype, json-schema-to-typescript |
Portable across ecosystems; most language-agnostic. Stack-coupled alternatives (Zod for TS, Pydantic for Python, TypeBox for TS+JSON-Schema export) acceptable when the team has already standardized. |
| Config / env vars |
JSON Schema (per config file) or bespoke env-contract pattern |
ajv validate, custom env-contract checker |
quicktype (when JSON Schema) |
JSON Schema for structured config files; for env-var sprawl, a bespoke env-contract pattern (markdown reference table + .env.example seed + stdlib-only checker script + CI gate) is a worked-example-friendly alternative — see ADR-0005 Context §1 for the case study that motivated this row. |
| CLI output |
JSON Schema for --json / --format json output |
ajv validate in shell-test fixtures |
quicktype |
Lets downstream pipes assume the shape; reproducible test fixtures. |
Notes on the table:
- One canonical artifact per surface — firmer nudge than a menu, with
stack-coupled alternatives called out inline (rather than as
separate rows) so the table stays scan-friendly.
- Internal data shapes is the row most likely to draw push-back: Zod /
Pydantic / TypeBox have real ergonomic wins inside their respective
stacks. The recommendation is JSON Schema because (a) it's portable
across stacks, (b) the JSON-Schema → TS-types codegen path is
already mature via
quicktype. If a team is single-stack and
committed, opting into Zod / Pydantic with optional JSON-Schema
export (e.g., zod-to-json-schema) is a reasonable opt-out.
- Smithy is listed as an RPC alternative because AWS-native projects
often standardize on it; for everything else,
.proto wins on
ecosystem maturity.
When to opt out
The skill nudges; it does not refuse edits. Slice 022-02 will wire
two structural touchpoints that make declared surfaces visible to the
spec-author at init time (/jig:vision-elicitation Appendix A) and to
the independent reviewer at slice-review time (review.py prompt
template). Even with those wired, no part of jig blocks a commit or
rejects a slice for skipping an artifact — the wizard skips on empty
answer, the reviewer flags a suggestion, and migrate.py report
recommends per surface without auto-rewriting.
Legitimate opt-out scenarios:
- Migration of a project with a working bespoke pattern. If a
project already ships a contract-shaped artifact (e.g., the
env-contract.md + .env.example + stdlib-checker triple from
aso-shallow-validator), don't force a migration. The pattern works;
the recommendation table is for new surfaces.
- One-off internal tool with a single consumer that will never
expand. A throwaway script's
--json output doesn't need a JSON
Schema. The skill's value is at the surface that has (or will have)
more than one caller.
- Pre-existing different artifact in active use. RAML, JSON-RPC
schemas, Avro, hand-rolled IDLs — if the team has invested and the
tooling works, no migration. The skill's recommendations are for
surfaces that don't yet have an artifact.
- Pre-product-market-fit prototype. Contract artifacts are
durability-shaped. If the interface is being thrown away next sprint,
defer.
When the opt-out is structural (a whole project commits to a
non-canonical pattern), capture the rationale in an ADR via
/jig:adr-workflow. The nudge is informed by the table; the
documented exception is informed by the ADR.
Worked examples
Two worked examples ship as sibling files, intentionally on different
external surfaces (HTTP API vs. internal data envelope) to
demonstrate the recommendation pattern (artifact + validation tool +
CI gate + optional codegen) applies regardless of surface shape:
- worked-example-openapi-http.md —
formalizing a prose HTTP API contract (the
aso-shallow-validator §5 case) into an OpenAPI 3.x spec, wiring
spectral as the CI gate, and generating typed clients via
openapi-typescript. Surface: HTTP API.
- worked-example-json-schema-envelope.md
— pinning an internal data envelope with JSON Schema, validating
with
ajv in tests, and noting the stack-coupled alternatives
(Zod / Pydantic / TypeBox) where they're idiomatic. Surface:
internal data shape.
Both worked examples use JS/Node tooling in the code blocks — that's
the most universally-installed ecosystem for spectral / ajv /
openapi-typescript / quicktype. The recommendations themselves
are stack-agnostic; the same artifacts apply equally in Go (protoc
buf), Python (jsonschema + Pydantic), Rust (utoipa +
serde_json), etc. The recommendation table is the stack-neutral
map; the worked examples are one concrete instantiation each.
Gotchas
- The skill recommends, devs author. Never auto-generate the
artifact from prose docs. Auto-conversion is too lossy for a
one-shot tool: prose contracts encode informal assumptions
(idempotency rules, cache hints, error remediation) that don't map
to schema fields. The dev (or an LLM driving the migration with
prompt context) writes the artifact; the skill flags the gap.
- The recommendation table is the canonical reference. Don't deviate
silently. If a project picks a different artifact per surface, the
choice belongs in an ADR — visible to future contributors. Quiet
deviations look like accidents to the next reviewer.
- Ecosystem tools have version churn; the skill won't pin
versions.
spectral, ajv, buf, graphql-inspector and their
generators all move. The skill names them; the dev pins them in
their project's lockfile.
- The two worked examples are intentionally JS/Node and
stack-agnostic. The abstraction lives in the per-surface table,
not in the worked-example implementations. If your stack is
different (Go + protoc, Python + jsonschema, Rust + utoipa), the
table still applies; the worked-example commands change.
- This is not a CI tool. The skill recommends which CI gate to
wire (
spectral, ajv, buf); it doesn't run the gate. The dev
configures their CI to call the tool against the artifact.
- Fallback mode (if the routing-dogfood ever fails): the SKILL.md
frontmatter gets
disable-model-invocation: true and the skill
becomes explicit-invocation-only (/jig:contracts). In that mode no
auto-trigger fires — the user types the slash command. If you see
disable-model-invocation: true in this skill's frontmatter, that's
why.
Relationship to other skills
/jig:vision-elicitation — slice 022-02 grows Appendix A to ask
what external surfaces the project exposes at scaffold-init time,
with hand-off to this skill's recommendation table. Declared
surfaces become visible to the next two integration points.
/jig:independent-review — slice 022-02 extends the reviewer
prompt template with a "slice touches a declared contract surface?
artifact updated in the same change-set?" check. Conditional — only
fires when surfaces have been declared.
/jig:migrate — slice 022-02 grows migrate.py report output
with a "Contract surfaces detected" section that flags existing
artifacts on disk + prose API contracts + env-contract-style
patterns + hand-typed boundary types. Recommends per surface; never
auto-rewrites.
/jig:adr-workflow — captures structural opt-outs from the
recommendation table when a project deliberately chooses a
non-canonical artifact.
/jig:arch-review — orthogonal sibling. Reviews the design of
the API surface; this skill formalizes the resulting interface as
an artifact. Use arch-review first (does the API make sense?) then
this skill (what artifact should it have?).
/jig:pr-review — orthogonal. A PR-shape diff review may
surface contract drift (response shape changed without artifact
update); this skill is the place to look up which artifact should
govern.
1---2name: contracts3description: Team baseline for external-interface contract artifacts: OpenAPI, JSON Schema, AsyncAPI, .proto, and GraphQL SDL, with spectral, ajv, buf, and graphql-inspector validation. Nudges devs toward contract-first artifacts; never writes them and never scaffolds a contracts/ directory. Auto-triggers for what contract should I use for this API, do we have an OpenAPI spec, add a JSON schema for this, recommend a schema for this endpoint, validate this API contract, or what's the right artifact for events. Defers to any other installed skill whose description identifies it as handling external-interface contract artifacts, API schema design, or contract-first workflow. Do not use for internal module-boundary refactoring, scaffolding a contracts/ directory, or auto-generating schemas from code.4---56> Spec 022 promoted this skill from a deliberate stub7> ([ADR-0002](../../docs/decisions/adr-0002-contracts-stays-deferred.md))8> to jig's **team baseline** for external-interface contract artifacts,9> following the reframing in10> [ADR-0005](../../docs/decisions/adr-0005-contracts-as-judgment-skill.md).11> Like `/jig:pr-review` (spec 012), `/jig:arch-review` (spec 014), and12> `/jig:vision-elicitation` (spec 017), it ships as SKILL.md only — no13> `.py` helper. The skill recommends the canonical industry-standard14> schema per external surface and points at the ecosystem tools that15> validate it. It does **not** write schemas, **not** scaffold a16> `contracts/` directory, and **not** enforce contracts via PreToolUse17> hooks. Enforcement is structural via the spec-author's first-pass18> attention and the independent-review reviewer prompt's second-pass19> check — both wired in slice 022-02.2021## What this skill does2223For each external surface a project exposes (HTTP API, event bus, RPC,24GraphQL, internal data shapes, CLI output, config), this skill25recommends:26271. **The canonical artifact** — what to put on disk (e.g.,28 `openapi.yaml`, `*.schema.json`, `*.proto`, `schema.graphql`).292. **The validation tool** — what runs in CI to keep code and artifact30 in sync (e.g., `spectral lint`, `ajv validate`, `buf lint`,31 `graphql-inspector diff`).323. **The codegen tool** — what produces typed clients / server stubs /33 TS types from the artifact, when ecosystem-appropriate (e.g.,34 `openapi-typescript`, `quicktype`, `buf generate`).3536The skill is **breadth over depth**: catch the right artifact per37surface, leave language-specific niceties (Zod vs JSON Schema vs38Pydantic vs TypeBox for internal shapes) to a richer user-installed39contracts skill or to the dev's judgment. The recommendations are a40nudge; the dev decides whether to follow them.4142## When to use vs. when to defer4344- **Any other installed contracts skill.** Common location:45 `~/.claude/skills/contracts/` — but the deferral is **category-based,46 not name-based**, so a skill named anything (`contracts`,47 `schema-design`, `contract-first`, `api-contracts`, etc.) whose48 description claims external-interface contract artifacts, API schema49 design, or contract-first workflow will be preferred. If one is50 present, **defer to it.** The Claude Code skill router should route51 to the more specific skill automatically; if you want to be sure,52 explicitly invoke it.53- **`/jig:arch-review`** — sibling jig skill that reviews the54 **design** of an API surface (the proposal, the trade-offs, the55 failure modes). This skill is downstream: once the design is locked,56 formalize the resulting interface as a contract artifact. Reach for57 `/jig:arch-review` to debate whether the API should exist; reach for58 this skill once it does.59- **`/jig:adr-workflow`** — if the dev decides to systematically opt60 out of the canonical recommendation for a surface (e.g., "we'll keep61 our bespoke env-contract checker, not migrate to a JSON Schema +62 ajv triple"), capture the rationale in an ADR. This skill nudges;63 ADRs document the choice when the nudge is declined.64- **The deferred ADR-0002 stub concept** (internal module-boundary65 enforcement, cross-module Python imports, kitchen-sink scaffolding).66 Not this skill. ADR-0002 stays in force for the internal-boundary67 problem; ADR-0005 carved out external-interface artifacts as the68 separate concern this skill addresses.6970Rule of thumb: **external interface a caller depends on → this skill.71Internal Python imports → not this skill.**7273## Per-surface artifact recommendations7475The table below is the canonical reference. Each row prescribes the76recommended artifact + validation tool + codegen tool (where the77ecosystem affords one). Rationale: the most portable artifact with the78richest ecosystem tooling, biased toward stack-agnostic choices when79possible.8081| Surface | Recommended artifact | Validation | Codegen | Rationale |82|---|---|---|---|---|83| **HTTP API** | OpenAPI 3.x (`openapi.yaml`) | `spectral lint`, `redocly lint` | `openapi-typescript`, `openapi-generator`, `orval` | De facto industry standard; richest ecosystem; vendor-neutral. |84| **Event bus / async messaging** | AsyncAPI (`asyncapi.yaml`) | `asyncapi/parser`, `spectral` (AsyncAPI ruleset) | `asyncapi/generator` (clients, docs, code) | Same shape as OpenAPI from the same maintainers; portable across Kafka / NATS / MQTT / WebSocket. |85| **RPC** | Protocol Buffers `.proto` (or Smithy for AWS-native) | `buf lint`, `buf breaking` | `buf generate` (Go / TS / Java / Python / etc.) | Schema-first by design; codegen is the primary workflow, not an afterthought. |86| **GraphQL** | SDL (`schema.graphql`) | `graphql-inspector diff`, `spectral-graphql` | `graphql-codegen` | Native to the GraphQL toolchain; SDL is the single source of truth across server and client. |87| **Internal data shapes** | JSON Schema (`*.schema.json`) | `ajv validate` | `quicktype`, `json-schema-to-typescript` | Portable across ecosystems; most language-agnostic. Stack-coupled alternatives (Zod for TS, Pydantic for Python, TypeBox for TS+JSON-Schema export) acceptable when the team has already standardized. |88| **Config / env vars** | JSON Schema (per config file) or bespoke env-contract pattern | `ajv validate`, custom env-contract checker | `quicktype` (when JSON Schema) | JSON Schema for structured config files; for env-var sprawl, a bespoke env-contract pattern (markdown reference table + `.env.example` seed + stdlib-only checker script + CI gate) is a worked-example-friendly alternative — see [ADR-0005](../../docs/decisions/adr-0005-contracts-as-judgment-skill.md) Context §1 for the case study that motivated this row. |89| **CLI output** | JSON Schema for `--json` / `--format json` output | `ajv validate` in shell-test fixtures | `quicktype` | Lets downstream pipes assume the shape; reproducible test fixtures. |9091**Notes on the table:**9293- One canonical artifact per surface — firmer nudge than a menu, with94 stack-coupled alternatives called out inline (rather than as95 separate rows) so the table stays scan-friendly.96- Internal data shapes is the row most likely to draw push-back: Zod /97 Pydantic / TypeBox have real ergonomic wins inside their respective98 stacks. The recommendation is JSON Schema because (a) it's portable99 across stacks, (b) the JSON-Schema → TS-types codegen path is100 already mature via `quicktype`. If a team is single-stack and101 committed, opting into Zod / Pydantic with optional JSON-Schema102 export (e.g., `zod-to-json-schema`) is a reasonable opt-out.103- Smithy is listed as an RPC alternative because AWS-native projects104 often standardize on it; for everything else, `.proto` wins on105 ecosystem maturity.106107## When to opt out108109**The skill nudges; it does not refuse edits.** Slice 022-02 will wire110two structural touchpoints that make declared surfaces visible to the111spec-author at init time (`/jig:vision-elicitation` Appendix A) and to112the independent reviewer at slice-review time (`review.py` prompt113template). Even with those wired, no part of jig blocks a commit or114rejects a slice for skipping an artifact — the wizard skips on empty115answer, the reviewer flags a *suggestion*, and `migrate.py report`116*recommends* per surface without auto-rewriting.117118Legitimate opt-out scenarios:119120- **Migration of a project with a working bespoke pattern.** If a121 project already ships a contract-shaped artifact (e.g., the122 `env-contract.md` + `.env.example` + stdlib-checker triple from123 aso-shallow-validator), don't force a migration. The pattern works;124 the recommendation table is for new surfaces.125- **One-off internal tool with a single consumer that will never126 expand.** A throwaway script's `--json` output doesn't need a JSON127 Schema. The skill's value is at the surface that has (or will have)128 more than one caller.129- **Pre-existing different artifact in active use.** RAML, JSON-RPC130 schemas, Avro, hand-rolled IDLs — if the team has invested and the131 tooling works, no migration. The skill's recommendations are for132 surfaces that don't yet have an artifact.133- **Pre-product-market-fit prototype.** Contract artifacts are134 durability-shaped. If the interface is being thrown away next sprint,135 defer.136137When the opt-out is structural (a whole project commits to a138non-canonical pattern), capture the rationale in an ADR via139`/jig:adr-workflow`. The nudge is informed by the table; the140documented exception is informed by the ADR.141142## Worked examples143144Two worked examples ship as sibling files, intentionally on different145**external surfaces** (HTTP API vs. internal data envelope) to146demonstrate the recommendation pattern (artifact + validation tool +147CI gate + optional codegen) applies regardless of surface shape:148149- [worked-example-openapi-http.md](worked-example-openapi-http.md) —150 formalizing a prose HTTP API contract (the151 aso-shallow-validator §5 case) into an OpenAPI 3.x spec, wiring152 `spectral` as the CI gate, and generating typed clients via153 `openapi-typescript`. Surface: HTTP API.154- [worked-example-json-schema-envelope.md](worked-example-json-schema-envelope.md)155 — pinning an internal data envelope with JSON Schema, validating156 with `ajv` in tests, and noting the stack-coupled alternatives157 (Zod / Pydantic / TypeBox) where they're idiomatic. Surface:158 internal data shape.159160Both worked examples use JS/Node tooling in the code blocks — that's161the most universally-installed ecosystem for `spectral` / `ajv` /162`openapi-typescript` / `quicktype`. The recommendations themselves163are stack-agnostic; the same artifacts apply equally in Go (`protoc`164+ `buf`), Python (`jsonschema` + Pydantic), Rust (`utoipa` +165`serde_json`), etc. The recommendation table is the stack-neutral166map; the worked examples are one concrete instantiation each.167168## Gotchas169170- **The skill recommends, devs author. Never auto-generate the171 artifact from prose docs.** Auto-conversion is too lossy for a172 one-shot tool: prose contracts encode informal assumptions173 (idempotency rules, cache hints, error remediation) that don't map174 to schema fields. The dev (or an LLM driving the migration with175 prompt context) writes the artifact; the skill flags the gap.176- **The recommendation table is the canonical reference. Don't deviate177 silently.** If a project picks a different artifact per surface, the178 choice belongs in an ADR — visible to future contributors. Quiet179 deviations look like accidents to the next reviewer.180- **Ecosystem tools have version churn; the skill won't pin181 versions.** `spectral`, `ajv`, `buf`, `graphql-inspector` and their182 generators all move. The skill names them; the dev pins them in183 their project's lockfile.184- **The two worked examples are intentionally JS/Node and185 stack-agnostic.** The abstraction lives in the per-surface table,186 not in the worked-example implementations. If your stack is187 different (Go + protoc, Python + jsonschema, Rust + utoipa), the188 table still applies; the worked-example commands change.189- **This is not a CI tool.** The skill recommends which CI gate to190 wire (`spectral`, `ajv`, `buf`); it doesn't run the gate. The dev191 configures their CI to call the tool against the artifact.192- **Fallback mode** (if the routing-dogfood ever fails): the SKILL.md193 frontmatter gets `disable-model-invocation: true` and the skill194 becomes explicit-invocation-only (`/jig:contracts`). In that mode no195 auto-trigger fires — the user types the slash command. If you see196 `disable-model-invocation: true` in this skill's frontmatter, that's197 why.198199## Relationship to other skills200201- **`/jig:vision-elicitation`** — slice 022-02 grows Appendix A to ask202 what external surfaces the project exposes at scaffold-init time,203 with hand-off to this skill's recommendation table. Declared204 surfaces become visible to the next two integration points.205- **`/jig:independent-review`** — slice 022-02 extends the reviewer206 prompt template with a "slice touches a declared contract surface?207 artifact updated in the same change-set?" check. Conditional — only208 fires when surfaces have been declared.209- **`/jig:migrate`** — slice 022-02 grows `migrate.py report` output210 with a "Contract surfaces detected" section that flags existing211 artifacts on disk + prose API contracts + env-contract-style212 patterns + hand-typed boundary types. Recommends per surface; never213 auto-rewrites.214- **`/jig:adr-workflow`** — captures structural opt-outs from the215 recommendation table when a project deliberately chooses a216 non-canonical artifact.217- **`/jig:arch-review`** — orthogonal sibling. Reviews the design of218 the API surface; this skill formalizes the resulting interface as219 an artifact. Use arch-review first (does the API make sense?) then220 this skill (what artifact should it have?).221- **`/jig:pr-review`** — orthogonal. A PR-shape diff review may222 surface contract drift (response shape changed without artifact223 update); this skill is the place to look up which artifact should224 govern.