Agent skill

Generating API Contracts

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Generate API contracts and OpenAPI specifications from code or design documents.

MITAuto-check passedBackend & APIs

Install Generating API Contracts

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-api-contracts -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace generating-api-contracts --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/generating-api-contracts .claude/skills/generating-api-contracts && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
generating-api-contracts
GitHub stars
2.8k
Token cost
~1.3k tokens
SKILL.md length
541 words
Files
5 (incl. scripts, references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Generate API contracts and OpenAPI specifications from code or design documents.

  • Works in 8 steps: Scan existing route handlers and… → Generate OpenAPI 3.0 specification from… → Define request schemas with field-level… → …
  • Documenting API contracts and specifications
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 3 more sections
  • Runs Shell scripts from its folder

What it does

Generating API Contracts is an agent skill from jeremylongshore/tons-of-skills-marketplace. Generate API contracts and OpenAPI specifications from code or design documents. Use when documenting API contracts and specifications. Trigger with phrases like "generate API contract", "create OpenAPI spec", or "document API contract".

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `references/errors.md`, `references/examples.md` and `references/implementation.md`). Compatibility notes: Designed for Claude Code

It sits in Backend & APIs, covering API design and OpenAPI specifications. It works with OpenAPI. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Documenting API contracts and specifications
  • With phrases like generate API contract
  • Create OpenAPI spec
  • Document API contract

Example prompts

  • “generate API contract”
  • “create OpenAPI spec”
  • “document API contract”
  • “/generating-api-contracts”

