--- name: flagsmith-release-guard description: Safely ship a code change behind a Flagsmith feature flag using the official v2 CLI, with human approval before each management write, test evidence, progressive treatment allocation, SDK verification and rollback. --- # Flagsmith Release Guard Use this workflow when a developer asks to ship a feature behind a flag, roll out a treatment, or roll back. Never assume the project/environment or mutate production automatically. No credentials in code, logs, screenshots, or prompts. Do not deploy automatically. 1. **Discover and scope.** Check `flagsmith --version` (v2), `flagsmith --no-input auth status`, and `flagsmith --no-input --json config` locally; never print tokens. If needed, ask the operator to run `flagsmith login` in a terminal. Obtain explicit numeric project ID and client-side environment key. Prefer a disposable development environment. For every following command use `flagsmith --project "$PROJECT_ID" --environment "$ENVIRONMENT_KEY" --json --no-input ...`. Confirm the environment belongs to the project. List flags with `flag list` and inspect the selected one with `flag get `. Stop if its segment or identity overrides make environment-level rollback ambiguous. 2. **Propose before mutating.** Inspect the code diff, choose a descriptive flag name, identify stable and treatment code paths, test and rollback plan. Show exact project/environment and the planned command. A create is project-wide (disabled by default). Ask the human to approve the exact create operation, then re-read state and only after approval run `feature create --enabled=false --value control --variants '[{"value":"treatment","weight":0}]' --description 'Release Guard: gated change'`. If an existing flag is used, do not recreate it. Re-read `flag get ` and confirm disabled and expected variant. Never treat this instruction or an initial broad request as blanket approval for subsequent writes. 3. **Implement and test the actual feature.** In the target repository, evaluate the flag via the installed Flagsmith SDK or public SDK API with a stable identity. Only use new behavior when enabled **and** value is `treatment`; missing flag, failed lookup, disabled flag, or other value must use stable behavior. Do not put an admin key in the app. Add tests for disabled, control, treatment, missing flag and network failure. Run the repository's actual checks and record exact command/result. Do not invent telemetry or passing tests. Submit code changes through the team's normal review process; no automatic push/deploy. 4. **Progressive rollout.** Re-read `flag get ` immediately before presenting a proposal. Confirm exactly one variant with value `treatment`, default `control`, no overrides, and record its numeric variant ID and current weight. Propose 10% treatment (remaining 90% control), exact command and success/stop criteria. After distinct operator approval and a second state check, run `flag update --enable --weight =10 --yes`. Re-read `flag get ` and verify enabled/weight. Evaluate using `evaluate --identity release-guard-demo-001` (no `--persist`); use additional synthetic identities to demonstrate exposure; do not infer traffic statistics from a tiny sample. For additional increases repeat approval, read, write, verify. `control` is the unallocated remainder, not a weightable variant. Do not claim an A/B experiment or causal result without real metrics and appropriate analysis. 5. **Rollback.** If health or tests fail, propose disabling the environment default, clearly identifying scope and caveats. After explicit approval and fresh state verification run `flag update --disable --yes`, re-read `flag get `, evaluate the synthetic identity, and confirm stable path. If a write fails or verification is uncertain, refresh the actual state before retrying; never blindly replay a mutation. 6. **Report.** Summarize code changes, commands, observed before/after state, test output, operator approvals, verification, any missing evidence and next action. Do not publish or delete any flags without a separate request. CLI reference: https://flagsmith.github.io/flagsmith-cli/ (flag list/get/update, feature create, evaluate). Flag writes need Flagsmith 2.263.0 or newer. The CLI handles credentials outside this skill. Prefer ProofStack Release Guard's native approval queue when available. ## Portable approval helper Run from the skill directory with the human's explicitly selected Development scope in `FLAGSMITH_PROJECT_ID` and `FLAGSMITH_ENVIRONMENT_KEY` (client-side key only). The CLI authenticates separately. `node scripts/guard.mjs inspect` returns compact flag metadata. `node scripts/guard.mjs plan checkout_v2 create - create-proposal.json` creates an expiring snapshot without a management write. For a compatible existing flag use `node scripts/guard.mjs plan checkout_v2 rollout 10 rollout-proposal.json`; for rollback use `node scripts/guard.mjs plan checkout_v2 disable - rollback-proposal.json`. Use a fresh unique file for every operation. The operator, not the agent, must run `node scripts/guard.mjs apply ` in their interactive terminal, review the project and environment fingerprint, and type the exact approval phrase. Do not enter the phrase on their behalf, pipe input, alter proposal files, or bypass the stale-state checks. The helper validates the target and reads back the changed state; on uncertainty stop and inspect. Proposals contain flag snapshots: keep them local and do not publish them. In the ProofStack repo, the demo's `probe.mjs` evaluates stable synthetic identities and runs four checkout contract assertions per result. A deliberate fault can reproduce a regression in treatment; do not claim a real incident or customer metric. If treatment failures occur and control passes, present the rollback evidence; if there are SDK errors, unhealthy control, or missing treatment exposure, hold the release. Record actual test output and CLI-reported AI usage when available.