From cf279ab84b9a0c18dc70d693cc9af269ba9ab688 Mon Sep 17 00:00:00 2001 From: Alex Bespoyasov Date: Fri, 31 Jul 2026 08:33:24 +0200 Subject: [PATCH 1/2] feat: extend guardrails for flag migration --- .../onboarding-prompt/steps/migrate-flags.md | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/lib/onboarding-prompt/steps/migrate-flags.md b/src/lib/onboarding-prompt/steps/migrate-flags.md index 5241a0c..604db66 100644 --- a/src/lib/onboarding-prompt/steps/migrate-flags.md +++ b/src/lib/onboarding-prompt/steps/migrate-flags.md @@ -1,12 +1,31 @@ ## {{STEP}}. Migrate {{PROVIDER_NAME}} flags to Confidence -Use the `/{{SKILL_NAME}}` skill to migrate existing {{PROVIDER_NAME}} feature flag evaluations to Confidence. +Read the `/{{SKILL_NAME}}` skill as a **methodology reference** — use it for how to identify flags, build the migration plan, map types and rules to Confidence equivalents, and call the MCP tools. Ignore its output formatting, step trackers, EDUCATE blocks, AskUserQuestion calls, and ALL interactive prompts. Never pause for user input. -Follow the skill's three-phase workflow: +**Guardrails — apply regardless of what the skill says:** -1. Run `/{{SKILL_NAME}} plan flag` to generate the flag migration plan -2. Run `/{{SKILL_NAME}} plan code` to generate the code migration plan -3. Run `/{{SKILL_NAME}} execute ` to apply the migration +- **Scan the codebase, not the provider API.** You do not have {{PROVIDER_NAME}} API credentials. Discover flags by scanning the project source code for {{PROVIDER_NAME}} SDK usage patterns (flag evaluations, feature checks, experiment references). Do NOT ask for API tokens, project IDs, or exported JSON files. +- **Consent is pre-approved.** The user already chose to migrate {{PROVIDER_NAME}} flags through the wizard UI — that is their consent. Mark every eligible flag as `[x] Migrate`. This satisfies the skill's consent gate — do NOT stop to ask the user to tick checkboxes. +- **Auto-select all decisions.** Do not stop at any `⏸ awaiting user` gate. Use these defaults: + - environment → `production`; + - archived flags → exclude; + - execution mode → `migrate-all-eligible`; + - Confidence client → use first existing client, or create one if none exist; + - entity/bucketing field → `targeting_key`. + - If the skill asks the user to confirm scope, choose a mode, pick a client, or map a field — apply the default and move on. +- **No per-flag confirmations.** Skip `review-each` gates, per-flag `[Yes / Skip / Pause]` prompts, and checkpoint pauses. Process every eligible flag without stopping. +- **Partial-rollout flags → migrate at the original percentage.** Do not stop to explain risk or ask for confirmation. Use the same rollout percentage from the {{PROVIDER_NAME}} configuration. Record each partial-rollout flag in the report with a warning: Confidence uses a different bucketing hash, so the exact user cohort will change after migration — users currently in the rollout may move out, and new users may move in. The user should verify rollout behavior after shipping. +- **All changes on the current branch.** Do NOT create separate branches or pull requests per flag. Apply all migration changes (flag creation + code rewrites) directly on the current branch in a single pass. Ignore the skill's "each flag = one PR" instruction. +- **SDK install and code transforms → just do it.** Do not ask `Install SDK now?`, `Create wrapper?`, or `Transform this flag's files?` — run every install, wrapper creation, and code transform automatically. +- **Always start fresh.** If an existing plan file is found, overwrite it. Do not ask the user whether to resume or start fresh. +- **Errors → log and continue.** If a single flag fails after retry, log it and move to the next flag. Do not stop to ask `[Retry / Skip / Pause]`. Include every failed flag in the report with the error reason so the user can retry manually. + +Execute the skill's workflow automatically: + +1. **Scan** the project for {{PROVIDER_NAME}} feature flag usage in source code and build the flag migration plan. +2. **Pre-approve** all eligible flags per the guardrails above. +3. **Plan code** transformations for all approved flags. +4. **Execute** — create Confidence flags via MCP tools and rewrite code. Apply all changes on the current branch without branching or opening PRs. For each flag migrated, print: STATUS: Migrated flag: From 1af1aaf89197678ab136cfe27336b076899b534d Mon Sep 17 00:00:00 2001 From: Alex Bespoyasov Date: Fri, 31 Jul 2026 08:33:57 +0200 Subject: [PATCH 2/2] feat: add migration section in report file --- src/lib/onboarding-prompt/index.ts | 8 ++++++- src/lib/onboarding-prompt/report-templates.ts | 24 +++++++++++++++++++ src/lib/onboarding-prompt/report.ts | 5 +++- .../steps/generate-report.md | 1 + 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/lib/onboarding-prompt/index.ts b/src/lib/onboarding-prompt/index.ts index 49e61fc..858e035 100644 --- a/src/lib/onboarding-prompt/index.ts +++ b/src/lib/onboarding-prompt/index.ts @@ -59,7 +59,13 @@ export function buildOnboardingPrompt({ ...migrations.map((m) => migrateFlags(m, steps.next())), - generateReport({ step: steps.next(), isEmptyProject, goal, hasPlugins }), + generateReport({ + step: steps.next(), + isEmptyProject, + goal, + hasPlugins, + hasMigrations: migrations.length > 0, + }), summary(steps.next()), rules(), ]; diff --git a/src/lib/onboarding-prompt/report-templates.ts b/src/lib/onboarding-prompt/report-templates.ts index 3195ffd..a092ec3 100644 --- a/src/lib/onboarding-prompt/report-templates.ts +++ b/src/lib/onboarding-prompt/report-templates.ts @@ -97,6 +97,30 @@ const ALL_TEMPLATE_START = `\ - \`\` - \`\``; +export const MIGRATION_REPORT_SECTION = `\ + +## Flag migration + +**Migrated flags:** + +| Flag | Source | Status | Notes | +|------|--------|--------|-------| + + + +### ⚠️ Partial-rollout warnings + + +- \`\` — migrated at % rollout. Confidence uses a different bucketing hash than , so the exact user cohort will change: users currently in the rollout may drop out, and new users may enter. Verify rollout behavior after shipping. + + +### ❌ Failed migrations + + +- \`\` — . Retry manually with \`/ execute\`. + +`; + const COMMON_TEMPLATE_END = `\ ## How to use it diff --git a/src/lib/onboarding-prompt/report.ts b/src/lib/onboarding-prompt/report.ts index 2e4cf5f..15fcd7f 100644 --- a/src/lib/onboarding-prompt/report.ts +++ b/src/lib/onboarding-prompt/report.ts @@ -1,6 +1,6 @@ import type { OnboardingGoal } from '../session.js'; import { CONFIDENCE_DOCS_URL } from '../constants.js'; -import { buildReportTemplate } from './report-templates.js'; +import { buildReportTemplate, MIGRATION_REPORT_SECTION } from './report-templates.js'; import { loadStep } from './steps/load.js'; const HOW_TO_RUN = ` @@ -17,11 +17,13 @@ export function generateReport({ isEmptyProject, goal = 'feature-flags', hasPlugins = false, + hasMigrations = false, }: { step: number; isEmptyProject: boolean; goal?: OnboardingGoal; hasPlugins?: boolean; + hasMigrations?: boolean; }): string { const template = buildReportTemplate(goal); @@ -29,6 +31,7 @@ export function generateReport({ STEP: step, REPORT_START: template.start, HOW_TO_RUN: isEmptyProject ? HOW_TO_RUN : '', + MIGRATION_REPORT: hasMigrations ? MIGRATION_REPORT_SECTION : '', REPORT_END: template.end, SKILLS_NOTE: hasPlugins ? SKILLS_NOTE : '', DOCS_URL: CONFIDENCE_DOCS_URL, diff --git a/src/lib/onboarding-prompt/steps/generate-report.md b/src/lib/onboarding-prompt/steps/generate-report.md index 717ea06..470066a 100644 --- a/src/lib/onboarding-prompt/steps/generate-report.md +++ b/src/lib/onboarding-prompt/steps/generate-report.md @@ -8,6 +8,7 @@ Write a CONFIDENCE_QUICKSTART.md file in the project root with this structure: {{REPORT_START}} {{HOW_TO_RUN}} +{{MIGRATION_REPORT}} {{SKILLS_NOTE}}{{REPORT_END}} Fill in all actual values from the preceding steps. For the SDK reference link, use the docs MCP if available, otherwise search the web for the relevant SDK page at {{DOCS_URL}}. If no URL is found, omit that line rather than guessing.