Index of every page on this site: llms.txt
All skills
gitbookio avatar

/build-integration

@4c6497e
by GitBookgitbookio/gitbook-skills27 stars
7
Run it yourself

Build, 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'.

Use this Skill: https://skilld.dev/gh/gitbookio/gitbook-skills/build-integration

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesmanifest.md

≈2.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

gitbook-manifest.yaml reference

The manifest defines the integration's identity, permissions, editor blocks, installer-facing configuration, and secrets. It's generated by gitbook integration new and read by gitbook integration publish.

Required fields: name, title, description, organization, visibility, scopes, script (script is required to publish).

Identity fields

name: acme-changelog          # globally unique across ALL GitBook integrations
title: Acme Changelog         # display name
description: Post changelog updates into your docs.   # short, one line
organization: <org_id>        # org id or subdomain that owns the integration
script: ./src/index.tsx       # entry file; must default-export createIntegration()

summary is an optional longer Markdown description shown on the installation page, limited to 2048 characters.

Visibility

Value Meaning
private Default. Only members of the owning organization can install.
unlisted Any org can install, but only via the shared install link.
public Any org can install; required for marketplace submission (separate review process).

Scopes

Request only what the code uses — installers see the list.

scopes:
    # Spaces
    - space:content:read      # read space content
    - space:content:write     # write space content
    - space:metadata:read
    - space:metadata:write
    - space:git:sync          # manage Git Sync within a space
    # Sites
    - site:metadata:read
    - site:views:read         # site analytics
    - site:visitor:auth       # authenticated-access workflows
    - site:adaptive:read      # read Adaptive Content claims
    - site:adaptive:write     # write Adaptive Content claims
    # OpenAPI
    - openapi:read
    - openapi:write
    # Conversations
    - conversations:ingest

site:script:inject and site:script:cookies appear in GitBook-owned integrations but are internal-only — third-party integrations cannot inject JavaScript into sites. Don't request them and don't design around them.

Events may require matching scopes (e.g. space_content_updated needs space content/metadata read access).

Blocks

Declares custom blocks so they appear in the editor's insert palette (⌘ + /). Each id must match a componentId in the code.

blocks:
  - id: example-block
    title: Example Block
    description: An example block for a GitBook integration

Optional per-block keys:

  • urlUnfurl — list of URL prefixes this block unfurls when pasted into the editor (pairs with the @link.unfurl action; see contentkit.md).

  • markdown — serialize the block as a Markdown code-block instead of an opaque node:

    blocks:
        - id: block-name
          title: My custom block
          markdown:
            codeblock: blocksyntax   # the code fence language
            body: content            # which prop becomes the fence body

    A block with props { "content": "something", "propA": "A" } serializes as:

    ```blocksyntax propA="A"
    something
    ```

    This is how the native Mermaid block works — use it when block content should survive round-trips through Git Sync as readable Markdown.

Marketplace/installation-page presentation

categories:            # any of: analytics, collaboration, content, marketing, authenticated-access, other
    - content
icon: ./assets/icon.png              # local path, shipped with the integration
previewImages:                       # recommended 1600×800 (2:1)
    - ./assets/preview.png
externalLinks:
    - label: Documentation
      url: https://example.com/docs

Configurations (installer-facing settings form)

configurations.account renders at org-installation level; configurations.site renders per site/space installation. Each takes properties (the form fields) and an optional required list. Values entered by the installer surface at runtime in context.environment (installation configuration object).

Property types:

configurations:
    account:
        properties:
            oauth_credentials:            # button — the OAuth entry point
                type: button
                title: Connection
                description: Authorization between my app and GitBook.
                button_text: Authorize
                callback_url: /oauth      # route handled by createOAuthHandler in fetch
            api_region:                   # string with fixed choices
                type: string
                title: Region
                enum: [us, eu]
            default_channel:              # string with dynamic choices
                type: string
                title: Default Channel
                completion_url: /channels # integration endpoint returning options
        required:
            - oauth_credentials
    site:
        properties:
            notify_content_update:
                type: boolean
                title: Notify Content Update
                default: true
            max_items:
                type: number
                title: Max items
                default: 5
  • string — free text; enum turns it into a fixed dropdown; completion_url fetches dropdown options from an endpoint on the integration.
  • number, boolean — plain inputs; support default.
  • button — for OAuth or other callback flows; button_text + callback_url.

Installation & configuration flow

installation_setup fires when the integration is first installed and again every time the installer edits a configuration property. The installation's status stays incomplete until the configuration validates against the schema, then becomes active. Check environment.installation.status !== 'active' to detect unfinished setup — don't assume configuration exists in event handlers that can fire before setup completes.

Secrets

Runtime secrets (API keys, OAuth client credentials) are declared with environment indirection — never literal values in the manifest:

secrets:
    CLIENT_ID: ${{ env.CLIENT_ID }}
    CLIENT_SECRET: ${{ env.CLIENT_SECRET }}

Env vars are not loaded into the manifest automatically; wrap the CLI with dotenv-cli so .env is visible at publish time, e.g. in package.json:

{ "scripts": { "publish": "dotenv -- gitbook integration publish" } }

At runtime the values appear as context.environment.secrets.CLIENT_ID.

CLI reference

Command What it does
gitbook auth --token <token> Authenticate with a personal access token (from https://app.gitbook.com/account/developer); prompts if --token is omitted. Works in CI, SSH and agent sandboxes. Required for publishing/unpublishing integrations. A GITBOOK_TOKEN env var is also honoured.
gitbook login Browser (OAuth) sign-in. Needs a localhost callback, so it doesn't work in CI/SSH/sandboxes, and it can't publish or unpublish integrations. If you used it, run gitbook logout before gitbook auth.
gitbook integration new [dir] Scaffold a new integration; prompts for name, title, organization, scopes.
gitbook integration check [file] Check the integration build.
gitbook integration publish [file] Publish a new version of the integration defined by the manifest (-o/--organization to pick the org); prints the install link.
gitbook integration dev [file] Start the local dev proxy — routes the installed integration's traffic to your machine. Requires the integration to be published and installed somewhere first.
gitbook integration tail Fetch and print the integration's execution logs.
gitbook integration unpublish [integration] Remove the integration from the platform (requires a token login).
gitbook whoami Show the authenticated user.
gitbook help Command help.
gitbook openapi publish <file-or-url> --spec <name> --organization <org_id> Publish/update an OpenAPI spec (adjacent tooling, not integration-specific).

Requires Node v18+. Install with npm install @gitbook/cli -g. The old top-level gitbook new, publish, dev and unpublish still work as hidden aliases but print a deprecation warning. gitbook integrations (plural) is the raw API group (list, get, installations, events, etc.), not the authoring group. Authenticate with gitbook auth --token <token> (or GITBOOK_TOKEN), not gitbook login; browser sessions can't publish integrations.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alertstoday3 checks · Risk SAFE
  • Gen Agent Trust Hub4d

    This skill provides developer documentation for building GitBook integrations using official vendor tools and libraries. It follows security best practices for secret management and does not contain malicious instructions.

  • Sockettoday

    No alerts

  • Snyk4d

    Risk: LOW · No issues

Signed by skilld at 4c6497e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 days ago.

Activeupdated 5 days ago
metadata
{
  "version": "1.0"
}

README badge

README badge for gitbookio/gitbook-skills/build-integration