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

Neon CLI

$ neonctl 官方出品 中风险
Neon · 数据库与数据处理 · Apache-2.0 · macos / linux / windows

Neon CLI 用于管理 Neon Serverless Postgres 项目、写时复制分支、计算端点与角色。全命令支持 --output json 与非交互式 NEON_API_KEY 鉴权,其秒级分支工作流非常适合 AI 编程 Agent 进行隔离测试。

FCRS-1.0 综合评分
89 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install neonctl
CLI vs MCP 选型建议 CLI + MCP 搭配

确定性的分支生命周期、CI 脚本和连接串获取适合使用 neonctl;如需自然语言交互式 SQL 探索,可搭配 Neon MCP 服务。

Agent 友好度体检单

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

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

FCRS-1.0 六维评分拆解

Agent 友好度 23 / 25

原生支持 --output json / yaml / table、非交互式 NEON_API_KEY 鉴权与清晰的子命令结构。

  • Supports --output json across resource commands and NEON_API_KEY env auth
安全与权限边界 21 / 25

写时复制分支机制天然支持隔离测试,但 branches delete 与 projects delete 仍需护栏约束。

  • Isolated branch creation protects production main; delete commands have remote impact
安装与运行摩擦 14 / 15

提供 brew、npm、npx 及多平台独立二进制,跨 macOS、Linux、Windows 开箱即用。

  • Multi-channel distribution via Homebrew and npm
能力覆盖与边际价值 14 / 15

Agent 可在数秒内创建临时 Postgres 分支并拿到连接 URI。

  • Instant copy-on-write Postgres branching in a single command
维护与来源背书 9 / 10

由 Neon 官方在 neondatabase/neonctl 仓库以 Apache-2.0 协议维护。

  • Official neondatabase/neonctl repo
文档与可验证性 8 / 10

官方 CLI 参考文档详尽,包含各命令参数表与示例。

  • Official reference at neon.tech/docs/reference/neon-cli

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

鉴权方式
浏览器 OAuth 环境变量密钥 本地配置文件
凭证存储位置

OAuth 凭证保存在 ~/.config/neonctl/credentials.json,也可通过 NEON_API_KEY 环境变量或 --api-key 传入。

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

CLI 以 Apache-2.0 开源;Neon 提供免费额度,付费方案按计算与存储用量计费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Neon CLI Agent Rules
- Always pass `--output json` and set `NEON_API_KEY` for headless runs.
- Create an isolated branch with `neonctl branches create` before running schema migrations.
- NEVER run `neonctl projects delete` or `neonctl branches delete main` autonomously.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 列出 Neon 项目
neonctl projects list --output json

获取结构化 JSON 格式的项目 ID、区域和 Postgres 版本信息。

获取分支连接字符串
neonctl connection-string main --project-id <project-id> --output json

返回指定分支的 PostgreSQL URI 供下游迁移或查询工具使用。

受控写入与预演

创建隔离的预览数据库分支
neonctl branches create --name agent-test --project-id <project-id> --output json

拉起写时复制的 Postgres 分支,确保 Agent 不会直接修改 main 主分支。

核心优势

  • + 一致的 --output json 输出让项目与分支自动化极易解析。
  • + 写时复制 branches create 让 Agent 能在独立分支安全验证迁移。
  • + NEON_API_KEY 便于无头 CI 与 Agent 环境免交互运行。

注意事项与踩坑点

  • ! connection-string 会向 stdout 输出数据库密码,注意在共享日志中脱敏。
  • ! 删除类破坏性操作缺少原生 --dry-run 预演开关。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI