Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Spectral CLI

$ spectral Official Low Risk
Stoplight · Design & Docs · Apache-2.0 · macos / linux / windows

Spectral CLI (@stoplight/spectral-cli) is a flexible, ruleset-driven JSON/YAML linter widely used as the CI governance gate for OpenAPI, AsyncAPI, Arazzo, and custom JSON Schema documents. Built-in --format json / sarif, --ruleset, and --fail-severity flags make it a gold standard for automated API design validation.

FCRS-1.0 Score
92 /100
Excellent
Medium Confidence
Zero-Friction Install
npm install -g @stoplight/spectral-cli
CLI vs MCP Decision CLI Only

spectral lint --format json evaluates API specs directly against repository .spectral.yaml rulesets in milliseconds.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 24 / 25

Purpose-built for CI and agents: --format json, --format sarif, --quiet, --stdin-filepath, --display-only-failures, and --fail-severity.

  • 11 built-in formatters including json, sarif, and github-actions
  • Zero interactive prompts and deterministic severity-based exit codes
Trust & Safety 24 / 25

Strictly read-only linter that never modifies API specification files.

  • Zero write/mutation side effects on source specs
  • No credentials required
Setup & Portability 14 / 15

Available via npm (@stoplight/spectral-cli), npx, Docker, and standalone pkg binaries on GitHub releases.

  • npm install -g @stoplight/spectral-cli and standalone binaries
Utility & Efficiency 14 / 15

Industry-standard API governance linter covering OpenAPI, AsyncAPI, Arazzo, and custom JSON/YAML schemas.

  • Extensible JSONPath-based custom rulesets (.spectral.yaml)
Maintenance & Lineage 8 / 10

Official Stoplight repository (stoplightio/spectral) maintained under Apache-2.0.

  • Official Stoplight GitHub organization
Docs & Verifiability 8 / 10

Comprehensive Stoplight docs covering CLI flags, rulesets, and built-in OAS/AsyncAPI functions.

  • Official docs at docs.stoplight.io/docs/spectral/

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

No credentials required; pure local linter (remote $ref or ruleset URLs are fetched over HTTP only if referenced).

Side Effects
Read-Only
Cost & Quotas

Free open-source software (Apache-2.0).

Copyable Guardrail for CLAUDE.md / AGENTS.md
# Spectral CLI Agent Rules
- Always run `spectral lint <spec> --format json --quiet` after editing OpenAPI or AsyncAPI files.
- Respect the repository's `.spectral.yaml` / `.spectral.yml` ruleset rather than bypassing rules.
- Use `--stdin-filepath` when linting unsaved spec snippets via stdin.

Agent-Ready Command Recipes

Safe Read-Only Queries

Lint an OpenAPI spec with JSON output
spectral lint openapi.yaml --format json --quiet

Validates openapi.yaml against .spectral.yaml (or default OAS rules) and outputs JSON diagnostics.

Lint multiple specs with SARIF output
spectral lint "specs/*.yaml" --format sarif --fail-severity warn

Outputs SARIF results and exits non-zero on any warning or error across specs/*.yaml.

Strengths for Agents

  • + Rich machine-readable formatters (--format json, sarif, junit, github-actions) plus --quiet and --fail-severity.
  • + Strictly read-only validation across OpenAPI, AsyncAPI, Arazzo, and arbitrary YAML/JSON.
  • + Supports --stdin-filepath for fast in-memory spec linting and standalone binaries alongside npm.

Caveats & Pitfalls

  • ! Custom JS functions inside .spectral.yaml rulesets execute local Node code when present.
  • ! Lint-only tool—use redocly bundle or openapi-generator-cli for bundling and code generation.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI