快速入门

本页目录

欢迎使用 Google Antigravity!请参照本指南,在常用开发环境中快速上手。

选择开发环境

下载与安装

  1. Download the Google Antigravity installer for your operating system (or view all builds at antigravity.google/download):

    macOSmacOS 13 (Ventura) or later (Apple Silicon or 64-bit Intel)

    Open the downloaded Antigravity.dmg disk image and drag Antigravity into your Applications folder. If you are upgrading an existing installation, select Replace when prompted instead of Keep Both.

    WindowsWindows 10 (64-bit) or Windows 11

    Run the downloaded .exe installer and follow the guided setup wizard.

    Linuxglibc >= 2.28, glibcxx >= 3.4.25 (Ubuntu 20+, Debian 10+, Fedora 36+, RHEL 8+)

    Extract the archive with tar -xzf Antigravity.tar.gz and launch ./Antigravity.

    GooglebookGooglebook OS (pre-installed on Googlebooks; update or reinstall via Google Play)

    Google Antigravity comes pre-installed on Googlebooks. Open Google Play to install updates or reinstall the application.

  2. Launch Google Antigravity from your applications launcher or menu.

  3. 登录并选择工作区的设置方式:

    • 个人 Google 账号 (v2.30.0+):通过浏览器登录后,Antigravity 会询问最符合您工作性质的选项——软件工程、知识工作、数据与分析、科研、设计或其他(点击跳过即可以默认的软件工程配置启动):

      First-launch role selection screen in Antigravity App asking What best describes your work? with Knowledge Work selected and a Continue button

      您的选择将决定初始界面布局(选择知识工作、科学研究、设计和其他时设为知识工作 (Knowledge Work);选择软件工程和数据与分析时设为软件工程 (Software Engineering)),并在您确认条款与数据使用 (Terms & Data Use) 声明后,在主界面消息框上方显示最多三个可关闭的初始提示词:

      Home message box in Antigravity App with three starter prompts for Google Calendar, Google Drive, and Google Slides

      选择角色时不会直接安装任何插件——点击初始提示词后,系统会在需要时于后台安装与之配对的 Marketplace 插件,预先填入 @<Plugin> 和提示词(但不会直接发送),并选中第一个 <...> 占位符以便你先行编辑(Google Calendar、Drive、Slides 或 Figma 等关联服务会在你运行提示词时提示登录)。选择软件工程 (Software Engineering) 还会包含从其他 Agent 开发工具导入我的配置 (Bring over my setup from other Agentic Developer Tools) 选项,方便你从 Claude Code、Codex、Cursor 和 Gemini CLI 导入 MCP 服务器、skill、规则和指令。你可以随时忽略任何建议,或在设置 > 常规 > 界面布局中切换布局。

    • Gemini Enterprise 与 Google Cloud 账号:在登录时选择 Use Business Account,然后选择为您分配的许可证和 Google Cloud 项目,或者使用您自己的项目按需付费。正在使用 Google Workspace 账号?请参阅 Google Workspace 账号。

  1. Install the Antigravity CLI (agy) binary using the automated installer for your operating system:

    curl -fsSL https://antigravity.google/cli/install.sh | bash

    Default binary location: ~/.local/bin/agy

  2. Open a terminal window and verify the installation:

    agy --version
  3. Complete the interactive terminal configuration on initial launch:

    • Color scheme: Select your visual preference (Dark, Solarized Dark, Solarized Light, or terminal default).
    • Rendering mode: Choose Alt-Screen mode (full-screen buffer) or Inline mode (sequential output in terminal history).
    • Workspace trust: Confirm that you trust the repository directory before the agent begins file indexing.
  1. Install the official Google Antigravity extension for your preferred editor, or download the standalone Antigravity IDE:

    Requirements: Visual Studio Code 1.90 or later on macOS, Linux, or Windows.

    Open the Extensions sidebar (Cmd + Shift + X on macOS or Ctrl + Shift + X on Windows/Linux), search for Google Antigravity, and click Install. See the VS Code extension guide.

  2. 在 Antigravity 面板或设置中收到提示时,使用您的个人 Google 账号或 Gemini Enterprise 凭据登录(IDE 扩展程序现已支持企业版功能:VS Code、Visual Studio、JetBrains、Zed、Xcode 和 Eclipse 已正式发布,Android Studio 目前处于预览版阶段)。

  1. Install the official Antigravity Python package inside a Python 3.10+ virtual environment:

    pip install google-antigravity

    If you use Poetry or uv for package management:

    # Poetry
    poetry add google-antigravity
    
    # uv
    uv add google-antigravity
  2. Authenticate and configure your environment:

    Configure your API credentials in your environment before initializing the agent harness:

    export GEMINI_API_KEY="your_api_key_here"

