$npx -y skills add GoogleCloudPlatform/cxas-scrapi --skill cxas-dfcx-migrationMigrate Dialogflow CX (DFCX) agents to CXAS (Customer Experience Agent Studio) agents. Use this skill when the user mentions DFCX migration, migrating agents, converting DFCX to CXAS, porting agents, agent migration, or post-migration optimization/consolidation. Four independentl
| 1 | # DFCX to CXAS Migration |
| 2 | |
| 3 | Four small scripts, one persistent IR bundle: |
| 4 | |
| 5 | | Script | What it does | Runtime | Output | |
| 6 | |---|---|---|---| |
| 7 | | `migrate.py` | 1:1 conversion of every selected playbook/flow into a CXAS agent. | ~30 min for ~40 flows | `<target>_ir.json`, `<target>_migration_report.md`, `<target>_unit_tests.json` | |
| 8 | | `stage_1.py` | Loads the IR bundle, runs `CXASOptimizer.optimize_stage1` (variable dedup) and Gemini structural consolidation (N→M agent grouping). Pushes via update-pass deploys. Deletes original orphans (iterative). CXAS Version `0.0.2` (dedup) and `0.0.3` (consolidation). | ~15 min | Updated `<target>_ir.json` (with `pre_consolidation_ir` snapshot for rollback), `<target>_grouping.json` | |
| 9 | | `stage_2.py` | Loads the IR bundle, runs `CXASOptimizer.optimize_stage2` (instruction state machines + tool mocks). Pushes via update-pass deploys. CXAS Version `0.0.4`. Re-generates unit tests. Lints. Writes the audit report. | ~10 min | Updated `<target>_ir.json`, `<target>_optimization_report.md`, regenerated `<target>_unit_tests.json` | |
| 10 | | `stage_3.py` | **Only after Stage 1 consolidation.** Rewires the consolidated agents' parent → children topology by mapping the SOURCE DFCX dep graph onto the new groups (rather than relying on what the synthesized PIF XML happened to reference) according to Spoke-Hub architecture style. Sets app `root_agent` to the `is_root` group. Idempotent — safe to re-run. CXAS Version `0.0.5`. | ~10 sec | Updated `<target>_ir.json` stage history; CXAS app's `child_agents` set per group | |
| 11 | |
| 12 | State flows through `<target>_ir.json` (a Pydantic `IRBundle` containing the `MigrationConfig`, source `DFCXAgentIR`, target `MigrationIR`, stage history, and version checkpoints). Each stage loads it from disk, mutates it, and writes it back. **No re-fetching or re-compiling between stages.** |
| 13 | |
| 14 | ## When to use this skill vs. the CLI directly |
| 15 | |
| 16 | This skill (InquirerPy prompts + HTML pre-flight preview + Gemini model picker) is the right entry when you want to **interactively** drive a migration with rich pre-flight context. The same `MigrationService.run_stage*` methods this skill calls are also exposed via the canonical CLI for scripted / CI use: |
| 17 | |
| 18 | ```bash |
| 19 | # Same E2E plumbing, non-interactive (standard optimized profile by default): |
| 20 | cxas migrate dfcx --run --source-agent-id … --project-id … --target-name … |
| 21 | |
| 22 | # Non-interactive Stage Checkpoint optimization runs: |
| 23 | cxas migrate dfcx --optimize --stage 1 --target-name my_app |
| 24 | cxas migrate dfcx --optimize --stage 2 --target-name my_app |
| 25 | cxas migrate dfcx --optimize --stage 3 --target-name my_app --architecture hub-and-spoke |
| 26 | cxas migrate dfcx --optimize --stage resume --target-name my_app # interactive stage picker |
| 27 | ``` |
| 28 | |
| 29 | The skill, the dashboard, and the E2E / Checkpoint commands all go through the **same** `MigrationService.run_stage_1/run_stage_2/run_stage_3` methods — pick whichever entry point matches your workflow. |
| 30 | |
| 31 | ## Prerequisites |
| 32 | |
| 33 | ```bash |
| 34 | # Ensure cxas_scrapi is installed editable (so this skill picks up local changes) |
| 35 | pip install -e . |
| 36 | |
| 37 | # Auth |
| 38 | gcloud auth application-default login |
| 39 | gcloud auth list # confirm the account has read on source + admin on target |
| 40 | ``` |
| 41 | |
| 42 | InquirerPy is required for the interactive prompts (matches the agent-foundry skill): |
| 43 | |
| 44 | ```bash |
| 45 | pip install InquirerPy |
| 46 | ``` |
| 47 | |
| 48 | ## Driving the flow interactively (from Claude) |
| 49 | |
| 50 | When invoked through Claude, lead the user through one question at a time. The scripts will prompt for missing inputs via InquirerPy, but you should pre-collect: |
| 51 | |
| 52 | 1. **GCP project ID** (target — where the new CXAS app will live). |
| 53 | 2. **Location** — default `us`. **Do NOT default to `global` — it does not work for CXAS apps in most projects.** |
| 54 | 3. **Source agent** — DFCX agent ID (full resource name) or path to a local `.zip` export. |
| 55 | 4. **Target name** — display name for the new CXAS app. |
| 56 | |
| 57 | Optional follow-ups: `--env` (PROD/AUTOPUSH), `--model` (Gemini), `--migration-version` (1.0/2.0). |
| 58 | |
| 59 | ## Quick Reference |
| 60 | |
| 61 | ```bash |
| 62 | # 1:1 migration (interactive — InquirerPy will prompt for project + location) |
| 63 | python .agents/skills/cxas-dfcx-migration/scripts/migrate.py |
| 64 | |
| 65 | # Fully scripted |
| 66 | python .agents/skills/cxas-dfcx-migration/scripts/migrate.py \ |
| 67 | --source-agent-id "projects/<src_proj>/locations/us/agents/<uuid>" \ |
| 68 | --project-id <targe |