Cursor CLICursor CLI
Cursor 的终端形态:和编辑器共用同一账户、同一批模型、同一份 mcp.json。
命令名是 agent。 官方称它支持:
官方原文:"print automation for scripts and CI pipelines"
也就是把 agent 写进脚本。
相对 IDE 形态,它多出两条路径。 一条是 headless 与非交互。 另一条是把会话交给 Cloud Agent 或持久会话。
The terminal form of Cursor: it shares one account, one model catalogue and one mcp.json with the editor.
The command is agent. Officially it supports "print automation for scripts and CI pipelines", so you can put the agent inside a script.
Against the IDE form it adds two paths. One is headless non-interactive use. The other is handing a session to a Cloud Agent or a persistent session.
Three differences from the IDE form: the interaction surface (a terminal), scriptability (-p / --print plus --output-format text|json|stream-json), and the way it plugs into other clients (agent acp, which serves ACP over stdio and JSON-RPC).
适合与不适合When to use it, when not to
在终端里做工程任务、写脚本、进 CI/CD 的人。 官方给了 GitHub Actions 与 cookbook。
已用 Cursor、希望编辑器与终端共用同一份账户、模型与 MCP 配置的人。 需要把会话交给 Cloud Agent 或持久会话继续跑的人。
不适合要求开源许可或完全自托管的场景。 Cursor CLI 是闭源商业产品,需 Cursor 账户或 API key,用量并入账户额度池。
People doing engineering work in the terminal, writing scripts, or running CI/CD. The official GitHub Actions docs and cookbook cover this. People already on Cursor who want the editor and the terminal to share one account, model set and MCP config. People who need to hand a session to a Cloud Agent or keep it running through a persistent session.
Not a fit where an open-source licence or full self-hosting is required. Cursor CLI is a closed-source commercial product: it needs a Cursor account or an API key, and usage draws on the same account quota pools.
中文生态China availability 国产 / 国内可直接用 / 备案状态 · 快照domestic / direct access / CAC filing · snapshot 2026-10-20
- 出品属地Origin
- 国外出品foreign-made 国外主体(网信办公示名单未见对应备案主体)。foreign entity (no matching filing entity in the CAC registry).
- 国内使用Direct access
- 大陆可直连direct OK 官网直连实测 200。official site measured 200 direct.
- 备案状态CAC filing
- 未见于备案名单not in filing list:未见于网信办公示名单(2026-10-20 检索 13 批附件,https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm);该产品未面向大陆公众提供服务,备案不适用。not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.
备案信息以网信办《生成式人工智能服务已备案信息》公示名单为准(按批次滚动更新,本站只抄编号不解读);「大陆可直连」是本站从大陆网络直连实测的结果,不是厂商承诺。GitHub 类站点当日实测有波动,口径写在依据里。Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.
固定坐标系Fixed coordinate system
8 个维度dimensions, 与同分区其他对象逐项可比each comparable item by item against others in the same section.
- 模型与开放条件Model & openness
和 Cursor 编辑器同源:模型清单跟着账户走。
官方 CLI 落地页给出的可选模型示例:
- Auto
- Composer 2
- Opus 4.6
- Codex 5.3 High Fast
- Gemini 3 Pro
- Grok
同一页还写它覆盖:
- Anthropic、OpenAI、Gemini、Cursor 等提供的前沿模型
以下是官方模型名的英文原文:
官方落地页原文: Auto、Composer 2、Opus 4.6、Codex 5.3 High Fast、Gemini 3 Pro、Grok
模型与价格页另列一批:Claude 4.6 Opus / Sonnet、Gemini 3.1 Pro、 GPT-5.3 Codex、GPT-5.4、Grok 4.20 与 Composer 2。
切换模型用
--model <model>、--list-models、agent models、/model。企业可以用管理策略限制可用模型。 被限制的模型传给
--model会带限制信息退出。官方 CLI changelog 的英文原文:官方 CLI changelog 原文: "Admin Team model restrictions apply in the CLI"
v2026.09.28 修掉了一个坑。
--model此前可能静默运行较短的基础模型。与
./cursor.md的差异只在入口。 模型目录不因形态而变。- 运行位置Where it runs
本地终端进程,命令名是
agent。官方安装脚本把它装到
~/.local/bin,Windows 原生用 PowerShell。 默认自动更新,agent update手动升级。生命周期主要绑定终端会话。但官方另给了几条「脱离终端」的路径(见 background)。
和
./cursor.md的 IDE 形态相比,差异有三处。 一是交互面:这里是终端。 二是可脚本化。 三是接入方式:agent acp能把 CLI 当作 ACP server, 跑在 stdio 上供自定义客户端接入。- 本地文件Local files
在仓库/工作区内操作,可用 Git worktree 隔离改动。
用
--workspace <path>指定工作区。 用-w/--worktree [name]在~/.cursor/worktrees/<reponame>/<name>建新 worktree(与编辑器共用保留规则)。写盘默认是收紧的。 脚本里要落盘,得配
--force(或--yolo)。 官方 headless 页的英文原文:官方 headless 页原文: "Without
--force, changes are only proposed, not applied"注意 parameters 页另有相反口径的表述,两页并存:
官方 parameters 页原文: "Has access to all tools, including write and shell"
规则读
.cursor/rules与项目根的AGENTS.md、CLAUDE.md。 读写范围由 permissions 的Read(...)/Write(...)精确控制。- 关机后的任务Tasks after shutdown
终端进程随会话结束,但官方提供三条「脱离终端」的路径。
一是 Cloud Agent handoff。 在会话里给消息前加
&,就能在 web 或移动端 cursor.com/agents 取回。官方原文: "continue running while you're away"
二是持久会话。 用
agent persist启动、/detach脱离、agent persist attach重连, 用agent persist list/stop管理。 这条能力来自 v2026.08.26,changelog 的英文原文:v2026.08.26 changelog 原文: "Keep agents running after you disconnect"
三是
agent worker,官方称它启动的是一个私有云 worker:官方原文: "a private cloud worker that runs agents in your environment"
三条路径各自的执行环境归属与额度限制,官方页面未分别写明。
- 工具与扩展Tools & extensions
工具面分三层,三层都已核到。
第一层是内置工具面。 官方 using 页的英文原文:
官方 using 页原文: "Agent has tools for file operations, searching, running shell commands, and web access"
其中的 Shell Mode(
/shell,/sh、/run为别名)在登录 shell 里跑命令。第二层是 MCP。 CLI 会自动读
mcp.json:官方原文: "automatically detect and respect your
mcp.json"位置是
.cursor/mcp.json或~/.cursor/mcp.json,与编辑器共用同一批 server。 另有agent mcp子命令(login/list/list-tools/enable/disable) 与--approve-mcps。第三层是 ACP。
agent acp以 stdio + JSON-RPC 对外提供 ACP server。扩展机制另有 plugins(
--plugin-dir、/plugin)、 skills(可粘成 custom mode)与.cursor/rules。- 上下文与记忆Context & memory
会话可恢复、可分叉、有压缩。
继续会话用
--resume [chatId]、--continue、agent resume、agent ls、/resume。/fork把当前会话分叉成新会话,/rewind跳回先前消息。 上下文压缩用/summarize(/compress为别名)。v2026.09.22 修掉了一个坑:此前的摘要会丢掉最新一条请求或整段会话。 现在会保留最近一条用户消息,一字不改。 摘要失败或被中止,则保留原会话。
长期上下文靠 rules 与 skills。
.cursor/rules与AGENTS.md/CLAUDE.md自动加载。/goal可以给长期目标,官方把它标为 "Rolling out"。跨会话记忆的存储位置,官方未在此页说明。
- 权限与限制Permissions & limits
权限设计是本形态最细的一块,另有 sudo 凭据保护。
配置文件有两个:全局
~/.cursor/cli-config.json,项目级<project>/.cursor/cli.json。权限 token 分五类:
Shell(cmd)Read(path)Write(path)WebFetch(domain)Mcp(server:tool)
用
permissions.allow/permissions.deny控制,deny 优先于 allow。默认下,每条终端命令都要批准。 官方 using 页的英文原文:
官方 using 页原文: "Before running terminal commands, CLI will ask you to approve (y) or reject (n)"
--force(别名--yolo)可以放行。 沙箱由/sandbox或--sandbox enabled|disabled控制, 官方写 disable 时「用 allowlist 模式」。需要
sudo时弹掩码密码框。官方称密码经安全 IPC 直达sudo:官方原文: "The AI model never sees it"
CI 侧官方推荐 受限自主 + permission-based restrictions, 并把指令写入
permissions.json配 Auto-review。- 适合什么任务Best for
适合三类人:
- 在终端里做工程任务、写脚本、或进 CI/CD 的人(官方 GitHub Actions 文档与 cookbook)
- 已用 Cursor,希望编辑器与终端共用账户 / 模型 / MCP 配置的人
- 需要把会话交给 Cloud Agent 或持久会话继续跑的人
不适合要求开源许可的场景。 Cursor CLI 是闭源商业产品,需 Cursor 账户或 API key,且用量并入账户额度池。
头号误解Top misconception
- 以为 Cursor CLI 是独立免费工具,实际需 Cursor 账户或 API key,用量并入账户额度池Thinking Cursor CLI is a standalone free tool: it needs a Cursor account or an API key, and usage draws on the same account quota pools.
- 以为 print 模式会自动落盘,headless 页写不加 --force / --yolo 时只提议不写Assuming print mode writes files by default: the headless page states that without --force / --yolo changes are only proposed, not applied.
- 以为 Shell Mode 能跑长任务,官方限 30 秒超时且不可配置Expecting Shell Mode to run long tasks: commands time out after 30 seconds and the limit is not configurable.
未知项清单Known unknowns
- 三条「脱离终端」路径(
&Cloud Agent handoff /agent persist/agent worker)各自执行环境归属与额度限制 —— 官方未说明(已查 CLI Overview、CLI changelog 与 About 页) - 沙箱在 Windows 原生下的底层实现(容器还是进程级)—— 官方未说明(已查 CLI Overview 与 Permissions 两页)
- CLI 与编辑器是否共用同一额度池 —— 官方页面按账户整体说明额度,未按形态拆分
- 各档额度倍数(1x / 3x / 20x 之类)对应的具体请求数或 token 量
证据来源Evidence sources
判断可回到以下一手源复核。本站核验日Every judgement can be rechecked against the primary sources below. Verified on 2026-10-08,内容更新日content updated on 2026-10-08。
| 类型Type | 名称Name | 链接Link |
|---|---|---|
| docs | Cursor · CLI 官方落地页(安装、模型示例、headless 入口) | https://cursor.com/cli |
| changelog | Cursor · CLI changelog(v2026.09.28 / 09.22 / 08.26 持久会话,2026-10-08 取到) | https://cursor.com/docs/cli/changelog |
| docs | Cursor Docs · Cursor CLI 总览(模式、非交互、Cloud Agent handoff、沙箱、sudo) | https://cursor.com/docs/cli/overview |
| docs | Cursor Docs · Headless CLI(print 模式、--force、输出格式、CI 脚本) | https://cursor.com/docs/cli/headless |
| docs | Cursor Docs · GitHub Actions 集成(CURSOR_API_KEY、自主级别、权限限制) | https://cursor.com/docs/cli/github-actions |
| docs | Cursor Docs · CLI Permissions(Shell / Read / Write / WebFetch / Mcp) | https://cursor.com/docs/cli/reference/permissions |
| docs | Cursor Docs · CLI Parameters(全局选项与子命令清单) | https://cursor.com/docs/cli/reference/parameters |
| docs | Cursor Docs · Models & pricing(双用量池与各档含额) | https://cursor.com/docs/models-and-pricing |
| pricing | Cursor · 官方定价页 | https://cursor.com/pricing |
| changelog | Cursor · 产品 changelog(Projects / 自托管 / Rollouts 等) | https://cursor.com/changelog |
实测记录Measured runs
本站尚未完成实测。测试协议见 tasks/_protocol.md。
实测建议:重点测非交互模式下「不落盘 / 落盘」的实际行为。 官方两页说法不一致。 headless 页写:不加 --force 不落盘。 parameters 页写:CLI 对所有工具都有访问权,其中包含写盘与 shell。
这是最值得用一条真实 CI 流程验证的地方。
其次测持久会话 agent persist 在断开网络后的续跑一致性。
与 IDE 形态的差异(本条目只写差异)
| 维度 | Cursor(IDE 形态) | Cursor CLI(本条目) | ||
|---|---|---|---|---|
| 交互面 | 图形编辑器 | 终端进程,命令 agent | ||
| 脚本化 | 无原生非交互入口 | -p / --print + `--output-format text\ | json\ | stream-json` |
| CI | — | 官方 GitHub Actions 文档与 cookbook | ||
| 接入编辑器 | 就是编辑器 | agent acp 以 ACP server(stdio + JSON-RPC)对外 | ||
| 共用项 | 账户、模型、mcp.json、.cursor/rules、额度池 | 同 |
这是同一产品的两种装法。 模型目录与额度池不因形态而变, 差别在交互面与可脚本化程度。详见 Cursor(IDE 形态)。
headless / 非交互(本分区的关键点)
官方 headless 页把脚本口径写全了:
- 单次执行:
agent -p "..."。官方原文 "Use print mode (-p, --print) for non-interactive scripting and automation"
- 落盘:批量改文件需
--force(别名--yolo)。官方原文 "Without--force, changes are only proposed, not applied"
- 输出:
--output-format text | json | stream-json,配--stream-partial-output做增量流;示例脚本用jq解析tool_call事件
- 鉴权:
export CURSOR_API_KEY=...(CI 里存为仓库/组织 secret) - 信任:
--trust在 headless 下免交互信任工作区
CI 侧,官方区分两种自主级别,并推荐生产用「受限自主」: 把提交、推送、评论交给确定性的 CI 步骤,agent 只改文件。 再用 permissions.allow / deny 在 CLI 层强约束。
权限与沙箱
权限 token 五类,写在 ~/.cursor/cli-config.json(全局) 或 <project>/.cursor/cli.json(项目级)。deny 优先于 allow。
| token | 例子 |
|---|---|
Shell(cmd) | Shell(git) 允许、Shell(rm) 拒绝 |
Read(path) | Read(**/*.md),Read(.env*) 拒绝 |
Write(path) | Write(src/**),Write(**/*.key) 拒绝 |
WebFetch(domain) | 未列入 allow 的每次抓取都要批准 |
Mcp(server:tool) | Mcp(datadog:*)、Mcp(*:*) |
交互模式下,默认每条终端命令都要批准。 沙箱用 /sandbox 或 --sandbox enabled|disabled 切换,disable 时退化为 allowlist 模式。
需要 sudo 时,官方称密码经安全 IPC 直达 sudo,模型看不到明文。
变更记录要点(官方 CLI changelog)
| 版本 | 关键改动 |
|---|---|
v2026.09.28 | --model / /model 现在运行你所选的精确模型(此前可能静默跑较短基础模型) |
v2026.09.22 | Auto-review:按 permissions.json 里的指令判断 MCP 调用该放行还是拦;修复摘要丢请求 |
v2026.08.26 | 持久会话:agent persist 让 agent 在断开后继续跑;团队模型限制在 CLI 生效 |
官方明确有独立的 Cursor CLI changelog 页,与 IDE / Agents Window / SDK 分栏。 agent --version 查版本,agent update 原地升级。
核验说明
本条目标为 confidence: partial,原因如下。
已核到的:能力与权限面证据充分。 官方 CLI 文档、独立 changelog 页、定价与模型页都已取到正文。
仍缺的:两处结构性缺口(见下面的未知项清单),所以不标 verified。
本轮核到的官方页:
- 官方落地页 —— https://cursor.com/cli
- 官方 CLI changelog —— https://cursor.com/docs/cli/changelog
- CLI Overview —— https://cursor.com/docs/cli/overview
- CLI Headless —— https://cursor.com/docs/cli/headless
- CLI GitHub Actions —— https://cursor.com/docs/cli/github-actions
- CLI Permissions —— https://cursor.com/docs/cli/reference/permissions
- CLI Parameters —— https://cursor.com/docs/cli/reference/parameters
- Models & pricing —— https://cursor.com/docs/models-and-pricing
- 官方定价页 —— https://cursor.com/pricing
- 产品 changelog —— https://cursor.com/changelog
相关条目Related entries
- Cursor同一产品的 IDE 形态;账户、模型目录、
mcp.json与规则共用,差异在运行面与审批默认值 - Claude Code CLI同为终端编码 agent,权限颗粒度与云端会话机制值得对照
- Codex CLI同为厂商官方 CLI,非交互模式与沙箱档位可并排比较
- Filesystem MCP ServerFilesystem MCP Server另一层 · 给 AI 装工具Other layer · Tools for your AI
本页由This page is generated from the ai-agent-guide 数据层生成(CC BY 4.0)。data layer (CC BY 4.0).
方法论与坐标系定义见仓库内 METHODOLOGY.md。