Skip to main content

Module 30.1: Spec-Driven AgentOps, Coding Skills & Scaffolding

Theoryโ€‹

Spec-Driven AgentOps, Coding Skills & Scaffolding (Light) Spec-Driven AgentOps, Coding Skills & Scaffolding (Dark) Figure: Spec-driven Enterprise AgentOps blueprint with google-agents-cli v1.10 โ€” from .agents-cli-spec.md and coding-agent skills to reference recipes, prototype scaffolding, and built-in A2A serving.

Welcome to Part 6: Enterprise AgentOps with Google Agents CLIโ€‹

Across Parts 1โ€“5, you mastered the ADK 2.0 cognitive runtime: designing Agent personas, stateful ToolContext functions, deterministic @node workflows, BasePlugin interceptors, MCP integrations, and real-time streaming with zero infrastructure clutter.

Shipping an agent to production, however, demands a second engineering discipline: Enterprise AgentOps. Production systems require an explicit architectural specification, reproducible uv dependency locks, built-in Agent-to-Agent (A2A) protocol endpoints, rubric-driven evaluation gates, GitOps CI/CD pipelines, OpenTelemetry tracing, and strict token cost controls.

Throughout Part 6 (Modules 30.1โ€“30.4) and Part 7 (Modules 31โ€“36), you will engineer, evaluate, govern, and deploy a single canonical enterprise application โ€” support-ops-agent, powered by gemini-3.8-flash โ€” using the Google Agents CLI (google-agents-cli ~= 1.10.0).


The agents-cli v1.10 Lifecycle (Phases 0โ€“7)โ€‹

Rather than bolting Dockerfiles, FastAPI servers, A2A routers, and Terraform onto a script at the eleventh hour, agents-cli v1.10 structures engineering around an 8-phase spec-driven, prototype-first lifecycle:

Lifecycle PhaseCore Commands / ArtifactsCurriculum Coverage & Purpose
Phase 0: Understand & Specify.agents-cli-spec.mdModule 30.1: Pin mission, tools, session state keys, safety non-goals, and measurable evaluation criteria before scaffolding.
Phase 1: Study Reference RecipesSparse-clone google/adk-samples (core/python/<recipe>/AGENTS.md)Module 30.1: Study curated reference implementations for RAG, sandboxes, memory, or HITL instead of using rigid generator flags.
Phase 2: Prototype Scaffoldagents-cli create support-ops-agent --agent adk --prototypeModule 30.1: Generate a clean ADK + FastAPI + A2A + eval repository without premature Terraform or CI/CD noise (create and scaffold create are equivalent).
Phase 3: Build & Smoke Testagents-cli install ยท agents-cli lint
agents-cli run "..." -v --start-server
agents-cli playground
Module 30.1: Implement app/agent.py, run fast multi-turn smoke tests against a warm local server, and inspect JSON event payloads.
Phase 4: Evaluate & Optimizeagents-cli eval run ยท eval dataset synthesize
eval analyze ยท eval optimize (GEPA) ยท eval compare
Module 30.2: Validate behavior on EvaluationDataset cases, synthesize multi-turn user personas, and optimize instructions with GEPA.
Extensions & GitOps CI/CDagents-cli-extension.yaml
agents-cli scaffold enhance . ยท infra cicd
Module 30.3: Enforce org-wide CLI guardrails, explore polyglot templates (--agent adk_go), and wire GitHub Actions / Cloud Build + Terraform.
Phases 5โ€“6: Deploy & Publishagents-cli deploy
agents-cli publish gemini
Part 7 (Modules 31โ€“36): Roll out containers to Cloud Run, GKE Autopilot, or Agent Runtime with Agent Identity, and register with Gemini Enterprise.
Phase 7: Observe & Control Costplayground --otel-to-cloud ยท --bq-analytics
ContextCacheConfig ยท EventsCompactionConfig
Module 30.4: Inspect Cloud Trace span trees, query BigQuery Agent Analytics (v_llm_response), and govern token and compute spend.

Installing agents-cli & Syncing the 7 Coding-Agent Skillsโ€‹

Install google-agents-cli once as an isolated global CLI tool via uv, then run agents-cli setup to equip your AI coding assistant with up-to-date operational knowledge:

# 1. Install google-agents-cli (~= 1.10.0) globally via uv
uv tool install google-agents-cli

# 2. Preview which coding agents are detected on your machine
agents-cli setup --dry-run