启动项目

Agents operate within Projects, which define the repository boundaries, file scopes, and security permissions for your workspaces.

  1. Click the New Project icon (folder with a plus sign) in the left sidebar.

  2. Click Add Folder to select one or more local Git repositories or working directories.

  3. 点击 Create(创建)。

  4. Type your instruction in the prompt input (for example: Add unit tests for the authentication handlers) and press Enter.

  5. 在设置弹窗中选择一种模式以启动 Agent(在软件工程界面布局下):

    • 本地模式 (Local mode):Agent 直接在你当前活动的文件夹中执行操作。
    • 新建工作树模式 (New worktree mode):Agent 在隔离的 Git worktree 中执行操作。

    在知识工作界面布局下,对话会直接在项目的文件夹中运行,而不会提示选择 Git worktree;您也可以直接从主页开始对话,无需先创建项目。

Navigate to any codebase directory in your terminal and start a session:

  1. Create or navigate to a project directory and launch the TUI:

    mkdir agy-demo && cd agy-demo
    agy
  2. Enter your first task prompt and press Enter:

    编写一个简单的 Python 脚本来获取网页文本

    Agent 会为工作区建立索引,并在您的工作区中创建 main.py。出现提示时按 Y 批准创建文件(在 auto 模式下,工作区编辑和沙箱内命令会自动运行)。

  3. 随时检查差异或审阅产物:

    • 运行 /diff 打开交互式差异查看器并检查每轮对话所做的更改,或在收到通知时按 Ctrl + R 审阅生成的产物(如实施方案;按 Esc 可返回提示词输入框)。
    • 如果您想在 auto、plan、default 和 accept-edits 执行模式之间切换,请在提示词输入框内按 Shift + Tab。
  4. 使用 Agent 执行测试命令以验证输出:

    运行该 Python 脚本并向我展示输出结果

    按 Y 确认并运行 python3 main.py(在 auto 模式下,Agent 会自动在终端沙箱内运行该命令)。完成后,按 Ctrl + D(或输入 /exit)关闭 TUI 会话。

  1. Open your workspace folder, repository, or solution in your preferred editor.
  2. Open the Antigravity panel or agent view in your IDE (for example, click the Antigravity icon in the VS Code Activity Bar, press Ctrl + \, Ctrl + Alt + L in Visual Studio, select Antigravity > Toggle Chat in Eclipse, or select Antigravity in JetBrains AI, Zed External Agents, or Xcode Intelligence).
  3. Enter a task prompt in the conversation panel to start an agent session that shares context and customizations with the rest of the Antigravity ecosystem.
  4. Inspect interactive implementation plans, review granular inline diffs, and execute multi-step engineering tasks directly inside your editor.
  1. Create a file named hello_agent.py to instantiate and run an autonomous agent:

    import asyncio
    from google.antigravity import Agent, LocalAgentConfig
    
    async def main():
        # Initialize the local agent harness
        config = LocalAgentConfig()
        async with Agent(config) as agent:
            response = await agent.chat("What files are in the current directory and what is their purpose?")
            print(await response.text())
    
    if __name__ == "__main__":
        asyncio.run(main())
  2. Execute the agent script in your terminal:

    python hello_agent.py
  3. Configure declarative tool policies:

    Use LocalAgentConfig and google.antigravity.hooks.policy to define explicit tool execution rules:

    from google.antigravity import LocalAgentConfig
    from google.antigravity.hooks.policy import allow, deny
    
    config = LocalAgentConfig(
        policies=[
            deny("*"),
            allow("view_file"),
        ]
    )

