/gitbook:build-integrationfrom gitbook
Scaffolds, develops, and publishes GitBook integrations: custom blocks, event handlers, OAuth flows, and editor extensions using the GitBook CLI and ContentKit TSX.
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.
A skill for building integrations on GitBook's developer platform: apps that run inside GitBook itself. An integration can render custom blocks in the editor, show configuration UI, listen to events (content updated, Git sync completed, space viewed), authenticate against external services with OAuth, and talk to anything over HTTP.
This skill covers the integration lifecycle — scaffold, code, develop, publish. For creating or restructuring the docs site an integration might be installed into, defer to configure-site; for authoring page content, defer to write-docs.
An integration is a small TypeScript app executed by GitBook's runtime — not a script injected into pages, and not code running on the user's server. Three consequences shape everything else:
render function runs server-side on every interaction and returns ContentKit markup (a JSX-like UI description). There is no client-side React tree you control, no DOM access, and UI updates flow through the action → new state → re-render loop.site:script:inject and site:script:cookies scopes you'll see in GitBook-owned integrations are internal-only. If the user's plan amounts to "add a script tag to their docs", stop and say so early — the supported paths are custom blocks, webframes, and events.gitbook integration dev routes the installed integration's traffic to your machine. You never open the dev server's port in a browser; you interact with the integration inside app.gitbook.com.gitbook integration new scaffolds this shape:
my-integration/
├── gitbook-manifest.yaml # identity, scopes, blocks, configuration schema
├── .gitbook-dev.yaml # local dev config (generated by `gitbook integration dev`)
├── package.json
└── src/
└── index.tsx # entry file — default-exports createIntegration()
The entry file (whatever script: in the manifest points to) default-exports createIntegration({ fetch, components, events }):
import { createIntegration, createComponent } from '@gitbook/runtime';
const helloBlock = createComponent({
componentId: 'hello-world', // must match a block id in the manifest
initialState: { message: 'Say hello!' },
action: async (element, action, context) => {
switch (action.action) {
case 'say':
return { state: { message: 'Hello world' } };
default:
return {};
}
},
render: async (element, context) => (
<block>
<button label={element.state.message} onPress={{ action: 'say' }} />
</block>
),
});
export default createIntegration({
components: [helloBlock],
events: {
space_content_updated: async (event, context) => {
// react to content changes
},
},
});
A custom block only appears in the editor's insert palette (⌘ + /) if it is declared in both places: createComponent in the code and a blocks: entry in the manifest whose id matches the componentId. Forgetting one half is the most common "my block doesn't show up" cause.
gitbook-manifest.yaml is the integration's identity and permission grant. Required: name (globally unique across all of GitBook — pick something namespaced like acme-changelog, not test), title, description, organization (org id or subdomain), visibility, scopes, and script. Request only the scopes the code actually uses — installers see them.
The manifest also declares blocks, installer-facing configurations (account-level and site-level property schemas rendered as a settings form), and secrets (e.g. CLIENT_ID: ${{ env.CLIENT_ID }}, loaded at publish time — use dotenv-cli so gitbook integration publish sees your .env).
Full field-by-field schema, scope list, and configuration property types: references/manifest.md. Read it whenever you're editing the manifest beyond the basics.
The loop has a non-obvious order — publish comes before local development:
npm install @gitbook/cli -g, then authenticate with gitbook auth --token <token> (or gitbook auth to be prompted). Use a token, not gitbook login: browser (OAuth) sign-in can't publish or unpublish integrations and doesn't work in CI, SSH, or agent sandboxes. If you already ran gitbook login, run gitbook logout first. The CLI also reads a GITBOOK_TOKEN environment variable. If a token needs to be pasted into the conversation, export it to the environment and never echo it back or commit it.gitbook integration new [dir] — prompts for name, title, organization, and scopes.gitbook integration publish in the project root. This registers the integration (private by default) and prints an install link.gitbook integration dev starts the proxy: all traffic for the installed integration is served from your local code instead of the published version. Interact with it in the GitBook editor, not at the server URL. UI changes need a browser refresh; disable browser caching for a smoother loop. Logs surface in the browser console or your terminal depending on where the code runs — check both before concluding logging is broken.gitbook integration publish whenever you want the hosted version updated. gitbook integration unpublish removes it. Before publishing, gitbook integration check validates the build, and gitbook integration tail prints the integration's execution logs.Note the singular/plural split: gitbook integration (singular) is the authoring group; gitbook integrations (plural) is the raw API group for listing, inspecting and installing integrations already on GitBook.
CLI command reference (including gitbook whoami and gitbook openapi publish): references/manifest.md.
Details and full tables live in references/runtime.md — read it when writing event handlers, OAuth flows, or anything touching context.environment. The essentials:
fetch handles incoming HTTP requests to the integration's public endpoint using standard Fetch API Request/Response objects. Outgoing HTTP is plain fetch too.events maps event names (installation_setup, space_installation_setup, space_view, ui_render, space_content_updated, space_visibility_updated, space_gitsync_started, space_gitsync_completed) to handlers. Some events require matching scopes.context.environment exposes apiEndpoint, apiTokens, installation info (space, status, per-installation configuration values entered by the installer), secrets, and public URLs (environment.integration.urls.publicEndpoint).button-type configuration property whose callback_url routes to a createOAuthHandler({...}) in your fetch handler, with client id/secret coming from secrets. Don't hand-roll the redirect/token exchange.context.api (an authenticated @gitbook/api client) rather than constructing your own client from raw tokens.ContentKit is the component vocabulary render can return: layout (block, vstack, hstack, divider), display (box, card, text, image, markdown), and interactive elements (button, textinput, select, switch, checkbox, radio, codeblock, webframe, modal). Interactivity model in one line: inputs bind their value to a state key; buttons dispatch actions; your action reducer returns new state; GitBook re-renders.
Read references/contentkit.md before writing any component beyond a trivial button — it has the full prop tables plus the patterns that are hard to guess: dynamic state binding for live previews, webframe postMessage communication, modals with returnValue, persisting props with @editor.node.updateProps, link unfurling via @link.unfurl + urlUnfurl manifest patterns, and markdown code-block serialization of blocks.
Visibility in the manifest controls reach:
private (default) — installable only by members of the owning org. Right for internal tools; stay here during development.unlisted — installable by any org, but only via the shared install link. Right for sharing with specific customers or beta testers.public — installable by anyone; required before submitting to the integration marketplace (which is a separate review process — see GitBook's "submit your app for review" docs).Re-run gitbook integration publish after changing visibility. Before suggesting public, sanity-check the manifest is presentable: icon, summary (Markdown, ≤2048 chars), previewImages (1600×800), categories, externalLinks.
gitbook integration new wires up the manifest, TypeScript config, and @gitbook/runtime versions correctly.blocks[].id ↔ componentId) whenever a component misbehaves.${{ env.X }} indirection, never literal values.references/manifest.md — every gitbook-manifest.yaml field, all scopes, configuration property types, secrets, CLI command reference, installation/configuration flow.references/runtime.md — createIntegration / createComponent / createOAuthHandler signatures, event catalog, context.environment shape, HTTP in and out.references/contentkit.md — full component reference with props, built-in actions, and interactivity recipes (dynamic binding, webframes, modals, unfurling, markdown serialization).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub gitbookio/gitbook-skills --plugin gitbook7 skills in this plugin
/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./write-openapiAuthor, configure, structure, and troubleshoot OpenAPI/Swagger API reference documentation in GitBook. Use this whenever a task involves a GitBook OpenAPI block or `{% openapi %}` block, adding or updating an OpenAPI/Swagger spec in GitBook (by file or URL, via the API, MCP, CLI, or app UI), generating API reference pages from a spec, configuring the interactive "Test it" runner (auth, servers, CORS, proxy), customizing pages with GitBook `x-*` extensions (icons, titles, navigation hierarchy, code samples, enum descriptions), marking operations experimental/deprecated/hidden, or automating spec updates in CI/CD. Trigger even when the user only mentions GitBook plus OpenAPI, puts an `x-` extension on a spec destined for GitBook, or asks "why isn't my spec loading" or "why doesn't Test it work", without naming this skill.Other plugins' skills for the same job