google-agents-cli-scaffold
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseADK Project Scaffolding Guide
ADK项目脚手架指南
Use the CLI to create new ADK agent projects or enhance existing ones with deployment, CI/CD, and infrastructure scaffolding.
agents-cli使用 CLI创建新的ADK Agent项目,或为现有项目添加部署、CI/CD和基础设施脚手架以增强项目功能。
agents-cliPrerequisite: Clarify Requirements (MANDATORY for new projects)
前置条件:明确需求(新项目必填)
Before scaffolding a new project, load and complete Phase 0 — clarify the user's requirements before running any command. Ask what the agent should do, what tools/APIs it needs, and whether they want a prototype or full deployment.
/google-agents-cli-workflowscaffold create在搭建新项目脚手架之前,请加载并完成第0阶段——在运行任何命令之前,先明确用户的需求。询问Agent应实现的功能、所需的工具/API,以及用户需要原型还是完整部署版本。
/google-agents-cli-workflowscaffold createStep 1: Choose Architecture
步骤1:选择架构
Mapping user choices to CLI flags:
| Choice | CLI flag |
|---|---|
| RAG with vector search | |
| RAG with document search | |
| A2A protocol | |
| Prototype (no deployment) | |
| Deployment target | |
| CI/CD runner | |
| Session storage | |
用户选择与CLI参数的映射:
| 选择 | CLI参数 |
|---|---|
| 带向量搜索的RAG | |
| 带文档搜索的RAG | |
| A2A协议 | |
| 原型(无部署) | |
| 部署目标 | |
| CI/CD运行器 | |
| 会话存储 | |
Product name mapping
产品名称映射
The platform formerly known as "Vertex AI" is now Gemini Enterprise Agent Platform (short: Agent Platform). Users may refer to products by different names. Map them to the correct CLI values:
| User may say | CLI value |
|---|---|
| Agent Engine, Vertex AI Agent Engine, Agent Runtime | |
| Vertex AI Search, Agent Search | |
| Vertex AI Vector Search, Vector Search | |
| Agent Engine sessions, Agent Platform Sessions | |
The Python SDK package name is unchanged.
vertexai原名为「Vertex AI」的平台现已更名为Gemini Enterprise Agent Platform(简称:Agent平台)。用户可能用不同名称指代产品,请将其映射为正确的CLI值:
| 用户可能的表述 | CLI值 |
|---|---|
| Agent Engine、Vertex AI Agent Engine、Agent Runtime | |
| Vertex AI Search、Agent Search | |
| Vertex AI Vector Search、Vector Search | |
| Agent Engine sessions、Agent Platform Sessions | |
vertexaiStep 2: Create or Enhance the Project
步骤2:创建或增强项目
Create a New Project
创建新项目
bash
agents-cli scaffold create <project-name> \
--agent <template> \
--deployment-target <target> \
--region <region> \
--prototypeConstraints:
- 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-filenamefor Gemini CLI,GEMINI.mdfor Claude Code,CLAUDE.mdfor OpenAI Codex/other).AGENTS.md - 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
agents-cli scaffold create <project-name> \
--agent <template> \
--deployment-target <target> \
--region <region> \
--prototype约束条件:
- 项目名称必须不超过26个字符,仅包含小写字母、数字和连字符。
- 运行命令前请勿手动创建项目目录——CLI会自动创建目录。如果提前创建,
create命令可能失败或出现异常行为。create - 根据你使用的IDE自动检测指南文件名,并相应传递参数(Gemini CLI对应
--agent-guidance-filename,Claude Code对应GEMINI.md,OpenAI Codex或其他工具对应CLAUDE.md)。AGENTS.md - 增强现有项目时,请检查Agent代码的存放位置。如果不在目录下,请传递
app/参数(例如--agent-directory <dir>)。参数错误会导致enhance模式遗漏或错误放置文件。--agent-directory agent
Reference Files
参考文件
| File | Contents |
|---|---|
| Full flag reference for |
| 文件 | 内容 |
|---|---|
| |
Enhance an Existing Project
增强现有项目
bash
agents-cli scaffold enhance . --deployment-target <target>
agents-cli scaffold enhance . --cicd-runner <runner>Run this from inside the project directory (or pass the path instead of ).
.bash
agents-cli scaffold enhance . --deployment-target <target>
agents-cli scaffold enhance . --cicd-runner <runner>请在项目目录内运行该命令(或传递路径替代)。
.Upgrade a Project
升级项目
Upgrade an existing project to a newer agents-cli version, intelligently applying updates while preserving your customizations:
bash
agents-cli scaffold upgrade # Upgrade current directory
agents-cli scaffold upgrade <project-path> # Upgrade specific project
agents-cli scaffold upgrade --dry-run # Preview changes without applying
agents-cli scaffold upgrade --auto-approve # Auto-apply non-conflicting changes将现有项目升级到更新版本的agents-cli,智能应用更新同时保留你的自定义内容:
bash
agents-cli scaffold upgrade # 升级当前目录
agents-cli scaffold upgrade <project-path> # 升级指定项目
agents-cli scaffold upgrade --dry-run # 预览更改但不应用
agents-cli scaffold upgrade --auto-approve # 自动应用无冲突的更改Execution Modes
执行模式
The CLI defaults to strict programmatic mode — all required params must be supplied as CLI flags or a is raised. No approval flags needed. Pass all required params explicitly.
UsageErrorCLI默认使用严格编程模式——所有必填参数必须通过CLI标志提供,否则会抛出。无需确认标志,请显式传递所有必填参数。
UsageErrorCommon 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 (strict programmatic)
为现有原型添加部署(严格编程模式)
agents-cli scaffold enhance . --deployment-target agent_runtime
agents-cli scaffold enhance . --deployment-target agent_runtime
Add CI/CD pipeline (ask: GitHub Actions or Cloud Build?)
添加CI/CD流水线(询问:GitHub Actions还是Cloud Build?)
agents-cli scaffold enhance . --cicd-runner github_actions
---agents-cli scaffold enhance . --cicd-runner github_actions
---Template Options
模板选项
| Template | Deployment | Description |
|---|---|---|
| Agent Runtime, Cloud Run, GKE | Standard ADK agent (default) |
| Agent Runtime, Cloud Run, GKE | Agent-to-agent coordination (A2A protocol) |
| Agent Runtime, Cloud Run, GKE | RAG with data ingestion pipeline |
| 模板 | 部署方式 | 描述 |
|---|---|---|
| Agent Runtime、Cloud Run、GKE | 标准ADK Agent(默认) |
| Agent Runtime、Cloud Run、GKE | Agent间协作(A2A协议) |
| Agent Runtime、Cloud Run、GKE | 带数据 ingestion 流水线的RAG |
Deployment Options
部署选项
| Target | Description |
|---|---|
| Managed by Google (Vertex AI Agent Runtime). Sessions handled automatically. |
| Container-based deployment. More control, requires Dockerfile. |
| Container-based on GKE Autopilot. Full Kubernetes control. |
| No deployment scaffolding. Code only. |
| 目标 | 描述 |
|---|---|
| 由Google托管(Vertex AI Agent Runtime),会话自动处理。 |
| 基于容器的部署,可控性更强,需要Dockerfile。 |
| 基于GKE Autopilot的容器部署,拥有完整Kubernetes控制权。 |
| 无部署脚手架,仅生成代码。 |
"Prototype First" Pattern (Recommended)
「原型优先」模式(推荐)
Start with to skip CI/CD and Terraform. Focus on getting the agent working first, then add deployment later with :
--prototypescaffold enhancebash
undefined使用参数跳过CI/CD和Terraform,先专注于让Agent正常工作,之后再用添加部署:
--prototypescaffold enhancebash
undefinedStep 1: Create a prototype
步骤1:创建原型
agents-cli scaffold create my-agent --agent adk --prototype
agents-cli scaffold create my-agent --agent adk --prototype
Step 2: Iterate on the agent code...
步骤2:迭代Agent代码...
Step 3: Add deployment when ready
步骤3:准备就绪后添加部署
agents-cli scaffold enhance . --deployment-target agent_runtime
undefinedagents-cli scaffold enhance . --deployment-target agent_runtime
undefinedAgent Runtime and session_type
Agent Runtime与session_type
When using session_type`, clear it — Agent Runtime overrides it.
agent_runtime as the deployment target, Agent Runtime manages sessions internally. If your code sets a 当使用作为部署目标时,Agent Runtime会在内部管理会话。如果你的代码设置了,请清除该设置——Agent Runtime会覆盖它。
agent_runtimesession_typeStep 3: Load Dev Workflow
步骤3:加载开发工作流
After scaffolding, save to the project root if it isn't there already.
DESIGN_SPEC.mdThen immediately load — it contains the development workflow, coding guidelines, and operational rules you must follow when implementing the agent.
/google-agents-cli-workflowKey files to customize: (instruction, tools, model), (custom tool functions), (project ID, location, API keys).
Files to preserve: section (CLI reads this), deployment configs under , , (the must match the directory name — default ).
app/agent.pyapp/tools.py.envpyproject.toml[tool.agents-cli]deployment/Makefileapp/__init__.pyApp(name=...)appRAG projects () — provision datastore first:
Before running or testing your RAG agent, you must provision the datastore and ingest data:
agentic_ragagents-cli playgroundbash
agents-cli infra datastore # Provision datastore infrastructure
agents-cli data-ingestion # Ingest data into the datastoreUse — not . Both provision the datastore, but is faster because it skips unrelated Terraform. Without this step, the agent won't have data to search over.
infra datastoreinfra single-projectinfra datastoreVector Search region:defaults tovector_search_location, separate fromus-central1(region). It sets both the Vector Search collection region and the BQ ingestion dataset region, kept colocated to avoid cross-region data movement. Override per-invocation withus-east1.agents-cli data-ingestion --vector-search-location <region>
Verifying your agent works: Use for quick smoke tests, then for systematic validation. Do NOT write pytest tests that assert on LLM response content — that belongs in eval.
agents-cli run "test prompt"agents-cli eval run搭建完成后,如果项目根目录没有文件,请将其保存到根目录。
DESIGN_SPEC.md随后立即加载——其中包含开发工作流、编码规范以及实现Agent时必须遵循的操作规则。
/google-agents-cli-workflow需要自定义的关键文件: (指令、工具、模型)、(自定义工具函数)、(项目ID、区域、API密钥)。
需要保留的文件: 中的部分(CLI会读取该内容)、下的部署配置、、(其中的必须与目录名称匹配——默认为)。
app/agent.pyapp/tools.py.envpyproject.toml[tool.agents-cli]deployment/Makefileapp/__init__.pyApp(name=...)appRAG项目()——先配置数据存储:
在运行或测试RAG Agent之前,必须先配置数据存储并导入数据:
agentic_ragagents-cli playgroundbash
agents-cli infra datastore # 配置数据存储基础设施
agents-cli data-ingestion # 将数据导入数据存储请使用——不要使用。两者都会配置数据存储,但更快,因为它会跳过无关的Terraform步骤。不执行此步骤的话,Agent将没有可搜索的数据。
infra datastoreinfra single-projectinfra datastore向量搜索区域:默认值为vector_search_location,与us-central1(region)分开设置。它会同时设置向量搜索集合区域和BQ导入数据集区域,保持同区域以避免跨区域数据传输。可通过us-east1参数在每次调用时覆盖默认值。agents-cli data-ingestion --vector-search-location <region>
验证Agent是否正常工作: 使用进行快速冒烟测试,然后使用进行系统性验证。请勿编写断言LLM响应内容的pytest测试——这类测试属于eval范畴。
agents-cli run "test prompt"agents-cli eval runScaffold 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
agents-cli scaffold create /tmp/ref-project \
--agent adk \
--deployment-target cloud_runInspect 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 the CLI generates before committing to it
当你需要特定文件(Terraform、CI/CD工作流、Dockerfile)但不想直接为当前项目搭建脚手架时,可以在目录下创建一个临时参考项目:
/tmp/bash
agents-cli scaffold create /tmp/ref-project \
--agent adk \
--deployment-target cloud_run检查生成的文件,调整所需内容并复制到实际项目中。完成后删除参考项目。
这种方法适用于:
- 模式无法处理的非标准项目结构
enhance - 挑选特定的基础设施文件
- 在决定使用CLI生成内容前,先了解其生成的内容
Critical Rules
关键规则
- NEVER skip requirements clarification — load Phase 0 and clarify the user's intent before running
/google-agents-cli-workflowscaffold create - 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 Runtime clears session_type — if deploying to , remove any
agent_runtimesetting 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
- NEVER write A2A code from scratch — the A2A Python API surface (import paths, schema,
AgentCardsignature) is non-trivial and changes across versions. Always useto_a2a()to scaffold A2A projects.--agent adk_a2a
- 绝对不要跳过需求明确步骤——加载第0阶段,在运行
/google-agents-cli-workflow前明确用户意图scaffold create - 绝对不要修改现有代码中的模型,除非用户明确要求
- 绝对不要在前手动创建目录——CLI会创建目录;提前创建会触发enhance模式而非create模式
create - 绝对不要未经询问就创建Git仓库或推送到远程——确认仓库名称、公私有属性以及用户是否需要创建仓库
- 选择CI/CD运行器前务必询问用户——提供GitHub Actions和Cloud Build选项,不要默认选择
- Agent Runtime会清除session_type——如果部署到,请从代码中移除任何
agent_runtime设置session_type - **优先使用**进行快速迭代——之后用
--prototype添加部署enhance - 项目名称必须≤26个字符,仅包含小写字母、数字和连字符
- 绝对不要从头编写A2A代码——A2A Python API接口(导入路径、schema、
AgentCard签名)较为复杂且会随版本变化。请始终使用to_a2a()来搭建A2A项目。--agent adk_a2a
Examples
示例
Using scaffold as reference:
User says: "I need a Dockerfile for my non-standard project"
Actions:
- Create temp project:
agents-cli scaffold create /tmp/ref --agent adk --deployment-target cloud_run - Copy relevant files (Dockerfile, etc.) from /tmp/ref
- Delete temp project Result: Infrastructure files adapted to the actual project
A2A project:
User says: "Build me a Python agent that exposes A2A and deploys to Cloud Run"
Actions:
- Follow the standard flow (understand requirements, choose architecture, scaffold)
- Result: Valid A2A imports and Dockerfile — no manual A2A code written.
agents-cli scaffold create my-a2a-agent --agent adk_a2a --deployment-target cloud_run --prototype
将脚手架作为参考:
用户说:"我需要为我的非标准项目准备一个Dockerfile"
操作步骤:
- 创建临时项目:
agents-cli scaffold create /tmp/ref --agent adk --deployment-target cloud_run - 从/tmp/ref复制相关文件(如Dockerfile等)
- 删除临时项目 结果:基础设施文件适配实际项目
A2A项目:
用户说:"为我构建一个支持A2A并部署到Cloud Run的Python Agent"
操作步骤:
- 遵循标准流程(理解需求、选择架构、搭建脚手架)
- 执行结果:生成有效的A2A导入代码和Dockerfile——无需手动编写A2A代码。
agents-cli scaffold create my-a2a-agent --agent adk_a2a --deployment-target cloud_run --prototype
Troubleshooting
故障排除
agents-cli
command not found
agents-cliagents-cli
命令未找到
agents-cliSee → Setup section.
/google-agents-cli-workflow请查看 → 设置部分。
/google-agents-cli-workflowRelated Skills
相关技能
- — Development workflow, coding guidelines, and the build-evaluate-deploy lifecycle
/google-agents-cli-workflow - — ADK Python API quick reference for writing agent code
/google-agents-cli-adk-code - — Deployment targets, CI/CD pipelines, and production workflows
/google-agents-cli-deploy - — Evaluation methodology, evalset schema, and the eval-fix loop
/google-agents-cli-eval
- — 开发工作流、编码规范以及构建-评估-部署生命周期
/google-agents-cli-workflow - — 用于编写Agent代码的ADK Python API快速参考
/google-agents-cli-adk-code - — 部署目标、CI/CD流水线以及生产工作流
/google-agents-cli-deploy - — 评估方法、评估集schema以及评估-修复循环
/google-agents-cli-eval