快捷键与命令

操作macOSWindows / Linux描述
Conversation pickerCmd + KCtrl + K按标题或全文搜索历史对话并切换到目标对话
File searchCmd + PCtrl + P按名称搜索当前项目中的文件并打开目标文件
命令Cmd + Shift + PCtrl + Shift + P搜索并运行应用命令
FindCmd + FCtrl + F在当前对话或打开的文件中查找文本
聚焦输入框Cmd + LCtrl + L将光标焦点直接跳转到消息框
新建对话Cmd + NCtrl + NStart a fresh autonomous agent session
上一个或下一个对话Option + ↑ / ↓Alt + ↑ / ↓切换到侧边栏中的上一个或下一个对话

如需详细了解如何搜索对话、文件和命令,请参阅搜索与命令面板。

核心斜杠命令

命令描述
/goalRuns the task autonomously until completion without pausing for intermediate input.
/grill-mePrompts the agent to interview you about requirements before beginning implementation.
/scheduleRuns an instruction as a one-time delayed task or recurring cron schedule.
/browser将实时 UI 测试、屏幕截图和网页检查委派给浏览器子 Agent(个人账号 v2.30.0+ 使用内置浏览器,或使用 Google Chrome)。
/pluginManages installed Marketplace plugins or creates and configures custom plugin bundles.

常用 CLI 命令

命令描述
agyLaunches the interactive TUI in the current directory.
agy -i "prompt"使用初始提示词启动交互式会话。
agy -p "prompt"以非交互方式运行单条提示词并输出响应。
/agentsSwitches between active background subagents.
/statuslineToggles or configures the terminal status line display.
/usageDisplays current model credit consumption and quota limits.
/exitCloses the TUI and restores your original shell session.

键盘快捷键

快捷键操作
Ctrl + ROpen the Artifact Review screen to inspect plans and diffs
Tab 补全Inspect file diffs and tool execution details
Ctrl + CInterrupt current agent generation
Ctrl + OExpand or collapse active tool execution pill
Ctrl + DExit the active Antigravity CLI session
EscExit diff inspector or close active overlay

编辑器命令与快捷键

IDEShortcut / Command操作
VS CodeCmd + Shift + X / Ctrl + Shift + XOpen Extensions sidebar to install or manage Google Antigravity
Visual StudioCtrl + \, Ctrl + Alt + LOpen the Antigravity tool window
ZedCmd + Shift + P / Ctrl + Shift + P → agent: open settingsOpen Agent settings to configure External Agents
JetBrainsJetBrains AI > Settings > AgentsInstall or configure the Antigravity agent
XcodeCmd + , → IntelligenceManage and authenticate Antigravity in Xcode Settings
EclipseCmd + Option + E / Ctrl + Alt + K切换 Antigravity 对话视图

身份验证配置

Auth type (auth.type)Account tier描述
"oauth-personal"Individual Google AccountsAuthenticates personal Free, Pro, and Ultra plans.
"oauth-business"Gemini Enterprise (Preview)Authenticates corporate identity with gcp.project and gcp.location.
"gemini-api-key"Gemini APIAuthenticates using a Gemini API key.
"agent-platform"Agent 平台(预览版)通过 API 密钥或 ADC 使用 Gemini Enterprise API 进行身份验证。

常用 SDK 方法与配置

Method / Command描述
await agent.chat(prompt)Sends a user prompt to the agent and returns the turn response.
LocalAgentConfig(policies=...)Configures declarative tool execution policies (allow, deny, ask_user).
LocalAgentConfig(system_instructions=...)Customizes the agent persona and system instructions.
export GEMINI_API_KEY="..."Sets Gemini API credentials in the environment.

更多资源