Contract-First API Design

Contract-First API Design is a skill for Claude Code from robisson/build-like-amazon-agent-skills. It costs 42 tokens per session (4,704 once invoked), scanned A, original, MIT.

A method for designing an API—the agreed way that software clients communicate with a service—before writing the implementation. It covers stable contracts, versioning, errors, repeated requests, and paginated results across different communication protocols.

In plain words
What is it for?
Use it when creating or changing web APIs, event interfaces, command-line interfaces, or other client-facing contracts. It helps define compatibility rules, error behavior, idempotency, pagination, and the right contract format.
Why use it?
It makes the service's promised behavior explicit before clients depend on it. This reduces accidental breaking changes and lets client and server teams develop independently.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the build-like-amazon plugin — 28 skills, 14 commands, 10 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/robisson/build-like-amazon-agent-skills/api-contract-first
Any agent
npx skills add robisson/build-like-amazon-agent-skills --skill api-contract-first
Clone the repo
git clone --depth 1 https://github.com/robisson/build-like-amazon-agent-skills

Made for: Claude Code.

Or install build-like-amazon, the plugin that ships this one along with the rest of its 28 skills, 14 commands, 10 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for Contract-First API Design

README.md
[![agentmods](https://agentmods.dev/badge/skills/robisson/build-like-amazon-agent-skills/api-contract-first.svg)](https://agentmods.dev/skills/robisson/build-like-amazon-agent-skills/api-contract-first)
Your own site
<a href="https://agentmods.dev/skills/robisson/build-like-amazon-agent-skills/api-contract-first"><img src="https://agentmods.dev/badge/skills/robisson/build-like-amazon-agent-skills/api-contract-first.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,704 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00042 $0.04704
Opus 5 $0.00021 $0.02352
Sonnet 5 $0.00008 $0.00941
Haiku 4.5 $0.00004 $0.00470

Measured 6d ago against content hash 2ea45e2aa22a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

Contract-First API Design scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/api-contract-first/SKILL.md · 393 lines

How it starts

The opening of the file, as written. The whole thing — 393 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Contract-First API Design

Overview

Contract-first means you design the API before you write implementation code. The API contract is a binding agreement with your clients: once published, it cannot be broken. This approach forces you to think from the client's perspective, establish clear semantics upfront, and create a stable interface that enables independent evolution of client and server.

At scale, APIs are used by clients you don't know, in ways you didn't anticipate, depending on behaviors you never documented. Hyrum's Law is absolute: "With a sufficient number of users of an API, all observable behaviors of your system will be depended on by somebody." This means every response header, every error format, every ordering behavior becomes part of your contract whether you intended it or not.

What counts as an API

An API is any contract through which a client consumes functionality. The protocol does not change the rule — but the standard you use to express the contract does change with the protocol. Picking the right standard matters. OpenAPI is not the universal answer; it is the answer for one of the protocols below.

Pick the right contract standard for the protocol

Protocol / surface Recommended contract standard Artifact filename example
REST / HTTP OpenAPI 3.x (canonical for REST). Smithy if you're in the AWS service style and want SDK code-gen. openapi.yaml, service.smithy
GraphQL GraphQL SDL — the schema is the contract; .graphql schema file with queries, mutations, subscriptions, types. Optionally publish via Apollo Federation / Schema Registry. schema.graphql
gRPC Protocol Buffers (.proto). Use proto3. The .proto is the contract; everything else (clients, servers, docs) is generated from it. service.proto
Async / event-driven (SQS, Kinesis, MSK / Kafka, EventBridge, SNS, RabbitMQ) AsyncAPI 3.x for the channel-and-operation level (the equivalent of OpenAPI for async). For the payload schema itself, pair with JSON Schema, Avro, or Protobuf depending on your serializer. EventBridge: also publish the event schema in the EventBridge Schema Registry. asyncapi.yaml + schemas/payment-requested.avsc
Data contracts (warehouse tables, lakehouse, topics, file formats consumed by downstream pipelines) Open Data Contract Standard (ODCS) when available — the emerging standard for producer ↔ consumer agreements on data products. Otherwise use the schema-language native to the store: dbt contracts for warehouse tables, Iceberg / Delta schema for lakehouse, Avro / Protobuf / JSON Schema for topics. data-contract.yaml (ODCS), model.yml (dbt)
MCP tool surface MCP server manifest — the tool definitions exposed by the server (name, parameters, return shape, side-effect declaration, JSON Schema for arguments). mcp-tools.json
AI agent tool definitions Agent tool spec — provider-native (Anthropic tool use, OpenAI tools, Bedrock agent action groups). Underlying input shape is JSON Schema. tools.json
Webhooks (outbound events you publish to subscribers) AsyncAPI (treats publisher-to-subscriber as first-class) or OpenAPI if you describe the receiver-side endpoint contract. JSON Schema for the payload. webhooks.asyncapi.yaml
CLI public surface Commands, flags, exit codes, output schemas (JSON output: JSON Schema). No single industry standard — document explicitly. cli-contract.md + output-schemas/
SDK public surface Language-native interface definitions (Java interfaces, TypeScript .d.ts, Python .pyi). Generate from the underlying API standard when possible (OpenAPI / Smithy / Proto). generated from upstream contract

Read the full file on GitHub · 393 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 393 lines · 42 tokens per session scan A 2ea45e2aa22a

Subscribe to this mod's changes

Contract-First API Design is a skill published in the GitHub repository robisson/build-like-amazon-agent-skills (14 stars, last pushed 3mo ago), licensed MIT. It adds 42 tokens to every session and 4,704 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

claude-md-improver

Audit and improve CLAUDE.md files in repositories. Use when user asks to check, audit, update, improve, or fix CLAUDE.md files. Scans for all CLAUDE.md files, evaluates quality against templates, outputs quality report, then makes targeted updates. Also use when the user mentions "CLAUDE.md maintenance" or "project…

anthropics/claude-plugins-official · 82 tokens

agent-platform-rag-engine-management

Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…

google/skills · 85 tokens

gke-workload-security

Audits, configures, and hardens workload-level security controls for Google Kubernetes Engine (GKE) applications and namespaces. Covers running cluster security audits (auditcluster.sh), configuring Workload Identity Federation (impersonation, KSA/GSA binding, and pod setup), enforcing Network Policies (default-deny…

google/skills · 181 tokens

gke-reliability

Improves GKE workload reliability, using PDBs, health probes, and topology spread constraints. Use when configuring GKE workload reliability, setting up PDBs, or configuring GKE health probes (liveness, readiness, startup). Don't use for disaster recovery setup or full cluster backups (use gke-backup-dr instead).

google/skills · 73 tokens

agent-platform-model-registry

Agent Platform Model Registry Management. Use when you need to upload, list, describe, update, or delete machine learning models (and their versions) in the Agent Platform Model Registry. Don't use for model training, model deployment to endpoints, or managing non-Agent Platform models.

google/skills · 60 tokens

google-cloud-solution-agentic-analytics-spark-knowledge-catalog

Discovers requirements and generates guidance to design and deploy a governed, secure agentic-analytics solution for data that's distributed across Google Cloud, other cloud providers, or on-premises. Data that's outside Google Cloud (such as data from Databricks, Snowflake, Salesforce, SAP, or Oracle systems) is…

google/skills · 138 tokens