# Flag Prerequisites

> Add, remove, or inspect feature-level prerequisites on a GrowthBook feature flag. Use when the user says "gate flag X on flag Y being enabled", "add a prerequisite", "flag X should only evaluate if flag Y is on", "remove the prerequisite on flag X", "what does this flag depend on", or "this flag should require the new-checkout flag to be true first". Feature-level prerequisites gate the entire fl…

- **Type:** Skill
- **Install:** `agentstack add skill-growthbook-skills-flag-prerequisites`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [growthbook](https://agentstack.voostack.com/s/growthbook)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [growthbook](https://github.com/growthbook)
- **Source:** https://github.com/growthbook/skills/tree/main/skills/flag-prerequisites

## Install

```sh
agentstack add skill-growthbook-skills-flag-prerequisites
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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:setup`.

## Workflow

### Path A — Add a prerequisite

1. **Fetch the flag's current prerequisites:**
   ```bash
   gb-call GET /api/v2/features/
   ```
   Capture the existing `prerequisites` array. The PUT below replaces the full array, so you need the current contents to avoid overwriting existing prerequisites.

2. **Confirm the prerequisite flag exists and is boolean:**
   ```bash
   gb-call GET /api/v2/features/
   ```
   Check `valueType`. If it is not `"boolean"`, halt:
   > "Feature-level prerequisites only support boolean flags. `` is a `` flag. To gate on a non-boolean flag's value, add a rule-level prerequisite instead via flag-targeting."

3. **Build the new prerequisites array.** Append to any existing entries. The condition is always `{"value": true}` — the gate means "prerequisite flag is on":
   ```json
   [
     { "id": "", "condition": "{\"value\": true}" },
     { "id": "", "condition": "{\"value\": true}" }
   ]
   ```

4. **Apply via draft:**
   ```bash
   echo '{"prerequisites":[...]}' \
     | gb-call PUT /api/v2/features//revisions/new/prerequisites -
   ```

5. Hand off to flag-publish.

### Path B — Remove a prerequisite

1. Fetch current prerequisites (step A-1 above).
2. Show the list and ask which to remove.
3. Build the updated array without the removed entry.
4. Apply via draft (step A-4 above) with the filtered array. An empty array `[]` removes all prerequisites.
5. Hand off to flag-publish.

### Path C — Inspect current prerequisites

```bash
gb-call GET /api/v2/features/
```

Surface the `prerequisites` array. For each entry, fetch the prerequisite flag to show its current evaluated state and value type. Use flag-graph to trace the full dependency chain if needed.

## Guardrails

- **Draft version threading.** If a version number is already in context from a previous write skill in this session, use it explicitly (e.g. `.../revisions/42/prerequisites`) instead of `new`. This keeps all changes in the same draft. Fall back to `new` when starting fresh — it auto-creates or reuses the most recently updated open draft.
- **`PUT /prerequisites` replaces the full array.** It's not additive. Always fetch the current array first and include all existing entries when adding or modifying — otherwise you'll silently delete prerequisites the user didn't intend to touch.
- **Prerequisite flags must be boolean.** Halt and route to flag-targeting if the user specifies a non-boolean flag as a prerequisite.
- **The condition is always `{"value": true}`.** Do not accept or generate custom conditions for feature-level prerequisites. The backend is permissive but we intentionally constrain this — the gate means "this flag is on". If the user wants a richer condition (e.g. string flag equals a value, flag is live but not necessarily true), route to flag-targeting rule-level prerequisites.
- **Feature-level vs rule-level prerequisites.** This skill gates the entire flag. If the user wants a prerequisite scoped to a single rule, route to flag-targeting.
- **Circular dependencies must be avoided.** If flag A requires flag B and flag B requires flag A, neither will ever evaluate. Check the existing dependency chain via flag-graph before adding a prerequisite.
- **Prerequisite flags must be in the same GrowthBook project (or org-wide).** Cross-project prerequisites may not resolve correctly depending on SDK configuration.
- **Deleting a prerequisite flag breaks any flag that depends on it.** The dependent flag's prerequisite condition will silently always fail. Surface this when the user is reviewing dependencies via flag-graph before cleanup.

## Endpoints used

- `GET /api/v2/features/:id` — fetch flag state including current `prerequisites` array
- `PUT /api/v2/features/:id/revisions/new/prerequisites` (body: `{ "prerequisites": [...] }`)

## Handoffs

- `flag-search` — to find the prerequisite flag's ID if the user gives a name
- `flag-graph` — to trace the full dependency chain and detect circular dependencies
- `flag-targeting` — to add rule-level prerequisites (scoped to a single rule rather than the whole flag)
- `flag-publish` — to publish the draft, handle approval-required (400) and merge conflicts (409)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [growthbook](https://github.com/growthbook)
- **Source:** [growthbook/skills](https://github.com/growthbook/skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-growthbook-skills-flag-prerequisites
- Seller: https://agentstack.voostack.com/s/growthbook
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
