1. 简介
在此 Codelab 中,我们将向您展示如何使用 Antigravity IDE 在您的计算机上设置一个有趣的 AI 辅助自主 AI 开发者团队。您将使用强大的 skills.md 和 agents.md 工作流,引导需求经历从技术规范到最终部署的整个生命周期,从而构建一个可正常运行的应用。
我们不会局限于特定的技术堆栈或编写复杂的 Python 编排脚本,而是采用友好的零代码方法,让您的需求通过由三个核心 Antigravity 原则驱动的自动化周期来完成:
agents.md:明确定义 AI 团队的成员(产品经理、前端、质检、DevOps)。- 技能和 skills.md:一个专用目录,您可以在其中将强大的技术能力和制品交付规则定义为模块化
.md文件。 - 工作流 (workflows/):用于定义自定义斜杠命令,以便将 AI 团队成员无缝链接到自主流水线中。
通过在 Antigravity 中原生组合这三个要素,您可以引导 Gemini 完全自动地开发一个可用于生产用途的应用,从头到尾!
学习内容
- 初始化工作区:设置项目,以便 Antigravity 深入了解项目。
- 定义团队:创建
agents.md文件以建立专业 AI 角色。 - 对技能进行编程:在
skills/目录中构建详细的.md文件,以定义严格的技术规则和迭代返工循环。 - 定义自定义工作流:创建
/startcycle斜杠命令以自动执行工作室的工作流。 - 启动连锁反应:使用单个命令即可高效自动执行整个多代理流水线!
尝试内容
- 如何将 AI 提示工程与应用代码分离。
- 如何构建一个代理,使其能够主动暂停,以便解读生成的 Markdown 文件中的用户评论和修改。
- 如何构建动态的、与语言无关的代码生成和部署技能。
- 如何在代理式 IDE 中构建自定义宏命令(工作流)。
所需条件
- Antigravity
- Chrome 浏览器
- 已在本地安装 Node.js (v18+) 或 Python 3.14
- (可选)在本地安装 gcloud CLI
准备工作
对于 Google Cloud 赠金:为帮助您将 Antigravity 与 Google Cloud 项目搭配使用,请使用此链接兑换免费 Google Cloud 赠金。您可以按照此处的说明激活赠金并创建新项目。
- 确保您已安装 Antigravity IDE(可在 antigravity.google 中获取)。
- 打开 Antigravity IDE,确保您已初始化新的专用工作区。
- 在编辑器模式下工作时,保持终端处于打开状态。
2. 初始化工作区
由于 Antigravity 可以原生理解放置在 .agents 目录中的工作流文件,因此设置自主开发者流水线非常简单,只需创建几个标准文件夹即可。
您可以设置工作区:
- 打开 Antigravity IDE。
- 打开 Agent Manager 您可以随时按 CMD+E (Mac) 或 CTRL+E (Windows) 在 Agent Manager 和编辑器之间切换,也可以通过菜单栏右上角的“打开编辑器”和“打开 Agent Manager”按钮进行切换。。
- 点击 + 打开工作区。
如需在工作区内发起新对话,请从“开始对话”标签页中选择所需的工作区,或点击边栏中工作区名称旁边的加号按钮。

- 点击“打开新工作区”,将工作区命名为
skills-codelab,然后选择一个本地目录。这样可确保代理拥有特定的根文件夹来搭建文件,而不会使其他项目杂乱无章。完成后,前往编辑器视图,然后执行步骤 (5)、(6) 和 (7)。

- 右键点击并创建
skills-codelab文件夹。 - 在其中创建两个目录:
production_artifacts和app_build。 - 创建一个
.agents目录,并在其中创建workflows和skills文件夹。
(可选)如果您更喜欢使用终端,可以运行以下命令立即生成此结构:
mkdir skills-codelab && cd skills-codelab
mkdir -p .agents/workflows .agents/skills
mkdir production_artifacts app_build
确保您的文件夹如下所示:

