Agent skill

Feature Flag

by speakeasy-api in speakeasy-api/gram

A skill your agent uses when gating a feature behind a flag, dogfooding or gradually rolling out a change, choosing between productfeatures and PostHog feature flags, adding or checking a product…

AGPL-3.0Auto-check passedBackend & APIs

Install Feature Flag

skills CLI
$ npx skills add speakeasy-api/gram --skill feature-flag -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install speakeasy-api/gram feature-flag --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/speakeasy-api/gram.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/feature-flag .claude/skills/feature-flag && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
feature-flag
GitHub stars
272
Token cost
~2.6k tokens
SKILL.md length
883 words
Files
1
Skills in repo
39
Repo updated
First seen
Licence
AGPL-3.0

At a glance

A skill your agent uses when gating a feature behind a flag, dogfooding or gradually rolling out a change, choosing between productfeatures and PostHog feature flags, adding or checking a product…

  • Gating a feature behind a flag
  • SKILL.md covers Two systems, two purposes, productfeatures, PostHog feature flags and Common mistakes
  • Calls mise
  • Gradually rolling out a change

What it does

Feature Flag is an agent skill from speakeasy-api/gram. Use when gating a feature behind a flag, dogfooding or gradually rolling out a change, choosing between productfeatures and PostHog feature flags, adding or checking a product feature or PostHog flag, or working out why a flag does not apply to an organization, project, or user.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs. It works with PostHog and PostgreSQL. The repository describes itself as: Securely scale AI usage across your organization. A single stack to Connect, Secure, Observe and Distribute agents, MCPs, and Skills within your company. The licence is AGPL-3.0.

When your agent uses it

  • Gating a feature behind a flag
  • Gradually rolling out a change
  • Choosing between productfeatures and PostHog feature flags
  • Checking a product feature

Example prompts

  • “/feature-flag”

What it can do on your machine

Read from SKILL.md and the folder at commit 4d32da1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • mise

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Feature Flag loads about 2.6k tokens when it runs. Until then it costs about 74 tokens; SKILL.md has 883 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~74
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from speakeasy-api/gram at commit 4d32da1, republished under its AGPL-3.0 licence (© speakeasy-api). 883 words, ~2,615 tokens.