# 3. Sync the 7 official AgentOps skills without triggering cloud login prompts
agents-cli setup --skip-auth
# Optional: scope skills strictly to the current repository (.gemini/skills/, .claude/skills/, .agents/skills/)
# agents-cli setup --workspace --skip-auth

agents-cli setup detects your active coding environments (Antigravity, Gemini CLI, Claude Code, Cursor, Codex, Windsurf) and installs seven phase-specific google-agents-cli-* developer skills into .gemini/skills/, .claude/skills/, or .agents/skills/:

Installed Coding-Agent SkillWhen Your Coding Assistant Loads ItWhat It Enforces
google-agents-cli-workflowAlways active (Phase 0 entrypoint)8-phase lifecycle discipline, code-preservation rules, model preservation, and systematic 5-step debugging.
google-agents-cli-scaffoldPhase 2 (create, enhance, upgrade)Strict programmatic flags, naming constraints (<= 26 chars), --prototype workflow, and built-in A2A rules.
google-agents-cli-adk-codePhases 1 & 3 (Design & Build)ADK 2.0 Python/Go API patterns, ToolContext, graph Workflow syntax, and the Reference Recipes topic index.
google-agents-cli-evalPhase 4 (Quality Flywheel)EvaluationDataset JSON shapes, rubric metrics, user simulation, GEPA prompt optimization, and eval compare.
google-agents-cli-deployPhase 5 (Cloud Rollout)Runtime target selection (agent_runtime, cloud_run, gke), IAM/403 troubleshooting, and Secret Manager wiring.
google-agents-cli-publishPhase 6 (Enterprise Catalog)Registering deployed agents and MCP servers with Gemini Enterprise and Agent Registry (ADK vs A2A modes).
google-agents-cli-observabilityPhase 7 (Production Telemetry)Cloud Trace span hierarchy, two-tier prompt/response logging, and BigQuery Agent Analytics SQL views.

Coding-Agent Dev Skills vs. Runtime ADK Skills: Do not confuse the 7 google-agents-cli-* skills installed by agents-cli setup (which guide your IDE coding agent while you write and deploy code) with ADK's runtime SkillToolset (covered in Module 39.5, which equips your deployed root_agent to load SKILL.md domain instructions at runtime).


Phase 0 & Phase 1: .agents-cli-spec.md and Clone-and-Study Recipesโ€‹

Phase 0: Pinning Intent in .agents-cli-spec.mdโ€‹

Before running agents-cli create or writing a single tool, Phase 0 captures a concise contract in .agents-cli-spec.md at the project root. If a coding agent or teammate opens the repository later, .agents-cli-spec.md serves as the single source of truth for:

  • Overview & Mission: What operational problem the agent solves (and explicit Non-Goals).
  • Tools & State Keys: Exact function signatures, external APIs, and Session.state keys (such as user:customer_tier, active_ticket_id, and escalated_tickets).
  • Constraints & Safety Rules: Guardrails the agent must never violate (for example, never fabricating ticket IDs or escalating unverified tickets).
  • Success Criteria: Measurable behavioral outcomes that directly seed Phase 4 evaluation rubrics.
  • Reference Samples: Relevant recipes to inspect in Phase 1 before writing custom infrastructure.

Phase 1: Why agents-cli v1.10 Retired --datastore and agentic_ragโ€‹

In earlier releases, scaffolding tools bundled monolithic RAG templates (--agent agentic_rag, --datastore, agents-cli infra datastore, agents-cli data-ingestion). In real enterprise teams, baking opinionated chunking pipelines and Terraform datastores into a rigid CLI flag made projects brittle and hard to customize.

agents-cli v1.10 officially retired --datastore, agentic_rag, and data-ingestion in favor of the Clone-and-Study Reference Recipe model:

  1. Scaffold a clean, minimal foundation: Always start your own repository with --agent adk --prototype so you own a lean, upgradeable codebase.
  2. Clone and study curated reference recipes: When your spec requires retrieval over private documents, sandboxed execution, cross-session Memory Bank, OAuth user consent, or runner-wide safety plugins, sparse-clone the matching canonical recipe (such as rag-agent-search, rag-vector-search, long-horizon-harness, cross-session-memory, or catalog samples such as adk@data-science and agentic-rag-vertex-ai-search), read its AGENTS.md architectural tour first, and lift only the exact pattern (app/, infra/terraform/, or Makefile target) your spec requires:
