# Redocly CLI **Govern your APIs with one tool.** Lint, bundle, test, document, and generate clients from the command line. [![npm version](https://img.shields.io/npm/v/@redocly/cli)](https://www.npmjs.com/package/@redocly/cli) [![npm downloads per month](https://img.shields.io/npm/dm/@redocly/cli)](https://www.npmjs.com/package/@redocly/cli) [![License](https://img.shields.io/npm/l/@redocly/cli)](LICENSE.md) [![Build and test](https://github.com/redocly/redocly-cli/actions/workflows/tests.yaml/badge.svg)](https://github.com/Redocly/redocly-cli/actions/workflows/tests.yaml) The API lifecycle with Redocly CLI: lint, test, document, generate, and compare, on every change, locally and in CI. Redocly CLI is a fast OpenAPI linter and API governance toolkit. It checks OpenAPI 3.2, 3.1, 3.0, Swagger 2.0, AsyncAPI 3.x and 2.6, and Arazzo 1.x descriptions against your API style guide. It runs on your machine, in CI/CD, and in Docker. ## Quick start Run the latest version without installing it: ```sh npx @redocly/cli@latest lint openapi.yaml ``` Or install it with npm or Docker. ### npm ```sh npm install -g @redocly/cli ``` ### Docker ```sh docker run --rm -v $PWD:/spec redocly/cli lint openapi.yaml ``` npm and npx need Node.js 22.12.0 and npm 10.9.2 or later. For more options, see [Install Redocly CLI](https://redocly.com/docs/cli/installation). ## What you can do Lint, test the live API, and build the docs: Redocly CLI lints a multi-file API description, tests a live API, and builds API reference docs. ### Lint to your API style guide Start with a built-in ruleset: [`recommended`](https://redocly.com/docs/cli/rules/recommended), [`minimal`](https://redocly.com/docs/cli/rules/minimal), or [`spec`](https://redocly.com/docs/cli/rules/spec). Then mix and match the [built-in rules](https://redocly.com/docs/cli/rules/built-in-rules) to set your own API guidelines. When you need a rule of your own, write it in `redocly.yaml`. [Configurable rules](https://redocly.com/docs/cli/rules/configurable-rules) use simple expressions that know the structure of the API description, not complex JSONPath selectors. For full control, [build your own plugin](https://redocly.com/docs/cli/custom-plugins). ```yaml extends: - recommended rules: operation-summary: error rule/operation-id-camel-case: subject: type: Operation property: operationId assertions: casing: camelCase message: operationId must be camelCase. ``` **Multiple files supported.** You do not need to bundle your API description to lint it. Point [`lint`](https://redocly.com/docs/cli/commands/lint) at the entry point, for example `openapi.yaml`, and it follows every `$ref`. ```sh redocly lint openapi.yaml ``` The default output is `codeframe`. Other tools can read the `stylish`, JSON, Markdown, Checkstyle, JUnit, and other formats. Moving from Spectral? Read [Migrate from Spectral](https://redocly.com/docs/cli/guides/migrate-from-spectral). [Learn more about API standards and how to configure rules](https://redocly.com/docs/cli/api-standards). For ready-made rules and plugins, see the [Cookbook](./cookbook/README.md). ### Build API reference docs Render your API description with one command. [`build-docs`](https://redocly.com/docs/cli/commands/build-docs) writes a single HTML file with [Redoc CE](https://redocly.com/redoc-ce) that you can host anywhere. ```sh redocly build-docs openapi.yaml ``` [`preview`](https://redocly.com/docs/cli/commands/preview) starts live docs on your machine, with a mock server, and updates the page each time you save the description. ```sh redocly preview ``` ### Test the live API [`respect`](https://redocly.com/docs/respect/get-started) sends real requests to your API and checks each response against your OpenAPI description and Arazzo workflows. With `--with-ai`, your local AI CLI (Claude, Codex, or Cursor) designs multi-step workflows from the OpenAPI description. ```sh redocly generate-arazzo openapi.yaml --with-ai redocly respect auto-generated.arazzo.yaml ``` ### Bundle, split, and join Keep a large description in many files, and [`bundle`](https://redocly.com/docs/cli/commands/bundle) it into one file for tools that need it. Use [decorators](https://redocly.com/docs/cli/decorators) to remove internal endpoints or change server URLs as you bundle. ```sh redocly bundle openapi.yaml -o dist/openapi.yaml ``` ### Generate typed clients (experimental) Generate typed SDKs for TypeScript, Python, Go, PHP, and Java from one OpenAPI description, or a ready-to-use CLI for your API. The TypeScript client has zero runtime dependencies. Its add-ons give you Zod schemas, MSW mocks, TanStack Query hooks, and SWR hooks. ```sh redocly generate-client openapi.yaml --output src/client.ts redocly generate-client openapi.yaml --output src/client.ts --generator cli ``` For all generators and options, see [`generate-client`](https://redocly.com/docs/cli/commands/generate-client). ### Compare versions and traffic (experimental) [`diff`](https://redocly.com/docs/cli/commands/diff) lists the changes between two versions of a description. [`drift`](https://redocly.com/docs/cli/commands/drift) compares recorded HTTP traffic with the description. ## All commands **Lint and govern** - [`lint`](https://redocly.com/docs/cli/commands/lint): Lint an API or Arazzo description. - [`check-config`](https://redocly.com/docs/cli/commands/check-config): Lint the Redocly configuration file. - [`score`](https://redocly.com/docs/cli/commands/score): Score an API description for integration simplicity and AI agent readiness (experimental). - [`scorecard-classic`](https://redocly.com/docs/cli/commands/scorecard-classic): Evaluate an API against the scorecard configuration of a Redocly project. - [`stats`](https://redocly.com/docs/cli/commands/stats): Show statistics for an API description. - [`recheck`](https://redocly.com/docs/cli/commands/recheck): Lint Markdown prose and structure. - [`inspect-node-types`](https://redocly.com/docs/cli/commands/inspect-node-types): Show the node types of an API description, for configurable rules and custom plugins (experimental). **Manage files** - [`bundle`](https://redocly.com/docs/cli/commands/bundle): Bundle a multi-file API description into a single file. - [`split`](https://redocly.com/docs/cli/commands/split): Split an API description into a multi-file structure. - [`join`](https://redocly.com/docs/cli/commands/join): Join multiple API descriptions into one (experimental). **Test** - [`respect`](https://redocly.com/docs/cli/commands/respect): Run the API tests of an Arazzo description against a live API. - [`generate-arazzo`](https://redocly.com/docs/cli/commands/generate-arazzo): Generate an Arazzo description from an OpenAPI description. **Docs** - [`build-docs`](https://redocly.com/docs/cli/commands/build-docs): Build API reference docs from an API description into an HTML file. - [`preview`](https://redocly.com/docs/cli/commands/preview): Start a local preview of a Redocly project. - [`translate`](https://redocly.com/docs/cli/commands/translate): Generate translation keys for a Redocly project. - [`eject`](https://redocly.com/docs/cli/commands/eject): Eject components from the core theme of a Redocly project, to change them. **Generate** - [`generate-client`](https://redocly.com/docs/cli/commands/generate-client): Generate typed SDKs and a CLI from an OpenAPI description (experimental). - [`eject-generator`](https://redocly.com/docs/cli/commands/eject-generator): Copy a built-in client generator into your repository as an editable file (experimental). - [`generate-spec`](https://redocly.com/docs/cli/commands/generate-spec): Infer an OpenAPI description from recorded HTTP traffic (experimental). - [`introspect-mcp`](https://redocly.com/docs/cli/commands/introspect-mcp): Record the capabilities of an MCP server in an OpenAPI description (experimental). **Compare** - [`diff`](https://redocly.com/docs/cli/commands/diff): Compare two API descriptions and rate each change by the semver bump it requires (experimental). - [`drift`](https://redocly.com/docs/cli/commands/drift): Detect drift between recorded HTTP traffic and an OpenAPI description (experimental). - [`proxy`](https://redocly.com/docs/cli/commands/proxy): Capture live HTTP traffic through a reverse proxy into a HAR file (experimental). **Redocly platform** - [`login`](https://redocly.com/docs/cli/commands/login): Log in to Redocly. - [`logout`](https://redocly.com/docs/cli/commands/logout): Clear your stored credentials. - [`push`](https://redocly.com/docs/cli/commands/push): Push an API description to the Redocly platform. - [`push-status`](https://redocly.com/docs/cli/commands/push-status): Track a push to the Redocly platform. - `project`: Work with a Redocly-hosted project (early access). **Tooling** - [`skills`](https://redocly.com/docs/cli/commands/skills): Install the Redocly CLI agent skills for AI coding agents. - [`completion`](https://redocly.com/docs/cli/commands/completion): Generate the autocomplete script for your shell. For the options and examples of each command, see the [commands reference](https://redocly.com/docs/cli/commands). ## Use with AI assistants Redocly CLI ships [agent skills](./.claude/skills) that teach AI coding assistants how to use it. This command finds Claude Code, Codex, Cursor, GitHub Copilot, and other agents, and installs the skills into your project: ```sh redocly skills ``` It installs only the skills for Redocly CLI. To install every skill that Redocly publishes, use `npx skills add https://redocly.com`. - `redocly-cli`: lint, bundle, decorate, build docs, test, and generate a client. - `redocly-lint-rules`: turn a rule written in plain language into a built-in rule, a configurable rule, or a plugin. It also moves rules from other linters, such as Spectral. - `recheck-lint`: run `redocly recheck` on the Markdown that the assistant changed, and fix what it finds. - `recheck-config`: write and tune the `recheck` settings in `redocly.yaml`. ## From the CLI to a full API platform Redocly Platform: publish what you lint. Interactive API docs, a mock server, and an API catalog, published from your Git repository. Start a 30-day free trial. See [plans and pricing](https://redocly.com/pricing). To work on a Redocly Framework project locally, run [`redocly preview`](https://redocly.com/docs/cli/commands/preview). Add `--plan=pro`, `--plan=scale`, or `--plan=enterprise` to see the features of that plan. ## Data collection This tool [collects data](./docs/@v2/usage-data.md) to help Redocly improve our products and services. You can opt out by setting the `REDOCLY_TELEMETRY` environment variable to `off`. ## Update notifications Redocly CLI checks for updates on startup. You can disable notifications by setting the `REDOCLY_SUPPRESS_NOTIFICATIONS` environment variable to `true`. ## More resources [Read the detailed docs](https://redocly.com/docs/cli/). ## Credits Thanks to [graphql-js](https://github.com/graphql/graphql-js) and [eslint](https://github.com/eslint/eslint) for inspiration of the API description traversal approach and to [Swagger](https://github.com/swagger-api/swagger-editor), [Spectral](https://github.com/stoplightio/spectral), and [OAS-Kit](https://github.com/Mermade/oas-kit) for inspiring the recommended ruleset. ## Development Contributions are welcome! All the information you need is in [CONTRIBUTING.md](CONTRIBUTING.md). ## Migrate Follow our official migration guides: - [From Redocly CLI v1 to v2](https://redocly.com/docs/cli/guides/migrate-to-v2) - [From Spectral](https://redocly.com/docs/cli/guides/migrate-from-spectral) - From [swagger-cli](https://redocly.com/docs/cli/guides/migrate-from-swagger-cli), [redoc-cli](https://redocly.com/docs/cli/guides/migrate-from-redoc-cli), or [openapi-cli](https://redocly.com/docs/cli/guides/migrate-from-openapi-cli)