Download SKILL.mdSave it as .claude/skills/feature-flag/SKILL.md (or your agent's skills folder).
name
feature-flag
description
Use when gating a feature behind a flag, dogfooding or gradually rolling out a change, choosing between `productfeatures` and PostHog feature flags, adding or checking a product feature or PostHog flag, or working out why a flag does not apply to an organization, project, or user.
metadata.relevant_files
server/internal/productfeatures/**/*.go, server/internal/productfeatures/queries.sql, server/design/shared/productfeatures.go…

Two systems, two purposes

Gram has two distinct feature-gating mechanisms. They are not interchangeable — pick based on the semantics of the flag, not on convenience.

productfeaturesPostHog feature flags
ScopePer-organizationPer-organization, per-project, or per-user
Who controls itOrg admins (dashboard) or Speakeasy opsEngineering (PostHog console)
PersistencePostgreSQL (organization_features table)PostHog platform
DirectionPermanent capability toggle; maps to entitlementsTemporary rollout gate; removed once GA
Example use"This org has SSO" / "This org was sold Risk""Dogfood this UI change with our org"
FrontenduseProductFeatures() hookuseFeatureFlag() hook
Decision rule

Use productfeatures when the toggle represents a durable, org-level capability that admins control or that maps to what the customer purchased (entitlement). Think: GCP's per-project API enablement.

Use PostHog flags when you're rolling something out gradually, dogfooding a change internally, or need per-user granularity. The flag is expected to disappear once the feature ships to everyone.


productfeatures

Concepts
  • Feature constants live in server/internal/productfeatures/features.go as typed string constants (Feature type).
  • State is stored in organization_features (PostgreSQL). Soft-deletes track removal.
  • productfeatures.Client checks Redis first (15 min TTL), falls back to Postgres, and returns errors on lookup failures — use PlatformFeatureCheck when you want silent false-on-error degradation.
  • The management API (/rpc/productFeatures.get and /rpc/productFeatures.set) exposes the state to the dashboard and Speakeasy ops.
Adding a new product feature

1. Declare the constant in server/internal/productfeatures/features.go:

go
const (
    FeatureMyNewFeature Feature = "my_new_feature"
)

2. Add it to the Goa design in server/design/shared/productfeatures.go:

go
// In the setProductFeature method's Enum constraint:
Enum("logs", "tool_io_logs", ..., "my_new_feature")

// In the getProductFeatures Result:
Attribute("my_new_feature_enabled", Boolean, "Whether my new feature is enabled")

3. Wire the result in server/internal/productfeatures/snapshot.go:

go
MyNewFeatureEnabled: isEnabled(FeatureMyNewFeature),

4. Regenerate with mise run gen:goa-server (Goa codegen updates gen/).

Checking a feature at runtime (Go)
go
// inject *productfeatures.Client — it's already wired in cmd/gram/start.go
enabled, err := pf.IsFeatureEnabled(ctx, organizationID, productfeatures.FeatureMyNewFeature)
if err != nil {
    return fmt.Errorf("check my_new_feature: %w", err)
}

Use PlatformFeatureCheck (returns bool, logs errors, degrades to false) only in non-critical paths where you want silent degradation.

Checking in the React dashboard
tsx
const { data: features } = useProductFeatures();
if (features?.myNewFeatureEnabled) { ... }

PostHog feature flags

Concepts
  • Flag keys are typed Flag constants in server/internal/feature/flags.go. The constant's comment is the one place per flag that records where it is evaluated (server, dashboard, or both) and how it is targeted.
  • The server reaches PostHog only through feature.Provider (inject it; tests use feature.InMemory). The dashboard uses useFeatureFlag().
  • For org-scoped server gates, distinctID is the organization ID and groups is feature.OrgProjectGroups(orgSlug, projectSlug): the organization group keyed by org slug and the slug group keyed by <org>/<project>, the same groups the dashboard registers.
How the server evaluates a flag

In production the SDK caches flag definitions (polled every minute) and evaluates locally, calling PostHog only for conditions it cannot decide from the distinct ID and group keys the server passes; IsFlagEnabledLocal never calls out and adds person properties. Expect up to a minute for a flip to land, stale definitions during an outage, and an Unable to compute flag locally (<key>) debug line whenever a condition needs data the server does not send.

Targeting rule for org and project flags

In the PostHog condition set, match by the organization group type and target "organization key is one of ..." (stored as $group_key); use the slug group key for project scope. Never target a group property such as organization_slug, a cohort, or person properties, except person properties a caller supplies through IsFlagEnabledLocal: the server otherwise passes group keys only, so those conditions call PostHog on every evaluation and miss most orgs, in the dashboard too.

Show full SKILL.md (363 more words)Show less
Provider surface
CallReturnsUse when
IsFlagEnabled(ctx, flag, distinctID, groups)bool, errorPlain rollout gate; cannot tell unavailable from off, so handle err
feature.EvaluateFlag(ctx, provider, flag, distinctID, groups)Evaluation, errorGates that fail closed; missing key, disabled provider, or error is Indeterminate
feature.FlagVariant(ctx, provider, flag, distinctID, groups)Variant, errorMultivariate flags; map "" or an error to the pre-rollout behaviour
FlagPayload(ctx, flag, distinctID, groups)[]byte, errorThe flag carries config (e.g. a version pin); nil or an error means no clearance
IsFlagEnabledLocal(ctx, flag, distinctID, groups, personProperties)bool, errorHot paths that must never call PostHog; inconclusive reads as false

Fail closed: treat Indeterminate and errors as "unavailable", never as an explicit off, and never let a flag stand in for RBAC or an entitlement.

Adding a new PostHog flag

1. Declare the constant in server/internal/feature/flags.go with a comment saying where it is evaluated and how it is targeted:

go
const (
    // FlagMyNewFeature gates X. Evaluated server-side; targeted by PostHog
    // organization group (org slug). Fails closed. Removed once X is GA.
    FlagMyNewFeature Flag = "my-new-feature" // must match the key in PostHog
)

2. Create the flag in PostHog before the gating code merges; a missing key evaluates as Indeterminate and the gate stays closed. Write the description like gram-budgets (org-scoped) or risk-async-scan-shadow (person-property, local-only): what it gates, where it is evaluated, how it is targeted, fail-closed behaviour.

3. Verify the condition with evaluation reasons (Feature flag → Evaluation reasons, or the feature-flags-evaluation-reasons-retrieve MCP tool) using groups={"organization": "<slug>"} for at least one target org and expect condition_match.

4. Check at runtime by injecting feature.Provider:

go
groups := feature.OrgProjectGroups(authCtx.OrganizationSlug, "")
evaluation, err := feature.EvaluateFlag(ctx, s.features, feature.FlagMyNewFeature, authCtx.ActiveOrganizationID, groups)
if err != nil {
    s.logger.WarnContext(ctx, "evaluate my-new-feature flag", attr.SlogError(err))
}
if evaluation != feature.EvaluationEnabled { // Disabled and Indeterminate both fail closed
    return oops.C(oops.CodeNotFound)
}
Checking in the React dashboard

Use the typed useFeatureFlag() hook from client/dashboard/src/hooks/useFeatureFlag.ts and register keys in FEATURE_FLAGS (client/dashboard/src/lib/featureFlags.ts); never import PostHog hooks directly:

tsx
const assistants = useFeatureFlag(FEATURE_FLAGS.assistants);

if (assistants.status === "loading") return null;
if (assistants.status === "missing" || assistants.status === "error") {
  return <FeatureUnavailable />;
}

const assistantsEnabled = assistants.status === "enabled";

The hook stays reactive as PostHog reloads flags. On localhost, the development telemetry provider reports every flag as enabled. PostHog flags control rollout UI only, never authorization or entitlement enforcement.


Common mistakes

  • Don't use productfeatures for a temporary dogfood gate. It creates API surface (getProductFeatures result field, Goa enum) that must be maintained indefinitely.
  • Don't use PostHog for entitlements. PostHog is engineer-controlled and ephemeral; entitlement checks belong in productfeatures so org admins and billing can manage them.
  • Don't hardcode PostHog flag strings in multiple places. Always declare them as constants in feature/flags.go.
  • Don't call the PostHog SDK directly from Go handlers. Always go through the feature.Provider interface so tests can inject a noop.

© speakeasy-api, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/feature-flag of speakeasy-api/gram.

Open the folder on GitHubat commit 4d32da1

Compare with similar skills

Feature Flag next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Feature Flag compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Feature Flag this skillspeakeasy-api/gram272—~2.6kAutomated safety check: PassAGPL-3.0
Adding Personhog RpcPostHog/posthog-foss721—~2.1kAutomated safety check: PassMIT
Django MigrationsPostHog/posthog-foss721—~5kAutomated safety check: PassMIT
Profiling Slow API EndpointsPostHog/posthog-foss721—~1kAutomated safety check: PassMIT
Prod TelemetryUsefulSoftwareCo/executor4.1k—~1.9kAutomated safety check: PassMIT
Adding Warehouse Person PropertiesPostHog/posthog-foss721—~2.9kAutomated safety check: PassMIT

Similar skills

  • Adding Personhog Rpc

    PostHog/posthog-foss

    Official

    Guide for adding a new RPC to personhog-replica and personhog-router.

    721 GitHub stars~2.1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Django Migrations

    PostHog/posthog-foss

    Official

    Django migration patterns and safety workflow for PostHog. An agent skill from PostHog/posthog-foss.

    721 GitHub stars~5k tokensUpdated today
    Backend & APIsAuto-check passed
  • Profiling Slow API Endpoints

    PostHog/posthog-foss

    Official

    Profiles slow PostHog API endpoints when the main cost is in Postgres or Python.

    721 GitHub stars~1k tokensUpdated today
    DatabasesAuto-check passed
  • Prod Telemetry

    UsefulSoftwareCo/executor

    Query Executor's production telemetry — Axiom traces (executor-cloud dataset), prod Postgres via PlanetScale, PostHog product analytics — through the Executor MCP.

    4.1k GitHub stars~1.9k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Official

    Sync columns from a synced data warehouse table onto PostHog person or group properties, so warehouse data becomes usable anywhere person and group properties already work: feature flag targeting…

    721 GitHub stars~2.9k tokensUpdated today
    DatabasesAuto-check passed
  • Modifying Taxonomic Filter

    PostHog/posthog-foss

    Official

    Guides safe changes to the TaxonomicFilter, PostHog's picker for events, actions, properties, cohorts, and more.

    721 GitHub stars~2.8k tokensUpdated today
    DevelopmentAuto-check passed

More from speakeasy-api/gram

All 39 skills in this repo
  • Gram Playwright CLI

    speakeasy-api/gram

    A skill your agent uses when automating the Gram dashboard in a browser, capturing screenshots, inspecting pages.

    272 GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Transactional Email

    speakeasy-api/gram

    A skill your agent uses when adding, changing, restyling, reviewing, validating, or previewing a Gram/Speakeasy transactional email, in Go or in LMX/MJML — a template<name.go, a TemplateKey…

    272 GitHub stars~4.7k tokensUpdated today
    Auto-check passed
  • Admin Shadcn

    speakeasy-api/gram

    A skill your agent uses when adding, changing, or styling UI in client/admin (the Gram admin dashboard) that touches shadcn/ui — a button, dialog, table, sidebar, badge, select, tabs, tooltip, card…

    272 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • A skill your agent uses when adding, editing, reviewing, testing, or locating a reviewed skill distributed with the Platform MCP plugin; triggers include "Platform MCP skill", "platformmcpskills"…

    272 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Clickhouse

    speakeasy-api/gram

    A skill your agent uses when changing or reviewing Gram ClickHouse schemas, migrations, queries, inserts, access principals, bootstrap SQL, Cloud compatibility, partial migration failures, or…

    272 GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • Gram Pubsub Python

    speakeasy-api/gram

    How to build and run GCP Pub/Sub stream subscribers in Python under pystreams/ — the multi command (start at pystreams/src/pystreams/cmd/multi.py), the graminfra.pubsub publisher/subscriber library…

    272 GitHub stars~4.1k tokensUpdated today
    Auto-check passed

Categories

Questions about Feature Flag

What does Feature Flag do?

A skill your agent uses when gating a feature behind a flag, dogfooding or gradually rolling out a change, choosing between productfeatures and PostHog feature flags, adding or checking a product…. Feature Flag is an agent skill from speakeasy-api/gram. Use when gating a feature behind a flag, dogfooding or gradually rolling out a change, choosing between productfeatures and PostHog feature flags, adding or checking a product feature or PostHog flag, or working out why a flag does not apply to an organization, project, or user.

When should I use Feature Flag?

Feature Flag fits situations like: gating a feature behind a flag; gradually rolling out a change; choosing between productfeatures and PostHog feature flags; checking a product feature.

How do I install Feature Flag in Claude Code?

Run `npx skills add speakeasy-api/gram --skill feature-flag -a claude-code`. Or copy the skill folder (.agents/skills/feature-flag in speakeasy-api/gram) into .claude/skills/feature-flag in your project. Claude Code loads it when a task matches its description.

How do I install Feature Flag in Codex?

Run `npx skills add speakeasy-api/gram --skill feature-flag -a codex`. Or copy the skill folder (.agents/skills/feature-flag in speakeasy-api/gram) into .agents/skills/feature-flag in your project. Codex loads it when a task matches its description.

Can I use Feature Flag in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add speakeasy-api/gram --skill feature-flag -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/feature-flag, .gemini/skills/feature-flag, .github/skills/feature-flag and .opencode/skills/feature-flag in your project.

What does Feature Flag need to run?

Going by SKILL.md and its folder, Feature Flag needs the command-line tools its instructions call (mise).

Does Feature Flag access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Feature Flag safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Feature Flag use?

Feature Flag is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Feature Flag use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Feature Flag?

Skills that share tags, products or a category with Feature Flag: Adding Personhog Rpc (PostHog/posthog-foss, 721 stars), Django Migrations (PostHog/posthog-foss, 721 stars), Profiling Slow API Endpoints (PostHog/posthog-foss, 721 stars) and Prod Telemetry (UsefulSoftwareCo/executor, 4.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Feature Flag?

speakeasy-api (a GitHub organization) maintains it in speakeasy-api/gram, which has 272 GitHub stars. The repository holds 39 skills in this directory. The repository was last updated on October 7, 2026.

Source: speakeasy-api/gram on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.