/gitbook:write-openapifrom gitbook
Authors, configures, structures, and troubleshoots OpenAPI/Swagger API reference documentation in GitBook. Handles spec import, interactive Test it runner setup, x-* extension customization, and CI/CD automation.
Ships in gitbook. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
GitBook turns an OpenAPI document into interactive, testable API reference blocks. You give it a spec (as JSON or YAML), and it renders endpoints, parameters, schemas, auth, and an in-page request runner. Most of the customization happens inside the spec itself through x-* extensions, not in the GitBook UI, so the bulk of any task here is editing OpenAPI YAML correctly.
This skill covers the full surface: getting a spec into GitBook, generating reference pages, structuring navigation, making the "Test it" runner work, controlling how operations and schemas display, and automating updates from CI/CD.
Most of this skill — editing the OpenAPI YAML/JSON itself — is transport-agnostic. But getting a spec into GitBook, or generating/inserting reference pages, does touch GitBook, and there's more than one way to do that: GitBook's MCP server and the REST API. Check what's actually available in the current session and prefer MCP first: if GitBook MCP tools are already connected, use them for anything they cover (publishing/updating a spec, generating reference pages) instead of making direct API calls. Don't run a detection script for this — you already know your own available tools/MCP connections; just use that awareness.
The steps below are described as outcomes ("add the spec", "generate the reference pages") rather than tied to one transport, so they apply whichever you use. If GitBook MCP tools are connected, call those directly — their own schemas describe their parameters. If you're on the REST API path instead, the exact endpoints and request bodies are in "Add or update a specification" below.
invoke_operation rather than named tools. If it isn't connected yet and the task is substantial enough to benefit (publishing a new spec, generating a full reference — not a one-off tweak), offer to set it up: claude mcp add --transport http gitbook-mcp https://mcp.gitbook.com/mcp (then /mcp to sign in with OAuth). Codex equivalent: codex mcp add gitbook-mcp --url https://mcp.gitbook.com/mcp. Note: this is a different server from GitBook's separate, read-only "published docs" MCP, which only exposes already-published content.https://api.gitbook.com/v1) — the fallback when MCP isn't connected, or for anything MCP doesn't cover. It requires a GitBook personal access token, created at https://app.gitbook.com/account/developer (see https://gitbook.com/docs/developers/gitbook-api/authentication).Never write a token to a file, never echo it back in a response, never commit it.
The GitBook CLI's gitbook openapi publish command (see "Add or update a specification" below) reaches the same underlying capability as the API and MCP — it's a convenience wrapper, not a separate feature set, and also requires a personal access token.
These shape almost every decision, so internalize them before editing anything.
parent tag property requires OpenAPI 3.2+ (use x-parent on 3.0.x and 3.1.x). Always check the spec's openapi:/swagger: version before reaching for a version-gated feature.x-* extensions are namespaced and safe to keep in a shared spec. Tools that do not understand a given extension ignore it, so a spec instrumented for GitBook still validates and works elsewhere.Match the task to the right section. For the deeper reference material, two files live alongside this one:
x-* extension, with full YAML for each: read references/extensions.md.references/test-it-setup.md.| Task | Go to |
|---|---|
| Get a spec into GitBook, or update one | "Add or update a specification" |
| Generate reference pages, or drop a single endpoint/schema into a page | "Insert an API reference" |
| Split, order, nest, title, or icon your pages | "Structure the reference" |
| Make "Test it" work, fix CORS, configure auth | "Configure the Test it runner" + references/test-it-setup.md |
| Mark an endpoint experimental, deprecated, or hidden | "Manage operation lifecycle" |
| Look up the exact name/scope of an extension | "Extensions cheat-sheet" + references/extensions.md |
| Auto-publish the spec from a pipeline | "Automate with CI/CD" |
A spec must exist in the organization before any block or page can reference it. Adding and updating are the same underlying operation on every transport — pick whichever you have per "How you can talk to GitBook" above. Whichever you use, give the spec a name/slug up front: it's how you reference it later and how you tell multiple specs apart.
GitBook MCP — if connected, there is no dedicated OpenAPI tool: find the operation with search, inspect it with describe_operation, and run it with invoke_operation (createOpenAPISpec to create, createOrUpdateOpenAPISpecBySlug to create-or-replace by slug). Both take the source as a URL or as the spec text.
REST API — the same operations. Create with POST /orgs/{organizationId}/openapi and a URL source:
{"slug": "<spec-name>", "source": {"url": "<hosted-url>"}}
or with the spec text (there is no multipart file upload; source is either {"url": ...} or {"text": ...}):
{"slug": "<spec-name>", "source": {"text": "<contents of openapi.yaml>"}}
Create or replace a spec by slug with PUT /v1/orgs/{orgId}/openapi/{specSlug} and body {"source": {"url": ...}} or {"source": {"text": ...}} (createOrUpdateOpenAPISpecBySlug). Don't use PATCH for this: PATCH .../openapi/{specSlug} only changes the spec's visibility (updateOpenAPISpecBySlug).
GitBook CLI — a thin wrapper over the same API call, useful in scripts and pipelines (same command adds or updates; running it against a URL also forces a refresh):
gitbook openapi publish --spec <spec-name> --organization <organization-id> <path-or-url>
For pipeline automation see "Automate with CI/CD". CLI details: https://gitbook.com/docs/docs-as-code/gitbook-cli
GitBook app UI — open the OpenAPI section in the sidebar, click Add specification, name it, then choose to upload a file or enter a hosted URL. Updating depends on the source: URL sources check every 6 hours automatically (click Check for updates to pull immediately; switch File to URL via Edit in the breadcrumb actions menu); file sources need Update to upload a new version.
Once the spec exists, surface it in the docs one of two ways.
Generate a full set of pages (recommended for a complete reference). In the target space's table of contents, click Add new... at the bottom, then OpenAPI Reference, pick the spec, and insert. GitBook creates one page per tag in the spec (see "Structure the reference"), and optionally a models page listing every schema. These pages keep updating whenever the spec updates.
Insert a single operation or schema into an existing page. Press /, search for OpenAPI, pick the spec, choose Continue, then select the specific operations and/or schemas to embed.
Block syntax. When writing GitBook markdown directly, an OpenAPI operation block looks like this (the inner line repeats the source):
{% openapi src="https://petstore3.swagger.io/api/v3/openapi.json" path="/pet" method="post" %}
https://petstore3.swagger.io/api/v3/openapi.json
{% endopenapi %}
To highlight one or more schemas inline (for example inside a tag description), use the schemas block:
{% openapi-schemas spec="petstore" schemas="Pet" grouped="false" %}
The Pet object
{% endopenapi-schemas %}
GitBook builds navigation from the spec's tags, so structuring the reference is mostly structuring tags. (These are OpenAPI spec tags; they are unrelated to GitBook's space content tags used on pages and update blocks.) Full YAML for every extension named here is in references/extensions.md.
Split operations across pages: give operations the same tag, and each tag becomes its own page.
paths:
/pet:
put:
tags:
- pet
summary: Update an existing pet.
operationId: updatePet
Order pages: page order follows the order of entries in the top-level tags array.
tags:
- name: pet
- name: store
- name: user
Nest pages into groups: use parent (OpenAPI 3.2+) or x-parent (3.0.x/3.1.x) to point a tag at its parent tag.
tags:
- name: everything
- name: pet
x-parent: everything
- name: store
x-parent: everything
If a parent page has no description, GitBook automatically renders a card-based layout linking its sub-pages.
Add titles, icons, and descriptions per page via tag-level extensions. Icons accept any Font Awesome name (https://fontawesome.com/search).
tags:
- name: pet
x-page-title: Pet # title in the table of contents and page header
x-page-icon: dog # icon in the ToC and next to the title
x-page-description: Pets are amazing! # shown just above the title
description: Everything about your Pets # the page body
Write rich descriptions. Tag description fields accept GitBook markdown, including advanced blocks such as {% tabs %}, so a page intro can be far more than plain text.
Document webhooks (OpenAPI 3.1) with a top-level webhooks field that mirrors paths:
openapi: 3.1.0
webhooks:
newPet:
post:
summary: New pet event
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"200":
description: Received successfully
The interactive runner only works as well as the spec describes it. The runner targets the URLs in the servers array and can only present auth that the spec declares under components.securitySchemes. For anything non-trivial (Bearer/JWT, API key, OAuth2, multiple or templated server URLs, per-operation overrides), read references/test-it-setup.md, which has copy-paste YAML for each pattern.
Two quick decisions you will hit constantly:
https://your-site.gitbook.io or your custom domain). Public, credential-free endpoints can return Access-Control-Allow-Origin: *.x-enable-proxy: true (at the root for the whole spec, or on a single operation; the operation value wins). The proxy forwards all HTTP methods, headers, cookies, and bodies, but only to URLs listed in servers, so make sure every base URL you want to test is in that array. Details in references/test-it-setup.md.To remove the runner from an endpoint (or the whole spec), set x-hideTryItPanel: true.
Common when endpoints are not production-ready or are being phased out. All of these are operation-level unless noted.
x-stability: experimental (also alpha or beta).deprecated: true. Deprecated endpoints show a deprecation warning on the published site.x-deprecated-sunset: 2030-12-05 (ISO 8601, YYYY-MM-DD).x-internal: true (or its alias x-gitbook-ignore: true).x-hideSample: true on that response object (for example under responses.200).paths:
/pet:
put:
operationId: updatePet
x-stability: experimental
deprecated: true
x-deprecated-sunset: 2030-12-05
Every GitBook-supported extension at a glance. For the full YAML example of any row, open references/extensions.md.
| Extension | Purpose | Where it goes |
|---|---|---|
x-page-title / x-displayName | Display name of a tag (navigation + page title) | tag |
x-page-description | Short description shown above the page title | tag |
x-page-icon | Font Awesome icon for the page | tag |
parent / x-parent | Nest a tag under a parent tag (parent = 3.2+, x-parent = 3.0.x/3.1.x) | tag |
x-hideTryItPanel | Show or hide the "Test it" runner | root or operation |
x-expandAllResponses | Expand all response sections by default | root or operation |
x-expandAllModelSections | Expand all model/schema sections by default | root or operation |
x-enable-proxy | Route "Test it" requests through GitBook's proxy | root or operation (operation wins) |
x-codeSamples | Provide custom code samples (lang, label, source) | operation |
x-enumDescriptions | Per-value descriptions for an enum, rendered as a table | schema |
x-internal / x-gitbook-ignore | Hide an endpoint from the reference | operation |
x-stability | Mark experimental, alpha, or beta | operation |
deprecated | Mark an operation deprecated | operation |
x-deprecated-sunset | Sunset date for a deprecated operation (YYYY-MM-DD) | operation |
x-hideSample | Hide a single response sample | response object |
x-gitbook-prefix | Custom auth prefix (e.g. Token); not allowed on http schemes | security scheme |
x-gitbook-token-placeholder | Default token placeholder shown in the runner | security scheme |
Two display extensions worth highlighting because they take a root default that operations can opt out of:
openapi: '3.0'
x-expandAllResponses: true # default for every operation
x-expandAllModelSections: true
paths:
/pets:
get:
x-expandAllResponses: false # opt this one out
Custom code samples replace GitBook's auto-generated snippets and accept multiple languages:
paths:
/users:
get:
summary: Retrieve users
x-codeSamples:
- lang: JavaScript
label: Node SDK
source: |
import { createAPIClient } from 'my-api-sdk';
const client = createAPIClient({ apiKey: 'my-api-key' });
client.users.list().then(console.log);
- lang: cURL
label: CLI
source: |
curl -L -H 'Authorization: Bearer <token>' \
'https://api.example.com/v1/users'
Publish the spec from any pipeline with the GitBook CLI: run gitbook openapi publish --spec <spec-name> --organization <organization-id> against a file (generated during the build) or a URL (forces a refresh after a release). The pipeline needs a GitBook personal access token stored as one of its secrets. gitbook login opens a browser, so it doesn't work in CI, over SSH, or in agent sandboxes.
For the token setup and a complete GitHub Actions workflow, point the user to GitBook's guide: https://gitbook.com/docs/api-references/guides/support-for-ci-cd-with-api-blocks.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
gitbook, openapi, swagger, api-documentation, test-it-runner
npx claudepluginhub gitbookio/gitbook-skills --plugin gitbook7 skills in this plugin
/build-integrationBuild, develop, and publish GitBook integrations — apps that run inside GitBook to add custom blocks, react to events, connect external services via OAuth, and extend the editor. Use this skill whenever a task involves the GitBook integrations platform: scaffolding an integration with the GitBook CLI (`gitbook integration new`), writing or editing an integration's code (`createIntegration`, `createComponent`, ContentKit TSX), configuring `gitbook-manifest.yaml` (scopes, blocks, configurations, secrets), building custom editor blocks or link unfurlers, handling GitBook events like `space_content_updated`, setting up an integration's OAuth flow, running `gitbook integration dev`, or publishing an integration (private/unlisted/public, marketplace submission). Trigger this even if the user just says they want to 'build an app for GitBook', 'add a custom block', or 'connect <some tool> to GitBook' without saying the word 'integration'./configure-siteCreate and maintain GitBook documentation sites end-to-end — design structure from source content, scaffold a Git monorepo, set up the GitHub/GitLab remote, drive the GitBook API (REST or MCP) to create the site/sections/spaces, apply branding, and hand off the one UI step (Git Sync) that GitBook does not expose programmatically. Prefer site-level Git Sync (gitbook-docs.yaml mapping every space) over per-space sync unless a space needs its own repo or branch. Use when spinning up a new docs site, restructuring or extending one, linking a site or spaces to Git, changing branding (logo, colors, fonts, header/footer), or programmatically managing spaces, sections, or site-spaces. Defers page authoring to the companion `write-docs` skill./cr-createDrive an end-to-end GitBook docs review flow from the agent through the GitBook MCP server — create a change request, push content (update an existing page AND create a new page), request reviewers, notify Slack, then pull review comments back in, fix them, re-push, and resolve. This is the authoring-side companion to cr-review (the reviewer side over the same operations). Use this whenever someone wants to run a "docs review in GitBook" loop from the terminal/agent, mentions creating a change request via the API, pushing content into a CR, "pull in the latest comments and fix them," requesting review on docs, or showing engineers how to collaborate on GitBook docs from Claude + Slack without leaving the agent./cr-reviewReview GitBook change requests from the agent through the GitBook MCP server — the reviewer-side companion to cr-create (the authoring side over the same operations). Discover the change requests that need review (filter by who opened them, by space, or across a whole org), get the GitBook app link to review the diff, summarize what actually changed in a CR, then leave comments and optionally submit a review verdict (approve / request changes). Use this whenever someone wants to review docs change requests from the agent, asks "what CRs are open / waiting on me / opened by <person>", "show me the change requests in <space>/<org>", "summarize what changed in this CR", "review this change request", "leave a comment on a CR", or "approve / request changes on a CR". For the authoring side (create a CR, push content, request reviewers, fix comments), use cr-create instead./docs-change-radarAutocomplete for a docs change. Name one thing that changed, or point it at a ticket, pull request, thread, pasted context, or an existing docs draft, and it finds everything else in the GitBook site that has to change with it, then makes those edits. Works with the GitBook MCP server and GitHub. Sweeps every page, reusable block, variable, and screenshot the change affects, opens with a TL;DR of the pages affected, proposes each edit in the team's own style guide, drafts one pull request or change request, records follow-ups, requests reviewers, and, on a later run, merges once approved. Use whenever someone asks to document a feature, launch, fix, or change in GitBook, says 'write the docs for this', 'what else does this affect', 'what else needs updating', 'run a docs radar', or 'check for stale docs', or asks for docs from a ticket or thread, even if they name only the obvious page./write-docsWrite, author, edit, and format GitBook documentation pages in Git-synced repos, IDEs, or any text editor. Use whenever a task involves creating or editing a GitBook markdown page, writing or updating a README.md or SUMMARY.md, inserting a hint, tab, stepper, card, or other GitBook block, configuring page frontmatter or layout options, setting up variables or expressions, or formatting content for GitBook outside the GitBook UI.Other plugins' skills for the same job