CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Scalar CLI

$ scalar 官方出品 低风险
Scalar · 设计与文档排版 · MIT · macos / linux / windows

Scalar CLI(@scalar/cli)为 OpenAPI/Swagger 文档提供现代开发工作流,涵盖规范校验、多文件 $ref 打包、JSON/YAML 格式化、本地 Mock 服务及 Scalar API Reference 文档预览。注意若不指定 --output,scalar document bundle 默认会直接覆盖原输入文件。

FCRS-1.0 综合评分
84 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
npm install -g @scalar/cli
CLI vs MCP 选型建议 优先选 CLI

使用 scalar 在本地直接完成 OpenAPI 校验、格式化与打包,无需经过 MCP 往返。

Agent 友好度体检单

— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 19 / 25

document validate、bundle 与 format 支持无头运行和清晰退出码,但校验缺乏原生 --json 输出且 mock/reference 为阻塞式服务。

  • document validate/bundle/format run headlessly
  • No --json diagnostics flag on validation; mock/reference are blocking servers
安全与权限边界 22 / 25

validate 为只读操作,但 bundle 与 format 在未显式传入 --output 时默认就地覆盖源文件。

  • scalar document bundle overwrites the source file if --output is omitted
安装与运行摩擦 13 / 15

跨平台 Node 包,可通过 npm install -g @scalar/cli 或 npx @scalar/cli 运行。

  • Published on npm as @scalar/cli
能力覆盖与边际价值 13 / 15

单工具集成 OpenAPI 校验、基于 Prettier 的格式化、打包、Mock 与文档预览。

  • Covers full OpenAPI local lifecycle in one CLI
维护与来源背书 9 / 10

由 Scalar 官方维护的 MIT 开源仓库(scalar/scalar)。

  • Official scalar/scalar GitHub repository
文档与可验证性 8 / 10

guides.scalar.com/scalar/scalar-cli 提供清晰文档与结构化的子命令 --help。

  • Official documentation at guides.scalar.com

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 环境变量密钥 本地配置文件
凭证存储位置

本地 OpenAPI 命令无需凭据;仅在发布至 Scalar Registry 时本地保存登录令牌。

潜在副作用
只读查询 本地写入 远端写入
费用与配额提示

CLI 遵循 MIT 开源协议免费使用;可选的 Scalar Registry 托管发布服务提供免费与付费档位。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Scalar CLI Agent Rules
- Always pass `--output <new-path>` with `scalar document bundle` so the source spec is not overwritten in place.
- Do not invoke `scalar mock` or `scalar reference` in foreground turns without backgrounding—they run long-lived HTTP servers.

Agent 高频安全命令配方

只读查询(安全推荐)

只读校验 OpenAPI 规范
scalar document validate openapi.yaml

检查 Swagger 2.0 或 OpenAPI 3.0/3.1 合规性,不修改 openapi.yaml。

受控写入与预演

将多文件 OpenAPI 引用打包到新文件
scalar document bundle openapi.yaml --output dist/openapi.bundled.yaml

将解析后的完整规范写入 dist/openapi.bundled.yaml,避免就地覆盖 openapi.yaml。

核心优势

  • + 统一集成 OpenAPI 校验、打包、格式化、本地 Mock 与 Scalar Reference 预览。
  • + 可通过 npx @scalar/cli 免安装即刻执行。
  • + 代码由 Scalar 官方团队以 MIT 协议积极维护。

注意事项与踩坑点

  • ! 省略 --output 时,scalar document bundle 会直接覆盖原输入文件。
  • ! scalar mock 与 scalar reference 会启动常驻 HTTP 服务并阻塞前台终端。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI