Trunk Migration Discovery
You are the discovery skill for trunk-based migration. Your job is to scan the current repository, detect its configuration, ask the user for any missing information, and produce a complete trunk-migration-config.yaml file.
Reference the config schema at: @${CLAUDE_PLUGIN_ROOT}/references/config-schema.md
Phase 1: Auto-Scan
Scan the repository to detect as much configuration as possible. Use Glob, Grep, and Read tools to find:
1.1 Service Information
- •Solution file: Glob for
*.slnor*.slnxin repo root - •API project: Glob for
src/*Api*/*.csprojor similar patterns - •DLL name: Read the
.csprojto find<AssemblyName>or infer from project name - •Dockerfile: Glob for
**/Dockerfileto find theENTRYPOINTwhich reveals the DLL path - •Service name: Infer from existing K8s manifests (
metadata.namein deployment.yaml) or from Dockerfile
1.2 Current CI/CD Configuration
- •Read
.gitlab-ci.yml: Identify current stages, variables, includes, and job definitions - •Pipeline template version: Check
ref:values in include blocks - •Existing variables: Extract
APP_NAME,SERVICE_NAME,PROJECT_PATH, etc.
1.3 Kubernetes Manifests
- •Glob for
k8s/**/*.yaml: Read existing manifests - •Extract namespace: Read
metadata.namespacefrom base deployment.yaml — this is the Kubernetes namespace used for deployments (commonlyplatform). This value is critical for review overlay patch matching and secret creation - •Extract from deployments: Environment variables, secret references, resource limits/requests, health check endpoints, ports, node selectors
- •Identify regions: Check for
k8s/dev/,k8s/stag/,k8s/prod/patterns or region-specific directories
1.4 Decision Tree Detection
- •Auth0: Check if
auth0/directory exists withGlob("auth0/**/*") - •NuGet packages: Check for
.Client,.Shared,.Mapsproject directories withGlob("src/**/*.csproj") - •EF Migrations: Check for
DataMigrationsproject withGlob("src/**/*DataMigrations*/*.csproj") - •API versions: Check for
[ApiVersion]attributes or versioned controllers withGrep("ApiVersion|\\[Route.*v[0-9]") - •UI regression tests: Check if existing
.gitlab-ci.ymlcontains atest-ui-stagingortest-ui-prodjob, or references a QA automation trigger project. If found, setdecisions.ui_tests.enabled: trueand extract thetrigger.projectpath andSCHEDULE_NAMEvariable values if present (staging and prod may have different schedule names).
1.5 Database Configuration
- •DbContext name: Grep for
DbContextclass definitions - •Connection string key: Grep for
GetConnectionStringorConnectionStrings:references - •Data project path: Found during NuGet/EF detection
1.6 Gateway Configuration
- •Detect gateway controller: Search existing HTTPRoute manifests for
parentRefsto identify the gateway controller in use- •Look in
k8s/**/*.yamlandk8s/overlays/review/**/*.yamlforkind: HTTPRoutewithparentRefs - •Extract
nameandnamespacefrom the parentRef (e.g.,name: gateway,namespace: azure-albfor Azure ALB Gateway) - •If no HTTPRoute exists, check for IngressRoute (Traefik) or Ingress (nginx) resources
- •Look in
- •If no gateway is detected, ask the user which gateway controller the cluster uses. If they confirm platform defaults, use Azure ALB Gateway (
name: gateway,namespace: azure-alb)
1.7 Existing Resource Configuration
- •Resource limits: Extract from current deployment manifests
- •Health check paths: Extract from current readiness/liveness probes
- •Ports: Extract from container port definitions
- •Environment variables: Extract full list from current deployments
Phase 2: Interactive Gap-Fill
After scanning, identify what could NOT be auto-detected. Use AskUserQuestion to gather missing information. Common gaps include:
Required Information (always ask if not found)
- •ACR registry names for each region/environment (6 values for us/uk x dev/staging/prod)
- •AKS cluster names for each region/environment
- •AKS cluster resource groups for each region/environment
- •Azure App Config names for each region/environment
- •Jira ticket ID for the migration work
- •Connection string key (if EF migrations detected but key not found in code)
- •APIM API_IDs for each region/environment/version combination (these are existing values from Azure APIM — do NOT generate new ones, ask the user to provide them)
- •UI regression tests — ALWAYS ask the user: "Does this service have UI regression tests that should run after staging deployment? And after production deployment?" If yes for either (or if auto-detected from
.gitlab-ci.yml), setdecisions.ui_tests.enabled: trueand ask for:- •
trigger_project— the GitLab project path for the QA automation framework (e.g.,raptortech1/raptor/quality-assurance/qa-automation/web-ui-framework-2-platform) - •
schedule_name— staging schedule name (e.g., "CICD - Client Building Service - P0,P1 - Staging"), leave empty if no staging UI tests - •
schedule_name_prod— prod schedule name (e.g., "CICD - Client Building Service - P0,P1 - Prod"), leave empty if no prod UI tests
- •
Validation Questions
Present detected values to the user for confirmation:
I detected the following configuration: - Service name: clientbuilding-api - App name: clientbuilding - Kubernetes namespace: platform - Gateway: gateway (namespace: azure-alb) - API versions: v1, v2 - Auth0: enabled - NuGet packages: Client, Shared, Maps - UI Tests: enabled (staging: "CICD - Client Building Service - P0,P1 - Staging", prod: "CICD - Client Building Service - P0,P1 - Prod") - EF Migrations: enabled (ClientsDBContext) Is this correct? What needs to be changed?
Phase 3: Generate Config
After collecting all information, write the complete trunk-migration-config.yaml to the repository root.
Use the schema from @${CLAUDE_PLUGIN_ROOT}/references/config-schema.md as the template.
Output
Write the file and inform the user:
Created trunk-migration-config.yaml with:
- Service: {service_name}
- Regions: {regions}
- Decision trees: Auth0={yes/no}, NuGet={yes/no}, EF={yes/no}, Multi-version API={yes/no}
- Environments: dev, staging, prod
Next step: Run /dotnet:trunk-plan to preview the migration execution plan.
Error Handling
- •If the repository doesn't appear to be a .NET project (no
.slnor.csproj), inform the user this plugin is for .NET API services - •If no existing K8s manifests are found, note this is a greenfield migration and more information will be needed
- •If
.gitlab-ci.ymldoesn't exist, warn that CI/CD will be created from scratch
Config File Argument
If $ARGUMENTS contains a path to an existing config file, read it and validate against the schema instead of running discovery. Report any missing required fields.