这些新文件夹有何用途?
.agents/:这是 Antigravity 原生识别的特殊目录。通过将文件放置在此处,您可以扩展 Antigravity 的内置 AI 行为。skills/:此文件夹用于存储 AI 的特定技术说明手册(.md文件)。这会告诉 AI 如何执行特定任务(例如编写代码或部署应用),从而用模块化步骤取代一个庞大而令人困惑的提示!- p
roduction_artifacts/:这是我们的共享文件夹,我们的自动化团队成员会故意将文件放入其中,以便下一个客服人员读取! app_build/:用于存放实际应用代码的指定工作区。全栈工程师代理会生成所有代码(例如package.json、app.py、React 组件),并直接将其保存到此文件夹中,从而将应用源代码与 AI 的指令隔离开来。
3. 定义团队 (agents.md)
首先,我们需要告知 Antigravity 谁在负责此项目。我们不再将说明放在四个不同的嵌套项目文件夹中,而是集中管理团队的身份。在 .agents/agents.md 中创建文件:
为什么需要不同的角色?
如果您要求 AI 从头开始构建整个应用,并同时担任架构师、程序员、测试人员和部署主管,它很容易不堪重负。通过在 agents.md 中集中管理这些角色,您可以防止 AI 混淆。项目经理只关注需求,工程师只关注代码生成,而 QA 只关注 bug 修复。您可以在流水线的每个阶段获得专业专家的帮助!
agents.md 文件通过集中管理团队的不同用户角色来解决此问题:
- 产品经理 (
@pm):只关注大局。它们会编写 Technical_Specification.md,并与您(人类)一起管理来回审批流程。 - 全栈工程师 (
@engineer):不担心规划;他们只会根据项目经理的规范,专注于以您认可的任何语言编写高质量的代码。 - 质量检查工程师 (
@qa):以全新的视角进行检查。他们不会编写新功能,而是专注于在工程师的代码中查找缺失的依赖项、语法错误或逻辑错误。 - DevOps Master (
@devops):严格专注于运行时环境。他们知道如何读取终端、安装软件包(npm install、pip install)以及启动本地服务器。
# 🤖 The Autonomous Development Team
## The Product Manager (@pm)
You are a visionary Product Manager and Lead Architect with 15+ years of experience.
**Goal**: Translate vague user ideas into comprehensive, robust, and technology-agnostic Technical Specifications.
**Traits**: Highly analytical, user-centric, and structured. You never write code; you only design systems.
**Constraint**: You MUST always pause for explicit user approval before considering your job done. You are highly receptive to user feedback and will enthusiastically re-write specifications based on inline comments.
## The Full-Stack Engineer (@engineer)
You are a 10x senior polyglot developer capable of adapting to any modern tech stack.
**Goal**: Translate the PM's Technical Specification into a beautiful, perfectly structured, production-ready application.
**Traits**: You write clean, DRY, well-documented code. You care deeply about modern UI/UX and scalable backend logic.
**Constraint**: You strictly follow the approved architecture. You do not make assumptions—if the spec says Python, you use Python. You always save your code into the `app_build/` directory.
## The QA Engineer (@qa)
You are a meticulous Quality Assurance engineer and security auditor.
**Goal**: Scrutinize the Engineer's code to guarantee production-readiness.
**Traits**: Detail-oriented, paranoid about security, and relentless in finding edge cases.
**Focus Areas**: You aggressively hunt for missing dependencies in configurations, unhandled promises, syntax errors, and logic bugs. You proactively fix them.
## The DevOps Master (@devops)
You are the elite deployment lead and infrastructure wizard.
**Goal**: Take the final code in `app_build/` and magically bring it to life on a local server.
**Traits**: You excel at terminal commands and environment configurations.
**Expertise**: You fluently use tools like `npm`, `pip`, or native runners. You install all necessary modules seamlessly and provide the local URL directly to the user so they can see the final product!
请注意我们如何为每种角色定义目标、特征和限制条件。
- 目标会告知代理在流水线中的确切职责。
- 特质赋予了它行为个性,告诉它该如何行动(例如“10 倍高级开发者”或“对安全性非常谨慎”)。
- 限制充当严格的护栏(例如,“绝不编写代码”“严格遵循已获批准的架构”)。
以这种方式构建提示可大幅减少 AI 幻觉,并确保代理严格遵循您所需的工作流程!
确保您的文件夹如下所示:
4. 对专业技能 (skills/) 进行编程
详细的指令工程是实现零代码魔法的关键。我们将为每项技能创建高度具体化的文本文件,确保 PM 在您要求返工时主动向后循环。
1. 规范技能
这项技能是起点。PM 代理会使用它来采访您,并在编写任何代码之前完善架构,从而避免浪费数小时的潜在编码时间!
创建 .agents/skills/write_specs.md:
# Skill: Write Specs
## Objective
Your goal as the Product Manager is to turn raw user ideas into rigorous technical specifications and **pause for user approval**.
## Rules of Engagement
- **Artifact Handover**: Save all your final output back to the file system.
- **Save Location**: Always output your final document to `production_artifacts/Technical_Specification.md`.
- **Approval Gate**: You MUST pause and actively ask the user if they approve the architecture before taking any further action.
- **Iterative Rework**: If the user leaves comments directly inside the `Technical_Specification.md` or provides feedback in chat, you must read the document again, apply the requested changes, and ask for approval again!
## Instructions
1. **Analyze Requirements**: Deeply analyze the user's initial idea request.
2. **Draft the Document**: Your specification MUST include:
- **Executive Summary**: A brief, high-level overview.
- **Requirements**: Functional and non-functional requirements.
- **Architecture & Tech Stack**: Suggest the absolute best framework (e.g., Python/Django, Node/Express, React/Next.js) for the job and outline the layout/API structure.
- **State Management**: Briefly outline how data should flow.
3. Save the document to disk.
4. **Halt Execution**: Explicitly ask the user: "Do you approve of this tech stack and specification? You can safely open `Technical_Specification.md` and add comments or modifications if you want me to rework anything!" Wait for their "Yes" or feedback before the sequence continues!
请注意严格的“审批关口”。AI 不会一次性构建整个应用,然后希望它是正确的,而是会明确指示其暂停、等待您的最终决定,并在您留下内嵌注释时主动重新读取文档!
2. 全栈生成技能
此技能是核心构建器。工程师代理会从 PM 的规范中读取确切的技术栈,并动态搭建所有必要的前端和后端代码文件。
创建 .agents/skills/generate_code.md:
# Skill: Generate Code
## Objective
Your goal as the Full-Stack Engineer is to write the physical code based entirely on the PM's approved specification.
## Rules of Engagement
- **Dynamic Coding**: You are not limited to HTML/JS. You must write code in the exact language/framework defined in the approved `Technical_Specification.md`.
- **Save Location**: Save all your raw code, accurately retaining necessary folder structures, directly inside `app_build/`.
## Instructions
1. **Read the Spec**: Open and carefully study `production_artifacts/Technical_Specification.md`.
2. **Scaffold Structure**: Generate all core backend and frontend application files.
3. **Output**: Dump your code perfectly into the `app_build/` directory. Do not skip or summarize any code blocks. Ensure all `package.json` or `requirements.txt` files are present.
此技能没有预定义的堆栈(例如 Next.js 或 Django)。它明确依赖于 PM 选择的动态技术堆栈。这意味着,您只需开发一个代码生成技能,即可用于规范中批准的任何框架!
3. 审核技能
这项技能可提供安全保障。质量保证代理充当独立审核员,专门负责在新生成的代码中查找缺失的依赖项和逻辑错误。
创建 .agents/skills/audit_code.md:
# Skill: Audit Code
## Objective
Your goal as the QA Engineer is to ensure the generated code is perfectly functional natively.
## Rules of Engagement
- **Target Context**: Your focus area is the `app_build/` directory.
## Instructions
1. **Assess Alignment**: Compare the raw code against the approved `Technical_Specification.md`.
2. **Bug Hunting**: Find and fix dependency mismatches, unhandled errors, and logic breaks.
3. **Commit Fixes**: Overwrite any flawed files in `app_build/` with your polished revisions.
在编写大量代码时,生成式 AI 自然会犯一些小的语法错误。通过设置单独的审核技能(其唯一任务是查找错误),我们可以大幅提高运行最终应用的成功率。
4. 动态部署技能
此技能可让应用生动起来。DevOps 代理会确定构建的应用类型(Node、Python 等),并安全地运行安装模块和启动服务器所需的终端命令。
创建 .agents/skills/deploy_app.md:
# Skill: Deploy App
## Objective
Your goal as DevOps is to intelligently package the application and fire up a server based on the chosen stack.
## Instructions
1. **Stack Detection**: Inspect the `Technical_Specification.md` and the files in `app_build/` to figure out what stack is being used.
2. **Install Dependencies**: Use your native terminal to navigate into `app_build/` and run `npm install`, `pip install -r requirements.txt`, or whatever is appropriate!
3. **Host Locally**: Execute the appropriate native terminal command (e.g., `npm run dev`, `python3 app.py`) to start a background server.
4. **Report**: Output the clickable localhost link to the user and celebrate a successful launch!
我们利用 IDE 安全运行原生终端命令的功能。
该代理就像真正的 DevOps 工程师一样,会根据其在 app_build/ 文件夹中实际看到的文件动态确定要运行的安装命令!
(可选)5. Cloud Run 部署技能
如果您想直接将应用投入生产环境,而不是仅在本地运行,可以创建替代部署技能。由于 Antigravity 直接在本地机器上运行,因此 AI 可以无缝利用本地经过身份验证的 gcloud CLI!
创建 .agents/skills/deploy_cloud_run.md:
# Skill: Deploy to Cloud Run
## Objective
Your goal as DevOps is to package the application into a container and deploy it to Google Cloud Run.
## Instructions
1. **Verify Environment**: Ensure the necessary files for the chosen tech stack are in `app_build/`.
2. **Containerize**: Use the IDE terminal to navigate to `app_build/` and run `gcloud run deploy --source .`.
3. **Configure**: If prompted by the CLI tool, automatically select the default region and allow unauthenticated invocations so the web app is public.
4. **Report**: Output the live production Google Cloud Run URL to the user!
5. 定义自定义斜杠命令
自定义斜杠命令的作用是什么?
通过将此文本文件保存在 .agents/workflows/ 中,您可以直接在 Antigravity 的聊天界面中注册一个全新命令!
/startcycle 命令充当自动化编排器,而不是手动逐步提示 AI(“充当 PM 并撰写规范…”然后“好的,现在充当工程师并编写代码…”)。它可将您定义的角色及其特定技能无缝串联起来,形成一个连续的自动化序列!我们将创建一个宏来处理代理之间的切换,并明确管理 PM 阶段的返工循环。
创建 .agents/workflows/startcycle.md:
---
description: Start the Autonomous AI Developer Pipeline sequence with a new idea
---
When the user types `/startcycle <idea>`, orchestrate the development process strictly using `.agents/agents.md` and `.agents/skills/`.
### Execution Sequence:
1. Act as the **Product Manager** and execute the `write_specs.md` skill using the `<idea>`.
*(Wait for the user to explicitly approve the spec. If the user provides feedback or adds comments directly to the Markdown file, act as the PM again to re-read and revise the document. Loop this step until they type "Approved").*
2. Shift context, act as the **Full-Stack Engineer**, and execute the `generate_code.md` skill.
3. Shift context, act as the **QA Engineer**, and execute the `audit_code.md` skill.
4. Shift context, act as the **DevOps Master**, and execute the `deploy_app.md` skill.
确保您的文件夹如下所示:

6. 开始链式反应!
在 Antigravity 中正式定义团队和规则后,您就可以轻松触发整个工作流程!
提示 Antigravity:
- 在 Agent Manager 对话框中,输入 / 以打开自定义命令菜单。选择或输入
startcycle。 - 向其提供您的想法:
/startcycle "I need a fast, real-time chat application for customer support on my ecommerce website."
坐下来,开始协作:
- Gemini 成为 PM,起草了一份完善的规范,并征求您的批准。
- 在 IDE 编辑器中打开
Technical_Specification.md,添加一些笔记(例如“Let's use Python instead of Node”),然后让代理重新处理它。它会自主修改文件! - 获得您的批准后,Gemini 会自然而然地将上下文切换到工程师,并使用已获批准的规范来编写后端/前端代码。
- 它会成为质量检查工程师,修复所有错误,并保存最终代码。
- 最后,DevOps Master 会动态安装模块,并将应用提供给您的浏览器!
Technical_Specification.md 的运行示例,等待审批或评论

用户在提示中批准后,整个工作流便会开始。

7. 总结与后续步骤
恭喜!您已学习如何将协作迭代循环和动态全栈应用生成注入到代理流水线中!
在此 Codelab 中,我们介绍了以下内容:
- 如何使用 .agents/agents.md 映射 AI 角色。
- 在
.agents/skills/write_specs.md中构建协作返工循环,以便代理读取您的内嵌 Markdown 注释。 - 构建了动态
.md技能,可根据获批的规范在任何框架(Python、React)中编写代码!