Requirements

  • A Bash shell
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Grep, Glob, Bash(api:contract-*)

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  1. Scan existing route handlers and controller files using Grep and Read to extract all endpoint paths, HTTP methods, request parameter…
  2. Generate OpenAPI 3.0 specification from the extracted data, including info (title, version, description), servers (environment URLs)…
  3. Define request schemas with field-level constraints: type, format, required, minimum/maximum, pattern (regex), enum, and example values…
  4. Document all response status codes per endpoint with separate schemas: 200/201 for success, 400 for validation errors (with field-level…
  5. Add security scheme definitions (bearerAuth, apiKey, oauth2) and apply them to appropriate operations using the security field.
  6. Create Pact consumer contract tests that capture expected interactions from the API consumer perspective, defining expected…
  7. Set up provider verification that replays Pact interactions against the actual API implementation, verifying the provider satisfies all…
  8. Generate contract artifacts: OpenAPI spec file, Postman collection, and consumer contract (Pact JSON), all versioned alongside the API…

What it can do on your machine

Read from SKILL.md and the folder at commit 80f86df. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Grep
    • Glob
    • Bash(api:contract-*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Shell), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • spec.openapis.org
    • pact.io
    • editor.swagger.io
    • dredd.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Generating API Contracts loads about 1.3k tokens when it runs, and up to ~3.4k if it reads all its reference files. Until then it costs about 66 tokens; SKILL.md has 541 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~66
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 80f86df, republished under its MIT licence (© jeremylongshore). 541 words, ~1,324 tokens.

Download SKILL.mdSave it as .claude/skills/generating-api-contracts/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
generating-api-contracts
description
Generate API contracts and OpenAPI specifications from code or design documents. Use when documenting API contracts and specifications. Trigger with phrases like "generate API contract", "create OpenAPI spec", or "document API contract".
allowed-tools
Read, Write, Edit, Grep, Glob, Bash(api:contract-*)
compatibility
Designed for Claude Code
version
1.25.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
api, api-contracts

Generating API Contracts

Overview

Generate OpenAPI 3.0/3.1 specifications and consumer-driven contract tests from existing API implementations, design documents, or database schemas. Produce machine-readable contracts that serve as the single source of truth for code generation, documentation, testing, and gateway configuration, with Pact integration for consumer-driven contract verification.

Prerequisites

  • API implementation with route definitions and handler logic, or design requirements document
  • OpenAPI authoring tool: Swagger Editor, Stoplight Studio, or IDE with OpenAPI extension
  • Consumer-driven contract framework: Pact (polyglot), Spring Cloud Contract (Java), or Dredd (generic)
  • Schema validation tool: Spectral for OpenAPI linting
  • Version control for contract files with diff-based review process

Instructions

  1. Scan existing route handlers and controller files using Grep and Read to extract all endpoint paths, HTTP methods, request parameter names/types, and response body shapes.
  2. Generate OpenAPI 3.0 specification from the extracted data, including info (title, version, description), servers (environment URLs), paths (operations), and components (reusable schemas).
  3. Define request schemas with field-level constraints: type, format, required, minimum/maximum, pattern (regex), enum, and example values for every property.
  4. Document all response status codes per endpoint with separate schemas: 200/201 for success, 400 for validation errors (with field-level error array), 401/403 for auth failures, and 404/500.
  5. Add security scheme definitions (bearerAuth, apiKey, oauth2) and apply them to appropriate operations using the security field.
  6. Create Pact consumer contract tests that capture expected interactions from the API consumer perspective, defining expected request/response pairs per endpoint.
  7. Set up provider verification that replays Pact interactions against the actual API implementation, verifying the provider satisfies all consumer expectations.
  8. Generate contract artifacts: OpenAPI spec file, Postman collection, and consumer contract (Pact JSON), all versioned alongside the API source code.

See ${CLAUDE_SKILL_DIR}/references/implementation.md for the full implementation guide.

Output

  • ${CLAUDE_SKILL_DIR}/openapi.yaml - Complete OpenAPI 3.0/3.1 specification
  • ${CLAUDE_SKILL_DIR}/contracts/pact/ - Consumer-driven contract definitions (Pact JSON)
  • ${CLAUDE_SKILL_DIR}/contracts/postman/ - Generated Postman collection for API testing
  • ${CLAUDE_SKILL_DIR}/tests/contract/consumer/ - Consumer contract test implementations
  • ${CLAUDE_SKILL_DIR}/tests/contract/provider/ - Provider verification test suite
  • ${CLAUDE_SKILL_DIR}/scripts/generate-contract.sh - Contract generation automation script
Show full SKILL.md (221 more words)Show less

Error Handling

ErrorCauseSolution
Spec-code divergenceAPI implementation changed without updating the OpenAPI specAdd CI check that generates spec from code and diffs against committed spec
Pact verification failureProvider response does not match consumer expectationReview consumer contract for correctness; update provider if contract is valid
Missing operation IDEndpoint has no operationId, preventing code generationGenerate deterministic operation IDs from method + path (e.g., getUsers, createUser)
Circular schema referenceComponents reference each other creating infinite recursionBreak cycles with allOf composition or introduce intermediate types
Example/schema mismatchExample values do not validate against their own schemaAuto-validate all examples during spec generation; reject mismatched examples

Refer to ${CLAUDE_SKILL_DIR}/references/errors.md for comprehensive error patterns.

Examples

Code-first OpenAPI generation: Scan Express route decorators and Zod validation schemas to auto-generate a complete OpenAPI 3.1 spec with accurate request/response schemas, examples, and descriptions.

Consumer-driven contract testing: Frontend team publishes Pact contracts defining the API interactions they depend on; backend CI verifies every contract on each deployment, preventing breaking changes.

Design-first workflow: Author OpenAPI spec in Stoplight Studio, generate server stubs and client SDKs from the spec, then implement business logic in the stubs -- spec stays as the single source of truth.

See ${CLAUDE_SKILL_DIR}/references/examples.md for additional examples.

Resources

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/.curated/generating-api-contracts of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/errors.md
  • references/examples.md
  • references/implementation.md
  • scripts/generate-contract.sh

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Generating API Contracts next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Generating API Contracts compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Generating API Contracts this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.3kAutomated safety check: PassMIT
API DesignerJeffallan/claude-skills12k1 repos~2kAutomated safety check: PassMIT
Old Coder API DesignAmazingAng/old-coder749—~3.4kAutomated safety check: PassMIT
API Surface Reviewpolarsource/polar10k—~1.3kAutomated safety check: PassMIT
API ContractChenyCHENYU/Robot_Admin1k—~1.9kAutomated safety check: PassMIT
API Designyonatangross/orchestkit290—~2.9kAutomated safety check: PassMIT

Similar skills

  • API Designer

    Jeffallan/claude-skills

    Designs REST and GraphQL APIs from resource modeling to an OpenAPI 3.1 contract, with versioning, pagination and RFC 7807 error handling.

    12k GitHub starsUsed in 1 repo~2k tokens
    Backend & APIsAuto-check passed
  • Old Coder API Design

    AmazingAng/old-coder

    Reviews or designs an HTTP/JSON API's endpoints, auth, pagination, versioning and deprecations, guarding against inventing a bespoke interface or silently breaking consumers.

    749 GitHub stars~3.4k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • API Surface Review

    polarsource/polar

    Review changes to Polar's API contract — Pydantic schemas, FastAPI endpoints, OpenAPI output and the generated SDKs.

    10k GitHub stars~1.3k tokensUpdated today
    Backend & APIsAuto-check passed
  • API Contract

    ChenyCHENYU/Robot_Admin

    A skill your agent uses when: generating TypeScript API layer (type definitions + request functions) from page-spec JSON or Swagger/OpenAPI docs.

    1k GitHub stars~1.9k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • API Design

    yonatangross/orchestkit

    API contract design for REST and GraphQL, covering resource shape, URL and header versioning with deprecation windows, RFC 9457 Problem Details error handling, and OpenAPI specs.

    290 GitHub stars~2.9k tokensUpdated today
    Backend & APIsAuto-check passed
  • Create, validate and maintain OpenAPI 3.1 specs for REST APIs, whether designed first or generated from existing code, and use them for docs and client SDKs.

    40k GitHub starsUsed in 9 repos~511 tokens
    Backend & APIsAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Generating API Contracts

What does Generating API Contracts do?

Generate API contracts and OpenAPI specifications from code or design documents. Generating API Contracts is an agent skill from jeremylongshore/tons-of-skills-marketplace. Generate API contracts and OpenAPI specifications from code or design documents.

When should I use Generating API Contracts?

Generating API Contracts fits situations like: documenting API contracts and specifications; with phrases like generate API contract; create OpenAPI spec; document API contract.

How do I install Generating API Contracts in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-api-contracts -a claude-code`. Or copy the skill folder (skills/.curated/generating-api-contracts in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/generating-api-contracts in your project. Claude Code loads it when a task matches its description.

How do I install Generating API Contracts in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-api-contracts -a codex`. Or copy the skill folder (skills/.curated/generating-api-contracts in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/generating-api-contracts in your project. Codex loads it when a task matches its description.

Can I use Generating API Contracts in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-api-contracts -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/generating-api-contracts, .gemini/skills/generating-api-contracts, .github/skills/generating-api-contracts and .opencode/skills/generating-api-contracts in your project.

What does Generating API Contracts need to run?

Going by SKILL.md and its folder, Generating API Contracts needs a shell for the scripts in its folder. Our summary lists: A Bash shell. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(api:contract-*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Generating API Contracts access the network?

SKILL.md names 4 domains. As links in the text: spec.openapis.org, pact.io, editor.swagger.io and dredd.org. This is read from the text; nothing was executed.

Is Generating API Contracts safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Generating API Contracts use?

Generating API Contracts is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Generating API Contracts use?

About 1.3k tokens (SKILL.md is roughly 5.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2k tokens, read only when the agent opens those files.

What are the alternatives to Generating API Contracts?

Skills that share tags, products or a category with Generating API Contracts: API Designer (Jeffallan/claude-skills, 12k stars), Old Coder API Design (AmazingAng/old-coder, 749 stars), API Surface Review (polarsource/polar, 10k stars) and API Contract (ChenyCHENYU/Robot_Admin, 1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Generating API Contracts?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.