# Phase 1 pattern: sparse-clone a curated recipe to /tmp, study AGENTS.md, and adapt cleanly
git clone --filter=blob:none --depth 1 --sparse \
https://github.com/google/adk-samples /tmp/adk-samples
cd /tmp/adk-samples
git sparse-checkout add core/python/rag-agent-search
cat core/python/rag-agent-search/AGENTS.md

Phase 2: Prototype Scaffolding & Complete Project Anatomyโ€‹

Once .agents-cli-spec.md is approved, scaffold support-ops-agent in prototype mode. Note that agents-cli create and agents-cli scaffold create are exact aliases, and agents-cli runs in strict programmatic mode by default (raising a UsageError if required flags are omitted rather than hanging in non-interactive shells):

# Equivalent to: agents-cli scaffold create support-ops-agent ...
agents-cli create support-ops-agent \
--agent adk \
--prototype \
--agent-guidance-filename GEMINI.md

This generates a standardized, production-grade repository without premature cloud infrastructure files:

support-ops-agent/
โ”œโ”€โ”€ .agents-cli-spec.md # Phase 0 architectural contract (mission, tools, state, metrics)
โ”œโ”€โ”€ agents-cli-manifest.yaml # Canonical project metadata read by info, enhance, deploy & upgrade
โ”œโ”€โ”€ GEMINI.md # IDE coding-agent guidance & safe-edit boundaries
โ”œโ”€โ”€ pyproject.toml # uv project dependencies (google-adk, fastapi, uvicorn, a2a-sdk)
โ”œโ”€โ”€ Dockerfile # Production container serving uvicorn app.fast_api_app:app
โ”œโ”€โ”€ .env # Gemini platform (GCP project/location) or AI Studio API key
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ __init__.py
โ”‚ โ”œโ”€โ”€ agent.py # YOUR CODE: tools, root_agent (gemini-3.8-flash) & App(name="app")
โ”‚ โ”œโ”€โ”€ fast_api_app.py # Unified FastAPI server (/run_sse + built-in /a2a/app lifespan)
โ”‚ โ””โ”€โ”€ app_utils/
โ”‚ โ”œโ”€โ”€ a2a.py # Dynamic AgentCardBuilder & JSON-RPC attach_a2a_routes()
โ”‚ โ””โ”€โ”€ services.py # Process-wide shared://session & shared://artifact registry
โ””โ”€โ”€ tests/
โ”œโ”€โ”€ eval/
โ”‚ โ”œโ”€โ”€ eval_config.yaml # Metric suite configuration (Module 30.2)
โ”‚ โ””โ”€โ”€ datasets/
โ”‚ โ””โ”€โ”€ basic-dataset.json # EvaluationDataset cases (Module 30.2)
โ”œโ”€โ”€ integration/ # Smoke tests verifying FastAPI & Runner wiring
โ””โ”€โ”€ unit/ # Deterministic pure-Python unit tests (never LLM wording checks!)

Inside the Generated Serving Harness (fast_api_app.py, a2a.py, services.py)โ€‹

  • Built-in A2A Protocol Surface (app/fast_api_app.py & app/app_utils/a2a.py): During FastAPI lifespan startup, fast_api_app.py instantiates a shared Runner and calls await attach_a2a_routes(app, agent=root_agent, runner=runner, task_store=InMemoryTaskStore(), rpc_path="/a2a/app"). Your agent automatically serves both ADK's native /run_sse endpoint and a standards-compliant A2A JSON-RPC endpoint plus discovery card at /a2a/app/.well-known/agent-card.json โ€” with v0.3 Gemini registration compatibility out of the box. Never hand-write custom A2A server boilerplate in an agents-cli project.
  • Unified shared:// Session & Artifact Registry (app/app_utils/services.py): Registers shared://session and shared://artifact process-wide so sessions created via ADK SSE, the Web Playground, or A2A share one backing store (InMemorySessionService locally, upgrading cleanly to Cloud SQL or VertexAiSessionService in cloud deployments).

The 4 Critical agents-cli Rulesโ€‹

