flag-prerequisites
flag-prerequisites
Add, remove, or inspect feature-level prerequisites on a GrowthBook feature flag. A feature-level prerequisite is a boolean gate: if the specified prerequisite flag is off for a user, the current flag skips all its rules and returns its defaultValue for that user.
Feature-level prerequisites are boolean-flag-only. The prerequisite flag must have valueType: "boolean". The gate condition is always "prerequisite flag is on" ({"value": true}) — no custom conditions. If the user wants a more nuanced dependency (e.g. gate on a string flag's value, or gate a single rule rather than the whole flag), route to flag-targeting.
This is distinct from rule-level prerequisites (which gate a single rule and support richer conditions) — feature-level prerequisites apply to every rule on the flag simultaneously.
All API calls go through the bundled helper: ${CLAUDE_PLUGIN_ROOT}/scripts/gb-call. It needs GB_API_KEY set in env or written to ~/.config/growthbook/.env by /growthbook:gb-setup.
Workflow
Path A — Add a prerequisite
- Fetch the flag's current prerequisites:
Capture the existinggb-call GET /api/v2/features/<flag-id>prerequisitesarray. The PUT below replaces the full array, so you need the current contents to avoid overwriting existing prerequisites.