adk-scaffold
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseADK Project Scaffolding Guide
ADK 项目脚手架指南
Use the CLI (via ) to create new ADK agent projects or enhance existing ones with deployment, CI/CD, and infrastructure scaffolding.
agent-starter-packuvx使用 CLI(通过)创建新的ADK Agent项目,或为现有项目添加部署、CI/CD和基础设施脚手架。
agent-starter-packuvxStep 1: Gather Requirements
步骤1:收集需求
Ask these questions in two rounds. Start with the use case, then move to architecture.
Start with the use case, then ask follow-ups based on answers.
Always ask:
- What problem will the agent solve? — Core purpose and capabilities
- External APIs or data sources needed? — Tools, integrations, auth requirements
- Safety constraints? — What the agent must NOT do, guardrails
- Deployment preference? — Prototype first (recommended) or full deployment? If deploying: Agent Engine or Cloud Run?
Ask based on context:
- If retrieval or search over data mentioned (RAG, semantic search, vector search, embeddings, similarity search, data ingestion) → Datastore? Use :
--agent agentic_rag --datastore <choice>- — for embeddings, similarity search, vector search
vertex_ai_vector_search - — for document search, search engine
vertex_ai_search
- If agent should be available to other agents → A2A protocol? Use to expose the agent as an A2A-compatible service.
--agent adk_a2a - If full deployment chosen → CI/CD runner? GitHub Actions (default) or Google Cloud Build?
- If Cloud Run chosen → Session storage? In-memory (default), Cloud SQL (persistent), or Agent Engine (managed).
- If deployment with CI/CD chosen → Git repository? Does one already exist, or should one be created? If creating, public or private?
分两轮询问以下问题。先从用例入手,再转向架构相关问题。
先了解用例,再根据回答进行后续提问。
必问问题:
- 该Agent将解决什么问题? — 核心用途和能力
- 是否需要外部API或数据源? — 工具、集成、认证要求
- 有哪些安全约束? — Agent绝对不能执行的操作、防护规则
- 部署偏好? — 先做原型(推荐)还是直接完整部署?如果选择部署:用Agent Engine还是Cloud Run?
根据上下文追加提问:
- 如果提到基于数据的检索或搜索(RAG、语义搜索、向量搜索、嵌入、相似度搜索、数据摄入)→ 是否需要数据存储? 使用:
--agent agentic_rag --datastore <选项>- — 用于嵌入、相似度搜索、向量搜索
vertex_ai_vector_search - — 用于文档搜索、搜索引擎场景
vertex_ai_search
- 如果该Agent需要被其他Agent调用 → 是否支持A2A协议?使用将Agent暴露为兼容A2A协议的服务。
--agent adk_a2a - 如果选择完整部署 → CI/CD执行器选什么?GitHub Actions(默认)还是Google Cloud Build?
- 如果选择Cloud Run → 会话存储方式?内存存储(默认)、Cloud SQL(持久化)还是Agent Engine(托管式)?
- 如果选择带CI/CD的部署 → 是否已有Git仓库?还是需要创建新仓库?如果创建,设为公开还是私有?
Step 2: Write DESIGN_SPEC.md
步骤2:编写DESIGN_SPEC.md
Compose a detailed spec with these sections. Present the full spec for user approval before scaffolding.
markdown
undefined撰写包含以下章节的详细规格文档。在执行脚手架搭建前,需将完整规格文档提交给用户确认。
markdown
undefinedDESIGN_SPEC.md
DESIGN_SPEC.md
Overview
概述
2-3 paragraphs describing the agent's purpose and how it works.
用2-3段文字描述Agent的用途和工作原理。
Example Use Cases
示例用例
3-5 concrete examples with expected inputs and outputs.
3-5个具体示例,包含预期输入和输出。
Tools Required
所需工具
Each tool with its purpose, API details, and authentication needs.
列出每个工具的用途、API细节和认证需求。
Constraints & Safety Rules
约束与安全规则
Specific rules — not just generic statements.
具体规则——而非泛泛而谈的表述。
Success Criteria
成功标准
Measurable outcomes for evaluation.
可衡量的评估指标。
Edge Cases to Handle
需要处理的边缘场景
At least 3-5 scenarios the agent must handle gracefully.
The spec should be thorough enough for another developer to implement the agent without additional context.
---至少3-5个Agent需能优雅处理的场景。
规格文档需足够详尽,确保其他开发者无需额外上下文即可实现该Agent。
---Step 3: Create or Enhance the Project
步骤3:创建或增强项目
Create a New Project
创建新项目
bash
uvx agent-starter-pack create <project-name> \
--agent <template> \
--deployment-target <target> \
--region <region> \
--prototype \
-yConstraints:
- Project name must be 26 characters or less, lowercase letters, numbers, and hyphens only.
- Do NOT the project directory before running
mkdir— the CLI creates it automatically. If you mkdir first,createwill fail or behave unexpectedly.create - Auto-detect the guidance filename based on the IDE you are running in and pass accordingly.
--agent-guidance-filename - When enhancing an existing project, check where the agent code lives. If it's not in , pass
app/(e.g.--agent-directory <dir>). Getting this wrong causes enhance to miss or misplace files.--agent-directory agent
bash
uvx agent-starter-pack create <project-name> \
--agent <template> \
--deployment-target <target> \
--region <region> \
--prototype \
-y约束条件:
- 项目名称必须**≤26个字符**,仅包含小写字母、数字和连字符。
- 运行命令前不要手动创建项目目录——CLI会自动创建目录。如果提前创建,
create命令可能失败或出现异常行为。create - 根据当前运行的IDE自动检测指南文件名,并相应传递参数。
--agent-guidance-filename - 增强现有项目时,检查Agent代码的存放位置。如果不在目录下,需传递
app/参数(例如--agent-directory <dir>)。参数错误会导致增强操作遗漏或错误放置文件。--agent-directory agent
Create Flags
创建命令参数
| Flag | Short | Default | Description |
|---|---|---|---|
| | | Agent template (see template table below) |
| | | Deployment target ( |
| | GCP region | |
| | off | Skip CI/CD and Terraform (recommended for first pass) |
| | | |
| | — | Datastore for data ingestion ( |
| | Session storage ( | |
| | off | Skip confirmation prompts |
| | off | Skip GCP/Vertex AI verification checks |
| | | Agent code directory name |
| | — | Use Google AI Studio instead of Vertex AI |
| | Guidance file name ( | |
| off | Enable debug logging for troubleshooting |
| 参数 | 简写 | 默认值 | 描述 |
|---|---|---|---|
| | | Agent模板(见下方模板列表) |
| | | 部署目标( |
| | GCP区域 | |
| | 关闭 | 跳过CI/CD和Terraform(首次构建推荐使用) |
| | CI/CD执行器( | |
| | — | 数据摄入用的存储服务( |
| | 会话存储方式( | |
| | 关闭 | 跳过确认提示 |
| | 关闭 | 跳过GCP/Vertex AI验证检查 |
| | | Agent代码目录名称 |
| | — | 使用Google AI Studio而非Vertex AI |
| | 指南文件名( | |
| 关闭 | 启用调试日志用于故障排查 |
Enhance an Existing Project
增强现有项目
bash
uvx agent-starter-pack enhance . \
--deployment-target <target> \
-yRun this from inside the project directory (or pass the path instead of ).
.bash
uvx agent-starter-pack enhance . \
--deployment-target <target> \
-y在项目目录内运行该命令(或传递项目路径替代)。
.Enhance Flags
增强命令参数
All create flags are supported, plus:
| Flag | Short | Default | Description |
|---|---|---|---|
| | directory name | Project name for templating |
| | — | Override base template (e.g. |
| off | Preview changes without applying | |
| off | Force overwrite all files (skip smart-merge) |
支持所有创建命令参数,新增以下参数:
| 参数 | 简写 | 默认值 | 描述 |
|---|---|---|---|
| | 目录名称 | 用于模板渲染的项目名称 |
| | — | 覆盖基础模板(例如 |
| 关闭 | 预览变更但不实际应用 | |
| 关闭 | 强制覆盖所有文件(跳过智能合并) |
Common Workflows
常见工作流
Always ask the user before running these commands. Present the options (CI/CD runner, deployment target, etc.) and confirm before executing.
bash
undefined执行以下命令前必须先询问用户。列出选项(CI/CD执行器、部署目标等)并确认后再执行。
bash
undefinedAdd deployment to an existing prototype
为现有原型添加部署能力
uvx agent-starter-pack enhance . --deployment-target agent_engine -y
uvx agent-starter-pack enhance . --deployment-target agent_engine -y
Add CI/CD pipeline (ask: GitHub Actions or Cloud Build?)
添加CI/CD流水线(询问:选GitHub Actions还是Cloud Build?)
uvx agent-starter-pack enhance . --cicd-runner github_actions -y
uvx agent-starter-pack enhance . --cicd-runner github_actions -y
Add RAG with data ingestion
添加带数据摄入的RAG功能
uvx agent-starter-pack enhance . --base-template agentic_rag --datastore vertex_ai_search -y
uvx agent-starter-pack enhance . --base-template agentic_rag --datastore vertex_ai_search -y
Preview what would change (dry run)
预览即将发生的变更(试运行)
uvx agent-starter-pack enhance . --deployment-target cloud_run --dry-run -y
---uvx agent-starter-pack enhance . --deployment-target cloud_run --dry-run -y
---Template Options
模板选项
| Template | Deployment | Description |
|---|---|---|
| Agent Engine, Cloud Run | Standard ADK agent (default) |
| Agent Engine, Cloud Run | Agent-to-agent coordination (A2A protocol) |
| Agent Engine, Cloud Run | RAG with data ingestion pipeline |
| 模板 | 部署支持 | 描述 |
|---|---|---|
| Agent Engine、Cloud Run | 标准ADK Agent(默认) |
| Agent Engine、Cloud Run | 支持Agent间协同(A2A协议) |
| Agent Engine、Cloud Run | 带数据摄入流水线的RAG Agent |
Deployment Options
部署选项
| Target | Description |
|---|---|
| Managed by Google (Vertex AI Agent Engine). Sessions handled automatically. |
| Container-based deployment. More control, requires Dockerfile. |
| No deployment scaffolding. Code only. |
| 目标 | 描述 |
|---|---|
| 由Google托管(Vertex AI Agent Engine),自动处理会话。 |
| 基于容器的部署,可控性更强,需要Dockerfile。 |
| 仅生成代码,不添加部署脚手架。 |
"Prototype First" Pattern (Recommended)
“先做原型”模式(推荐)
Start with to skip CI/CD and Terraform. Focus on getting the agent working first, then add deployment later with :
--prototypeenhancebash
undefined使用参数跳过CI/CD和Terraform,先专注于让Agent正常工作,之后再用命令添加部署能力:
--prototypeenhancebash
undefinedStep 1: Create a prototype
步骤1:创建原型
uvx agent-starter-pack create my-agent --agent adk --prototype -y
uvx agent-starter-pack create my-agent --agent adk --prototype -y
Step 2: Iterate on the agent code...
步骤2:迭代优化Agent代码...
Step 3: Add deployment when ready
步骤3:准备就绪后添加部署能力
uvx agent-starter-pack enhance . --deployment-target agent_engine -y
undefineduvx agent-starter-pack enhance . --deployment-target agent_engine -y
undefinedAgent Engine and session_type
Agent Engine与session_type
When using as the deployment target, Agent Engine manages sessions internally. If your code sets a , clear it — Agent Engine overrides it.
agent_enginesession_type当使用作为部署目标时,Agent Engine会在内部管理会话。如果代码中设置了,请清除该设置——Agent Engine会覆盖此配置。
agent_enginesession_typeStep 4: Save DESIGN_SPEC.md and Load Dev Workflow
步骤4:保存DESIGN_SPEC.md并加载开发工作流
After scaffolding, save the approved spec from Step 2 to the project root as .
DESIGN_SPEC.mdThen immediately load — it contains the development workflow, coding guidelines, and operational rules you must follow when implementing the agent.
/adk-dev-guide脚手架搭建完成后,将步骤2中确认通过的规格文档保存到项目根目录,命名为。
DESIGN_SPEC.md随后立即加载——该文档包含开发工作流、编码规范和运营规则,是你实现Agent时必须遵循的指南。
/adk-dev-guideScaffold as Reference
脚手架作为参考工具
When you need specific files (Terraform, CI/CD workflows, Dockerfile) but don't want to scaffold the current project directly, create a temporary reference project in :
/tmp/bash
uvx agent-starter-pack create /tmp/ref-project \
--agent adk \
--deployment-target cloud_run \
--cicd-runner github_actions \
-yInspect the generated files, adapt what you need, and copy into the actual project. Delete the reference project when done.
This is useful for:
- Non-standard project structures that can't handle
enhance - Cherry-picking specific infrastructure files
- Understanding what ASP generates before committing to it
当你需要特定文件(Terraform配置、CI/CD工作流、Dockerfile)但不想直接对当前项目进行脚手架操作时,可以在目录下创建临时参考项目:
/tmp/bash
uvx agent-starter-pack create /tmp/ref-project \
--agent adk \
--deployment-target cloud_run \
--cicd-runner github_actions \
-y查看生成的文件,提取需要的内容并适配到实际项目中,完成后删除参考项目。
这种方式适用于:
- 命令无法处理的非标准项目结构
enhance - 挑选特定的基础设施文件
- 在正式使用ASP生成内容前了解其输出
Critical Rules
关键规则
- NEVER change the model in existing code unless explicitly asked
- NEVER before
mkdir— the CLI creates the directory; pre-creating it causes enhance mode instead of create modecreate - NEVER create a Git repo or push to remote without asking — confirm repo name, public vs private, and whether the user wants it created at all
- Always ask before choosing CI/CD runner — present GitHub Actions and Cloud Build as options, don't default silently
- Agent Engine clears session_type — if deploying to , remove any
agent_enginesetting from your codesession_type - Start with for quick iteration — add deployment later with
--prototypeenhance - Project names must be ≤26 characters, lowercase, letters/numbers/hyphens only
- 除非明确要求,否则绝不要修改现有代码中的模型
- 运行命令前绝不要手动创建目录——CLI会自动创建目录;提前创建会触发增强模式而非创建模式
create - 未经询问绝不要创建Git仓库或推送到远程——确认仓库名称、公开/私有属性,以及用户是否需要创建仓库
- 选择CI/CD执行器前必须询问用户——列出GitHub Actions和Cloud Build选项,不要默认选择
- Agent Engine会清除session_type——如果部署到,请删除代码中所有
agent_engine设置session_type - 优先使用参数快速迭代,之后再用
--prototype添加部署能力enhance - 项目名称必须≤26个字符,仅包含小写字母、数字和连字符
Examples
示例
Using scaffold as reference:
User says: "I need a Dockerfile for my non-standard project"
Actions:
- Create temp project:
uvx agent-starter-pack create /tmp/ref --agent adk --deployment-target cloud_run -y - Copy relevant files (Dockerfile, etc.) from /tmp/ref
- Delete temp project Result: Infrastructure files adapted to the actual project
将脚手架作为参考工具:
用户需求:“我需要为我的非标准项目生成一个Dockerfile”
操作步骤:
- 创建临时项目:
uvx agent-starter-pack create /tmp/ref --agent adk --deployment-target cloud_run -y - 从/tmp/ref目录复制相关文件(如Dockerfile)
- 删除临时项目 结果:基础设施文件适配到实际项目中
Troubleshooting
故障排查
uvx
command not found
uvxuvx
命令未找到
uvxInstall :
uvcurl -LsSf https://astral.sh/uv/install.sh | shIf is not an option, use pip instead:
uvbash
undefined安装:
uvcurl -LsSf https://astral.sh/uv/install.sh | sh如果无法使用,可以改用pip:
uvbash
undefinedmacOS/Linux
macOS/Linux
python -m venv .venv && source .venv/bin/activate
python -m venv .venv && source .venv/bin/activate
Windows
Windows
python -m venv .venv && .venv\Scripts\activate
pip install agent-starter-pack
agent-starter-pack create <project-name> ...
undefinedpython -m venv .venv && .venv\Scripts\activate
pip install agent-starter-pack
agent-starter-pack create <project-name> ...
undefined