Violating any of these four invariants is the top cause of scaffolding failures or runtime "Session not found" errors:

  1. Project name <= 26 characters ([a-z0-9-] only): Names must use only lowercase letters, digits, and hyphens (e.g., support-ops-agent, 17 characters). Cloud IAM service accounts and Terraform resource identifiers append suffixes that hit GCP's 30-character limit if the project name exceeds 26 characters.
  2. NEVER mkdir before agents-cli create: Always run create (or scaffold create) from the parent workspace directory. If you pre-create an empty support-ops-agent/ folder, agents-cli refuses to overwrite it or misinterprets the directory state.
  3. App(root_agent=root_agent, name="app") MUST match agent_directory: "app": ADK's FastAPI router and agents-cli eval resolve /apps/{app_name} from the package folder name (app). Setting App(..., name="support_ops_agent") while code lives in app/agent.py causes "Session not found" failures.
  4. Agent(name="support_ops_agent") MUST match create_params.root_agent_name in agents-cli-manifest.yaml: agents-cli coerces support-ops-agent to the Python identifier support_ops_agent inside create_params.root_agent_name in agents-cli-manifest.yaml. Keep Agent(name=...) and create_params.root_agent_name identical so OpenTelemetry gen_ai.agent.name attributes, eval runners, and your A2A AgentCard stay aligned.

Phase 3 Smoke Testing, scaffold enhance, and scaffold upgradeโ€‹

Fast Local Iteration (install, lint, run -v --start-server, playground)โ€‹

During Phase 3, keep feedback loops tight from the terminal:

# Sync uv virtual environment & run ruff / static checks
agents-cli install
agents-cli lint

# Start a persistent background server, stream full JSON event payloads (-v), and keep session state alive
agents-cli run "Investigate ticket TCK-1042 and check its SLA." -v --start-server --session-id demo-1
agents-cli run "Was TCK-1042 escalated in this session?" --session-id demo-1
agents-cli run "Stop" --stop-server

# Or launch the browser-based ADK Web Playground
agents-cli playground

Code-Preservation Guarantee (scaffold enhance & scaffold upgrade)โ€‹

When your prototype passes Phase 4 evaluations, you do not start a new repository. Instead:

  • Adding Cloud Infrastructure (agents-cli scaffold enhance .): Running agents-cli scaffold enhance . --deployment-target cloud_run --cicd-runner github_actions layers Terraform (deployment/terraform/), CI/CD workflows, and load tests in place while strictly preserving your custom app/agent.py, .agents-cli-spec.md, .env, GEMINI.md, and tests/eval/ datasets. Pass --dry-run to preview additions first, or --prefer-new to resolve template conflicts in favor of the incoming scaffold.
  • Staying Current Across CLI Releases (agents-cli scaffold upgrade): When a newer google-agents-cli version ships updated FastAPI/A2A wiring or Terraform modules, run agents-cli scaffold upgrade --dry-run to preview a 3-way smart merge between the original template version recorded in agents-cli-manifest.yaml, the new CLI template, and your repository. Unmodified boilerplate updates automatically while your business logic in app/agent.py remains untouched (--auto-approve applies clean merges; --force resets scaffolding files if a manual conflict cannot be merged).

๐ŸŽฏ Knowledge CheckSelect Best Answer

Your team is kicking off an enterprise ADK agent ('support-ops-agent') that will eventually need document retrieval (RAG) and A2A interoperability. Following Google Agents CLI v1.10 best practices, how should you initialize and structure the repository?

Key Takeawaysโ€‹

  • Spec-First Lifecycle (Phase 0 โ†’ Phase 7): Pin mission, tools, state keys, non-goals, and measurable evaluation criteria in .agents-cli-spec.md before scaffolding or coding.
  • Clone-and-Study Recipes Replace Rigid Flags: agents-cli v1.10 retired --datastore, agentic_rag, and data-ingestion. Scaffold a clean --agent adk --prototype project and sparse-clone curated recipes (rag-agent-search, long-horizon-harness, adk@data-science) to study their AGENTS.md patterns.
  • 7 Coding-Agent Skills (agents-cli setup): Syncs workflow, scaffold, adk-code, eval, deploy, publish, and observability skills directly into your IDE coding assistant.
  • Built-In A2A & Shared Services: Every scaffolded ADK app automatically mounts /a2a/app/.well-known/agent-card.json and JSON-RPC task handling alongside /run_sse over a unified shared://session store.
  • The 4 Non-Negotiable Rules & Non-Destructive Upgrades: Enforce <= 26 char [a-z0-9-] project names, never mkdir before create, keep App(..., name="app") matched to agent_directory: "app", keep Agent(name="support_ops_agent") matched to root_agent_name, and evolve safely via scaffold enhance and scaffold upgrade --dry-run.
๐Ÿ“–

30.1: Spec-Driven AgentOps & Scaffolding(Theory & Overview)

Part 6: AgentOps & Google Agents CLI โ€ข Module 30.1

Overall Course Progress:
0%(0/98)
Next Step: Challenge Lab ๐Ÿงช โ†’