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

Atlas CLI

$ atlas 官方出品 中风险
Ariga · 数据库与数据处理 · Apache-2.0 (Community) / Proprietary (Pro) · macos / linux / windows

Ariga 开发的 Atlas CLI 支持用 HCL 或 SQL 声明式管理 PostgreSQL、MySQL、SQLite 等数据库结构。提供 atlas schema inspect、atlas migrate diff 与 atlas migrate apply --dry-run,让 Agent 能在落库前安全生成并预览 DDL 变更。

FCRS-1.0 综合评分
88 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install ariga/tap/atlas
CLI vs MCP 选型建议 优先选 CLI

atlas 原生即可完成确定性 SQL 差异计算、JSON 结构导出与 --dry-run 迁移预览,无需借助 MCP。

Agent 友好度体检单

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

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

FCRS-1.0 六维评分拆解

Agent 友好度 23 / 25

支持 --format '{{ json . }}' 模板输出、--dry-run 预演、非交互参数及声明式 atlas.hcl 配置。

  • Supports --format '{{ json . }}' and migrate apply --dry-run
安全与权限边界 22 / 25

migrate apply 与 schema apply 均支持 --dry-run,且可通过 --dev-url 沙箱隔离计算差异。

  • Explicit --dry-run planning and isolated --dev-url diff calculation
安装与运行摩擦 14 / 15

单文件静态 Go 二进制,支持 Homebrew、npm 封装、Docker 与直接下载,覆盖全平台。

  • Static Go binary distributed via ariga/tap/atlas and @ariga/atlas
能力覆盖与边际价值 14 / 15

用自动化声明式 Schema 规划替代易错的手写迁移脚本。

  • Declarative schema inspection, diffing, and migration execution
维护与来源背书 7 / 10

由 Ariga(ariga/atlas)积极维护,但标准发行版包含专有 Pro 扩展。

  • Official ariga/atlas repo; split Community vs Pro licensing
文档与可验证性 8 / 10

atlasgo.io 提供详尽的 CLI 参考与多数据库实战指南。

  • Official CLI reference at atlasgo.io/cli-reference

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

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

数据库连接串通过 --url 或 atlas.hcl 配置;可选的 Atlas Cloud 令牌通过 atlas login 或 ATLAS_TOKEN 传入。

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

基础核心功能以 Apache-2.0 开源免费;高级 Pro 驱动、策略检查(migrate lint)与企业能力需付费订阅 Atlas Pro。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Atlas CLI Agent Rules
- Always run `atlas migrate apply --dry-run` before applying migrations.
- Use `atlas schema inspect` first to capture current schema state cleanly.
- NEVER run `atlas schema clean` or apply destructive `DROP` migrations without human review.

Agent 高频安全命令配方

只读查询(安全推荐)

将数据库现有结构导出为 JSON
atlas schema inspect --url "$DB_URL" --format '{{ json . }}'

只读读取表结构、索引和外键并输出标准 JSON。

使用 --dry-run 预览待执行迁移
atlas migrate apply --dir file://migrations --url "$DB_URL" --dry-run

打印将要执行的精确 SQL 语句,但不对数据库做任何修改。

受控写入与预演

本地生成带版本的 SQL 迁移差异文件
atlas migrate diff add_orders --dir file://migrations --to file://schema.hcl --dev-url "docker://postgres/16/dev"

对比目标 Schema 计算迁移脚本并写入本地目录供审阅。

核心优势

  • + migrate apply --dry-run 与 schema apply --dry-run 让 DDL 变更过程对 Agent 完全透明。
  • + schema inspect --format '{{ json . }}' 可直接输出标准化 JSON 结构树。
  • + 统一支持 PostgreSQL、MySQL、MariaDB 与 SQLite。

注意事项与踩坑点

  • ! migrate lint 及部分企业数据库驱动需要 atlas login / Pro 商业授权。
  • ! atlas migrate diff 通常依赖临时 --dev-url(如 Docker 容器)以保证 SQL 归一化准确。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI

Follow 家族生态联动