GitHub Sync

GitHub Sync keeps a DocStar collection in sync with your GitHub repository. Put OpenAPI files in api-docs/ and Markdown pages in docs/. On every push, a GitHub Action sends the changed files to DocStar. Use one folder or both.

#

Set it up

#

Step 1: Add the workflow

Run this in the root of your repository. Replace <collectionId> with your collection's ID (in the collection's URL, after /collection/), and change branch=main if you publish from another branch.

For OpenAPI files in api-docs/:

mkdir -p .github/workflows
curl --fail "https://api.docstar.io/p/generate-docstar-openapi-workflow/<collectionId>?branch=main" \
  -o .github/workflows/docstar-api-docs.yml

For Markdown pages in docs/:

mkdir -p .github/workflows
curl --fail "https://api.docstar.io/p/generate-docstar-workflow/<collectionId>?branch=main" \
  -o .github/workflows/docstar-docs.yml
#

Step 2: Add docstar.md and tell your AI assistant to read it

docstar.md holds the rules your AI coding assistant follows to keep your docs in sync with your code: the folder structure, and which endpoints to document (only the ones your users call, never private or admin ones). Download it into the root of your repository:

curl --fail "https://api.docstar.io/docstar.md" -o docstar.md

Then add this line to your assistant's instruction file. If the file does not exist yet, create it in the root of your repository.

- Whenever any endpoint is added, changed, renamed or removed, read `docstar.md` in this repo and follow it to update `api-docs/` in the same change.
AI assistant Instruction file
Codex, Cursor and most other agents AGENTS.md
Claude Code CLAUDE.md (or put @AGENTS.md in it to reuse AGENTS.md)
GitHub Copilot .github/copilot-instructions.md

If your repository has more than one of these files, add the line to each. Download docstar.md again from time to time to pick up changes.

#

Step 3: Add your API token

Create an API token in DocStar (see API Tokens). In your GitHub repository, go to Settings → Secrets and variables → Actions → New repository secret, name it DOCSTAR_API_KEY and paste the token.

#

Step 4: Commit and push

git add .github/workflows docstar.md AGENTS.md
git commit -m "Add DocStar sync"
git push origin main

Add any other instruction file you changed in Step 2 too. From now on, every push that changes api-docs/ or docs/ syncs to your collection. You can follow each run in the repository's Actions tab.

#

Which APIs to add

api-docs/ becomes public documentation, so add only the endpoints your users call.

Add Never add
Endpoints your frontend or app calls, and your public API Admin and back-office routes, cron jobs, webhooks that other services call, and service-to-service routes

NEVER add a private, internal or admin API. No exceptions. These docs are public, so anything you add is visible to every user. This bans admin and back-office routes, cron jobs, webhooks that other services call and service-to-service routes, and any internal detail in a description (secrets, internal hostnames, table or queue names, class names, security weaknesses). If you cannot confirm the frontend calls an endpoint, do not add it.

docstar.md has the same rule, so your AI assistant follows it too.

#

Describe everything

Your public docs, your MCP server and your CLI are all built from the descriptions in your files. An AI assistant decides which endpoint to call, and what to put in each field, only from what you write. A missing or vague description makes an endpoint hard to find and easy to call wrong, so every item needs a short, clear description. Never leave one empty.

Item Where to write it What to write
Module description in layout.json One or two sentences on what the module covers.
Endpoint name the operation's summary A short action, such as "Create a charge".
Endpoint the operation's description What it does, when to use it, the permissions it needs and its main errors. End with a short Body fields: / Query params: list.
Path, query and header parameters description on each item in parameters What the value is, what it changes, and where the user gets it.
Body fields description on each property in the requestBody schema The same, for every field, including fields inside nested objects and array items.
Responses description on each response code When this response is returned.
Markdown page description in the front matter A one-line summary of the page.
#

Describe every input field

Every path parameter, query parameter, header and body field needs:

  • a description that says what the field means and what it changes, in one or two sentences.

  • its type, plus format where it helps (date-time, email, uri).

  • whether it is required: required: true on a parameter, or the field listed in the schema's required array.

  • allowed values (enum), limits (minimum, maximum, maxLength) and the default, if there are any.

  • an example with a realistic value.

paths:
  /charges:
    get:
      operationId: list-charges
      summary: List charges
      description: |
        Returns the charges on your account, newest first. Needs the charges:read permission.
        Query params: status, limit.
      x-docstar-published: true
      parameters:
        - name: status
          in: query
          required: false
          description: Return only charges with this status. Leave it out to get every charge.
          schema:
            type: string
            enum: [pending, succeeded, failed]
          example: succeeded
        - name: limit
          in: query
          required: false
          description: How many charges to return in one page.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          example: 20
      responses:
        "200":
          description: The list of charges.
    post:
      operationId: create-charge
      summary: Create a charge
      description: |
        Charges a customer's saved card. Returns 402 if the card is declined.
        Body fields: amount, currency, customerId, metadata.
      x-docstar-published: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [amount, currency, customerId]
              properties:
                amount:
                  type: integer
                  description: Amount to charge in the smallest unit of the currency (paise, cents). 1000 is 10.00.
                  example: 1000
                currency:
                  type: string
                  description: Three-letter ISO 4217 currency code.
                  example: INR
                customerId:
                  type: string
                  description: ID of the customer to charge, as returned by List customers.
                  example: cus_8f2k1
                metadata:
                  type: object
                  description: Optional key-value pairs saved with the charge and returned with it.
                  example: { orderId: "A-1042" }
      responses:
        "200":
          description: The charge was created.
        "402":
          description: The card was declined.

Avoid descriptions that only repeat the name, such as "limit: the limit". Say what the value does instead. Keep internal details out of every description, as explained in Which APIs to add.

#

Folder structure

api-docs/
├── docstar.json          optional: module order
├── payments/             a folder is a module
│   ├── layout.json       optional: module settings
│   └── charges.yaml      a complete OpenAPI file
└── users.yaml            a file on its own is a one-file module
docs/
├── getting-started.md    a page
└── guides/               a section
    ├── page.md           the section's own page
    └── setup.md          a page in the section

Use only lowercase letters, numbers, - and _ in file and folder names.

#

API docs (api-docs/)

  • Each operation needs a unique operationId. DocStar matches endpoints by it, so never change it once the endpoint exists.

  • Set x-docstar-published: true on every operation, or the endpoint stays a draft.

  • Give every operation a summary and a description, and describe every parameter, header and body field, with requestBody and responses examples. See Describe everything.

  • docstar.json sets the module order: { "order": ["payments", "users.yaml"] }.

  • layout.json keys, all optional: name, description, published, defaultPublished (publish new endpoints without x-docstar-published), and adopt (the name of a module you already made by hand, so the sync fills it instead of creating a duplicate).

#

Markdown pages (docs/)

  • Each file starts with front matter: title, a short description of the page, and published: true.

  • Every file is published, so keep only user-facing pages there.

#

Good to know

  • Only the files you change are synced. For api-docs/, all files of a module you touch are sent together, so removed operations are recognised.

  • Deleting a file or an operation archives the matching page or endpoint. You can restore it for about 30 days.

  • The repository is the source of truth: edits made in DocStar can be overwritten by the next sync.

  • For a one-time import instead, see Import Content.