Antigravity CLI 入门指南:从安装到第一次运行
众所周知,最近 Antigravity 迎来了一次重大更新
众所周知,最近 Antigravity 迎来了一次重大更新。
这次更新不只是产品形态上的变化,也带出了一个很值得关注的新入口:Antigravity CLI。Antigravity CLI 是终端优先的 Antigravity Agents 操作界面。它可用于各种任务,从编写代码到自动化重复性工作。
Antigravity CLI 是 Antigravity 2 版本的一部分。官方文档说明:“它将 Antigravity 2.0 相同的核心代理能力——包括多步推理、多文件编辑、工具调用和对话历史——直接带到你的终端中。”
参考:https://antigravity.google/product/antigravity-cli
以下是 Antigravity CLI 带来的几个亮点:
更快的执行速度:新的 CLI 用 Go 语言构建,比前代明显更敏捷、响应更快。
异步工作流:这是一个巨大的生产力提升。用户现在可以在后台运行大规模任务(如代码库重构或深度研究)。CLI 会编排 agent 而不锁定活动终端会话。
统一架构:CLI 与新的桌面应用 Antigravity 2.0 共享相同的后端 agent harness。未来核心 agent 的任何改进都会直接落地到终端。

安装
安装很简单,主流操作系统都有二进制包。以下是直接取自安装文档的终端命令:
macOS | Linux
curl -fsSL https://antigravity.google/cli/install.sh | bash
Windows PowerShell
irm https://antigravity.google/cli/install.ps1 | iex
Windows CMD
curl -fsSL https://antigravity.google/cli/install.cmd -o install.cmd && install.cmd && del install.cmd
这通常会在系统中安装 Antigravity CLI(agy)并将其加入 PATH。
例如在我的 MacOS 上,安装程序将可执行文件复制到 /Users/romin/.local/bin/agy,并在 profile 中添加了路径。
# Added by Antigravity CLI installer
export PATH="/Users/romin/.local/bin:$PATH"
在某些情况下,如果安装程序无法将二进制文件(agy)添加到 PATH,它会提示你。例如在另一台机器上,我看到了如下输出,明确告诉你需要做什么:
% curl -fsSL https://antigravity.google/cli/install.sh | bash
⠋ Detecting system environment...
✓ Platform detected: darwin_arm64
⠋ Querying release repository...
✓ Latest available version: 1.0.1
⠋ Downloading release package...
✓ Download complete and checksum verified.
⠋ Extracting binary from archive...
⠋ Configuring shell environment...
I0523 11:44:14.012088 76528 installer.go:27] Running Antigravity CLI setup...
Warning: /Users/neilirani/.local/bin is not present in your active PATH.
To use the 'agy' CLI globally, please manually add it to your shell profile:
echo 'export PATH="/Users/neilirani/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
✅ Antigravity CLI binary placed successfully at /Users/neilirani/.local/bin/agy
Note: The binary is installed, but it is not in your active PATH. Please follow the instructions above to add it, then restart your terminal session.
我建议先创建一个名为 agy-cli-projects 的文件夹,后续教程都基于此。
创建文件夹 agy-cli-projects 并进入。我是在 home 目录下创建的,你可以根据自己的偏好选择位置。
登录 Antigravity CLI
首次启动 Antigravity CLI 时,它会要求你登录。运行 agy,应该会看到类似如下画面:
▄▀▀▄
▀▀▀▀▀▀
▀▀▀▀▀▀▀▀
▄▀▀ ▀▀▄
▄▀▀ ▀▀▄
Welcome to the Antigravity CLI. You are currently not signed in.
Select login method:
> 1. Google OAuth
2. Use a Google Cloud project
[Use arrow keys to navigate, Enter to select]
先用个人账户。选择 1. Google OAuth 并按回车。这会打开一个浏览器窗口,你可以用 Google 账号登录。认证和授权成功后,需要复制一个代码。回到 Antigravity CLI 终端粘贴代码。
登录成功后,有几件事需要处理:
挑一个喜欢的颜色主题,然后接受服务条款,最后授权信任工作目录:
Accessing workspace:
/Users/romin/agy-cli-projects
Do you trust the contents of this project?
Antigravity CLI requires permission to read, edit, and execute files here.
> Yes, I trust this folder
No, exit
↑/↓ Navigate · enter Confirm
Gemini 3.5 Flash (High)
在每个新文件夹中启动 Antigravity CLI 时通常都会看到这个提示。我们稍后系列中会详细说明,现在先选 “Yes, I trust this folder”。
现在一切就绪,等待你的输入:
▄▀▀▄ Antigravity CLI 1.0.1
▀▀▀▀▀▀ <YOUR_ACCOUNT_EMAIL>
▀▀▀▀▀▀▀▀ Gemini 3.5 Flash (High)
▄▀▀ ▀▀▄ ~/agy-cli-projects
▄▀▀ ▀▀▄
───────────────────────────────────────────────────────────
>
───────────────────────────────────────────────────────────
? for shortcuts Gemini 3.5 Flash (Medium)
注意右下角显示它使用的是 Gemini 3.5 Flash。大部分自定义和设置都通过 /config 或 /settings 命令完成。
配置 / 设置
直接输入 /config 命令。这会显示 Antigravity 中可以根据偏好自定义的各种区域,包括颜色方案、工具权限、遥测设置等。
例如,颜色方案会提供以下选项供选择:
settings.json
所有配置设置都存储在 ~/.gemini/antigravity-cli/settings.json 文件中。示例如下:
{
"colorScheme": "dark",
"model": "Gemini 3.5 Flash (High)",
"statusLine": {
"type": "",
"command": "",
"enabled": true
},
"trustedWorkspaces": [
"/Users/romin/antigravity-cli-projects",
"/Users/romin/agy-cli-projects"
]
}
可以看到我选择的 colorScheme、model 以及启动过 Antigravity CLI 并信任过的多个文件夹。
注意:你也可以直接修改 settings.json 并重启 Antigravity CLI 来生效。但如果不确定设置,最好使用 /settings 或 /config 命令来操作这个文件。
工具权限
一个重要的设置是 Tool Permission。你可以通过 /config 命令进入 Tool Permission,或者直接在提示符中使用 /permissions 命令。
Tool Permission
> request-review (current)
proceed-in-sandbox
always-proceed
strict
默认设置为 request-review。我们来详细了解这几种模式:
在 Antigravity 中,Tool Permission 设置在安全(保护主机系统免受非预期更改)和效率(agent 可以多自主地工作而不中断)之间取得平衡。
request-review(当前默认)
在这种模式下,agent 被视为协作伙伴,在执行任何可能影响系统或项目文件的操作之前会先征求意见。
工作方式:每当 agent 尝试运行终端命令、执行文件操作(如写入/删除)或调用尚未预先授权的外部服务时,执行会暂停。用户需要批准或拒绝该特定操作。
例如,agent 需要用 npm install lodash 安装一个包。CLI 不会立即执行命令,而是暂停并显示提示,让你选择是否允许执行。
proceed-in-sandbox
此模式允许 agent 自动执行终端命令,但在安全的隔离容器内进行。Agent 可以无需提示运行命令,但这些命令在虚拟沙箱(如轻量容器)中执行。它们无法修改实际主机文件系统或访问本地网络。
always-proceed
这是完全自主模式,为 agent 提供最大速度和能力。Agent 被授予完全权限,可直接在主机上运行命令和写入文件。它不会提示你确认。
例如,你使用 /goal 命令让 agent 通宵运行一个长任务(如“将我们的样式系统重构为 vanilla CSS,并确保所有组件构建无误”)。Agent 会自主编写数十个文件、运行 npm run build、解决编译器错误、安装辅助包、执行 git 命令。工作完成后从不停下来等待批准。(谨慎使用:仅在受信任的版本控制仓库中使用。)
strict
这是零信任、高安全模式。Agent 的能力仅限于执行读取工具。所有非读取工具需要用户提示操作。
设置模型
你可以使用 /model 命令选择模型。目前可用的模型列表:
Switch Model
> Gemini 3.5 Flash (High) (current)
Gemini 3.5 Flash (Medium)
Gemini 3.1 Pro (High)
Gemini 3.1 Pro (Low)
Claude Sonnet 4.6 (Thinking)
Claude Opus 4.6 (Thinking)
GPT-OSS 120B (Medium)
Keyboard: ↑/↓ Navigate enter Select esc Go Back
你可以根据需要选择任意模型。
退出 Antigravity CLI
通过 /quit 命令退出。如果难以回到提示符输入,使用 esc esc 退出当前状态。
退出时,你会看到恢复对话所需的命令。例如,这是我收到的消息。使用该命令可以恢复对话,并保留你之前给出的所有提示。只需在提示符中使用箭头键(上下)查看历史。
Resume: agy --conversation=bbb2048c-7de6-4dd5-ba7e-8b0c27d46b95 (or -c)
Shell 模式
这类似于 Gemini CLI、Claude Code你可以进入 Shell 模式,从而无需退出 Antigravity CLI 即可执行 shell 命令。
只需使用 ! 进入 Shell 模式。你会注意到提示符前缀从 > 变为 !。
可以执行 ls、pwd 等命令以及其他你拥有的工具。
我们的第一个编程任务
我将在 agy-cli-projects 中创建一个子文件夹,并在其中启动 Antigravity CLI。我把它命名为 bq-release-notes,因为我将构建一个 BigQuery Release Notes Reader 应用。
让我们给 Antigravity CLI 第一个任务:构建一个显示当前 RSS 源内容的 Web 应用。假设我对 BigQuery Release notes 非常感兴趣。它有一个 RSS Feed。我希望用我偏好的技术栈构建一个 Web 应用来访问这个 feed 并展示信息。我从以下提示词开始:
Please build a web application for me using Python Flask and plain vanilla HTML, JavaScript and CSS that fetches the BigQuery Release notes from (https://docs.cloud.google.com/feeds/bigquery-release-notes.xml) and shows them to me. A simple refresh button with a spinner is good enough, anytime I’d like to refresh the details. I would also like the ability to take any specific update, select it and then Tweet about it.
Antigravity CLI 的响应如下:
I will start by exploring the workspace to see if there is an existing structure or if this is a brand new project.
● ListDir(/Users/romin/agy-cli-projects/bq-release-notes) (ctrl+o to expand)
I will read the BigQuery release notes XML feed to understand its structure (Atom/RSS elements, entry/item elements, namespaces, dates, titles, content) so that we can parse it
correctly in the Python Flask backend.
● ReadURL(https://docs.cloud.google.com/feeds/bigquery-release-notes.xml) (ctrl+o to expand)
I will view the fetched feed content saved locally to understand its format and structure.
● Read(/Users/romin/.gemini/antigravity-cli/brain/116191af-e6ea-4ba5-aa23-62f995bd068a/.system_generated/steps/6/content.md) (ctrl+o to expand)
▸ Thought for 2s, 2.3k tokens
Analyzing XML Feed Structure
I will write the implementation plan detailing the architecture, design aesthetic, components, and verification steps for the BigQuery Release Notes Web Application. This plan will be
written to the artifacts directory.
● Create(/Users/romin/.gemini/antigravity-cli/brain/116191af-e6ea-4ba5-aa23-62f995bd068a/implementation_plan.md) (ctrl+o to expand)
I have created the implementation_plan.md to outline the design and architecture of the BigQuery Release Notes Web Application.
Please review the plan, especially the approach for the Twitter Composer & Preview Card, and let me know if you approve or if there are any adjustments you'd like to make!
1 artifact · /artifact to review
/artifact 是 Antigravity CLI 里用来查看和处理 Agent 产物的命令。简单说:当 Agent 在执行任务时,尤其是进入 Planning Mode 后,可能会生成一些中间产物
输入 /artifact 命令。会显示 implementation_plan.md 文件已创建,可以使用箭头键打开、批准、拒绝等。对于之前使用过 Antigravity(非 CLI 应用)的用户来说应该很熟悉。
打开后可以看到整个 artifact 即实现计划。
按 Escape 回到提示符,可以在那里批准它。
或者也可以拒绝或提出修改意见。例如我们走 vibe 模式,直接说 approve。
这会触发下一组步骤:开始实施,即创建文件、运行一些命令等。系统会提示你根据需要批准权限。
在我的例子中,我批准了创建 Python 虚拟环境、通过 requirements.txt 安装依赖等。
后台还根据实现计划创建了一个 task.md 文件,逐个勾选完成的任务。感受一下 agent 的思维过程和完成节奏还是挺有意思的。
然后收到结果消息:
I have successfully completed the implementation of the BigQuery Release Pulse web application!
The application dev server is up and running locally at http://127.0.0.1:5000.
Please refer to the walkthrough.md for details on the architectural implementation, the features we delivered, and verified test scenarios.
我还看到有几个 artifact(Implementation Plan、Task List 和 Walkthrough 文档)。
Action required (3 left)
› task.md open
walkthrough.md
□ new implementation_plan.md
Media · 1 items (enter to expand)
查看 Task artifact:
task.md
> 1 Tasks
2
3 [✓] Setup dependencies and environment
4 [✓] Implement backend Flask application ( app.py )
5 [✓] Implement frontend HTML structure ( templates/index.html )
6 [✓] Implement frontend CSS styling ( static/css/style.css )
7 [✓] Implement frontend JS logic ( static/js/app.js )
8 [✓] Verify local execution and manual test scenarios
9 [✓] Create walkthrough documentation ( walkthrough.md )
顺便问一下(btw)
这是一个非常实用的命令。如果你的主 agent 正在忙于某个长任务,你可以使用 /btw 命令问一个旁路问题。这不会中断当前运行的任务。
最好的尝试方式:给 Antigravity CLI 一个长任务(如生成某个应用),然后在它忙碌时使用 /btw
例如,Agent 正忙于重构代码,你想了解某个 git 命令:
/btw What is the git command to list branches sorted by last commit date?
或者:
/btw what does exit status code 137 typically indicate?
关于 /btw 还有几点:
并行且不中断:如果 agent 当前正在运行长编译脚本或重构多个文件,输入 /btw 不会暂停、中止或延迟该进程。主 agent 任务在后台继续运行。
临时 UI:输出会在终端界面上以临时覆盖面板(类似模态框)的形式呈现。关闭面板时(按 Enter 或 Esc),响应消失。
无副作用(只读上下文):为确保速度和安全,/btw 以只读模式运行。它可以完全读取文件和对话状态,但不能执行工具(如写入文件、运行 bash 命令或调度任务)。
Token 效率:/btw 查询的提示词和响应不会追加到主对话历史中。这防止了随意的问题导致对话上下文膨胀(上下文膨胀)。
了解 Antigravity CLI 的命令行参数
我们启动 Antigravity CLI 时只用了简单的 agy。它使用若干默认值,然后显示终端供你输入命令。
本节介绍启动 Antigravity CLI 时可用的几个命令行选项。
使用 agy –help、agy help 或 agy -h 命令可以查看当前可用的命令行参数列表:
$ agy --help
Usage of agy:
--add-dir Add a directory to the workspace (repeatable) (default [])
-c Short alias for --continue
--continue Continue the most recent conversation
--conversation Resume a previous conversation by ID
--dangerously-skip-permissions Auto-approve all tool permission requests without prompting
-i Short alias for --prompt-interactive
--log-file Override CLI log file path
-p Short alias for --print
--print Run a single prompt non-interactively and print the response
--print-timeout Timeout for print mode wait (default 5m0s)
--prompt Alias for --print
--prompt-interactive Run an initial prompt interactively and continue the session
--sandbox Run in a sandbox with terminal restrictions enabled
Available subcommands:
changelog Show changelog and release notes
help Show help for subcommands
install Configure environment paths and shell settings
plugin Manage plugins (install, uninstall, list, enable, disable)
plugins Alias for plugin
update Update CLI
到目前为止,我们启动 Antigravity CLI 后一直使用交互模式。如果你希望 Antigravity CLI 直接接收提示词、执行并返回结果,可以使用非交互模式。这通过 –prompt 参数(或 -p、–print 参数)实现。
这在需要将 Antigravity CLI 集成到自动化流水线中或在特定时间调度任务时非常有用,无需人工界面。
agy -p "What is the command line syntax for doing a GET call to myhost.com via curl"
这是快速获取答案的好方法。但要注意,无法继续对话进行后续提问。
如果你要求自动化且不怕风险,可以查看一个名为 –dangerously-skip-permissions 的参数。
通过以下命令启动 Antigravity CLI:
agy --dangerously-skip-permissions
然后输入以下提示词(注意它没有询问任何文件写入权限):
> get the latest news and write it in a file called news.txt. Then create another file that contains the summary of that file.
这种模式在本地环境且受你控制的情况下有用,用的时候心里有数就行。
从 Gemini CLI 迁移过来该注意什么
如果你之前在 Gemini CLI 里配过 Extensions、MCP 服务器、Skills 和上下文文件,迁移时有些变化需要注意。具体看文档的迁移章节,会告诉你哪些可以直接导入、哪些有差异:
注意 2026 年 6 月 18 日是 Gemini CLI 个人版和免费版的截止日,之后 Gemini CLI 和 Gemini Code Assist IDE 扩展会停服。详细说明看这篇:
An important update: Transitioning Gemini CLI to Antigravity CLI (developers.googleblog.com)
Google Antigravity - Build the new way
antigravity.google
如果这篇对你有帮助:
• 先收藏,之后配置时直接翻出来用。
• 关注 @vincemask,后面继续拆 Claude Code / Agent 工程化实践。
评论
加载评论…