Hacker
Suryansh Singh
@suryansh.singh_07
Projects
Flagsmith Safe Rollout & Cleanup — Agent Skill
Flagsmith Experimentation HackathonNov 2026
I built flagsmith-safe-rollout, an end-to-end Agent Skill built on Flagsmith CLI v2+ (flagsmith) and the Flagsmith Python SDK that guides AI coding agents safely through the complete feature-flag lifecycle. Problems it solves: LLM context bloat: Raw Flagsmith JSON payloads dump thousands of unnecessary tokens into an agent's context window. Using --json --jq projections and compact script summaries reduces context usage by 92.5% to 96.3% (measured via benchmark_tokens.py on a 25-flag environment: 19,727 chars raw vs. 1,477 chars --jq vs. 735 chars scan summary). Unsafe flag mutations: AI agents often modify production flags without previews, forget SDK fallbacks, or skip verification. This skill enforces dry-run defaults, blocks Production changes unless --confirm-prod is explicitly passed, verifies flag evaluations (flagsmith evaluate --test), and outputs a ready-to-run flagsmith flag disable rollback command on every apply. Feature-flag tech debt: Teams leave 100%-rolled-out or archived flags scattered in application code. The skill detects stale flag references via Python AST analysis and prepares safe removal and flagsmith feature update --archive commands. Who would use it: Engineering teams and solo developers using AI coding agents (Claude Code, Cursor, Codex, or Antigravity) who want their agent to create, test, roll out, and clean up Flagsmith feature flags safely without wasting tokens or risking production outages. How it works: The skill uses progressive disclosure (SKILL.md + on-demand references/cli-cheat-sheet.md) and four deterministic Python lifecycle scripts wired to Flagsmith CLI v2: Phase 1 — Preflight & Snapshot (preflight.py): Verifies flagsmith.json, checks CLI auth (flagsmith auth status), inspects the environment via --jq to flag Production guardrails, and captures an environment snapshot before changes. Phase 2 — Code & Diff Audit (scan_flags.py): Uses Python AST parsing to check that every Flagsmith SDK call has a safe fallback, scans PR diffs for risky unflagged functions, and cross-references code calls with live Flagsmith flags. Phase 3 — Guarded Rollout (rollout_guard.py): Defaults to --dry-run to preview exact CLI commands. On --apply, it guards Production, resolves variant IDs via flagsmith feature variant list, applies weighted rollouts (flagsmith flag update --weight), runs flagsmith evaluate --test, and prints an instant rollback command. Phase 4 — Stale Flag Cleanup (cleanup_stale.py): Cross-references flagsmith feature list --include-archived and flagsmith flag list against code call sites to locate dead branches and generate flagsmith feature update --archive commands. Includes a FastAPI demo app (demo_app/) with SafeFlagClient offline/fallback protection, cross-agent mirroring (install_skill.py), and 15 passing pytest tests.