home / skills / agenta-ai / agenta / update-api-docs

update-api-docs skill

/.claude/skills/update-api-docs

This skill updates API reference docs by fetching the latest production OpenAPI spec and regenerating Docusaurus pages for accurate endpoints.

npx playbooks add skill agenta-ai/agenta --skill update-api-docs

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.3 KB
---
name: update-api-docs
description: Update the API reference documentation by downloading the latest OpenAPI spec from production and regenerating the Docusaurus API docs
---

# Update API Documentation

This skill guides you through updating the API reference documentation from the production OpenAPI specification.

## Overview

The API documentation is generated from an OpenAPI spec using `docusaurus-plugin-openapi-docs`. The workflow involves:
1. Downloading the latest `openapi.json` from production
2. Replacing the local spec file
3. Regenerating the API documentation pages

## File Locations

| Purpose | Path |
|---------|------|
| OpenAPI spec (source) | `docs/docs/reference/openapi.json` |
| Generated API docs | `docs/docs/reference/api/*.api.mdx` |
| Generated sidebar | `docs/docs/reference/api/sidebar.ts` |
| Docusaurus config | `docs/docusaurus.config.ts` |

## Steps

### 1. Download the OpenAPI spec from production

```bash
curl -s "https://cloud.agenta.ai/api/openapi.json" -o docs/docs/reference/openapi.json
```

**Important:** The file should be saved in **minified format** (single line, no pretty-printing) to match the existing format in the repository. The curl command above preserves the original format from the server.

### 2. Install dependencies (if needed)

If this is a fresh clone or dependencies haven't been installed:

```bash
cd docs
npm install
```

### 3. Clean existing generated API docs

```bash
cd docs
npm run clean-api-docs -- agenta
```

The `agenta` argument refers to the OpenAPI config ID defined in `docusaurus.config.ts`.

### 4. Regenerate API docs

```bash
cd docs
npm run gen-api-docs -- agenta
```

This will generate:
- Individual `.api.mdx` files for each endpoint
- `.tag.mdx` files for API categories
- `sidebar.ts` for navigation

### 5. Verify the changes

Optionally, start the dev server to preview:

```bash
cd docs
npm run start
```

Then visit `http://localhost:5000/docs/reference/api` to verify the API docs render correctly.

## Commit Guidelines

When committing these changes:

1. **First commit** - API docs update:
   ```
   docs(api): update OpenAPI spec from production
   ```

2. Include all changed files:
   - `docs/docs/reference/openapi.json`
   - `docs/docs/reference/api/*.api.mdx`
   - `docs/docs/reference/api/*.tag.mdx`
   - `docs/docs/reference/api/sidebar.ts`

## Troubleshooting

### "missing required argument 'id'" error

The clean and generate commands require the config ID. Use:
```bash
npm run clean-api-docs -- agenta
npm run gen-api-docs -- agenta
```

### "docusaurus: not found" error

Run `npm install` in the `docs/` directory first.

### Deprecation warning about onBrokenMarkdownLinks

This is a known warning and can be safely ignored. It will be addressed in a future Docusaurus v4 migration.

## Related Configuration

The OpenAPI plugin is configured in `docs/docusaurus.config.ts`:

```typescript
[
  "docusaurus-plugin-openapi-docs",
  {
    id: "openapi",
    docsPluginId: "classic",
    config: {
      agenta: {
        specPath: "docs/reference/openapi.json",
        outputDir: "docs/reference/api",
        downloadUrl: "https://raw.githubusercontent.com/Agenta-AI/agenta/refs/heads/main/docs/docs/reference/openapi.json",
        sidebarOptions: {
          groupPathsBy: "tag",
          categoryLinkSource: "tag",
        },
      },
    },
  },
],
```

Overview

This skill automates updating the API reference docs by pulling the latest OpenAPI spec from production and regenerating Docusaurus API pages. It ensures the local spec is replaced in the expected minified format and runs the docusaurus-plugin-openapi-docs generation steps. The outcome is a refreshed set of .api.mdx/.tag.mdx files and an updated sidebar for the docs site.

How this skill works

The skill downloads the production openapi.json into docs/docs/reference/openapi.json, preserving the server-provided minified format. It runs the plugin's clean and generate npm scripts (passing the OpenAPI config ID) to remove and recreate generated API pages and sidebar. Optionally, it can start the local dev server so you can preview the updated docs at /docs/reference/api.

When to use it

  • After backend API changes that modify or add endpoints in production.
  • Before releasing documentation updates tied to a new backend deployment.
  • When the OpenAPI spec hosted in production has been corrected or extended.
  • As part of a docs maintenance sweep to keep reference docs current.
  • When automated doc generation fails and a manual refresh is required.

Best practices

  • Always download the spec into docs/docs/reference/openapi.json and keep the minified format to avoid noisy diffs.
  • Run npm install inside docs/ on first use to avoid docusaurus: not found errors.
  • Pass the OpenAPI config ID (agenta) to clean and gen scripts: npm run clean-api-docs -- agenta.
  • Preview changes locally with npm run start and verify /docs/reference/api before committing.
  • Commit all generated files together (openapi.json, .api.mdx, .tag.mdx, sidebar.ts) with a single clear message.

Example use cases

  • Update API reference after deploying a new endpoint that needs documentation.
  • Regenerate docs when the production spec was fixed for an incorrect schema.
  • Include the docs update as a step in a release checklist for coordinated backend and docs changes.
  • Quickly troubleshoot and verify generated docs when CI/TG doc generation fails.
  • Refresh API docs after merging an API contract change from the API team.

FAQ

What command downloads the production OpenAPI spec?

Use curl -s "https://cloud.agenta.ai/api/openapi.json" -o docs/docs/reference/openapi.json to save the minified spec.

Why do I need to pass an ID to the clean/gen scripts?

The docusaurus-plugin-openapi-docs config uses an ID per spec (agenta). The clean and gen scripts require that ID to target the correct plugin config.