Feature flags, A/B tests, and gradual rollouts with Vercel Flags, in any app or framework. Use whenever the user is planning, adding, or changing a feature flag, toggle, kill switch, experiment, percentage rollout, or targeting rule, or wants to gate or hide a feature for some users, even before a library or provider is chosen. Covers choosing an integration (Flags SDK, `@vercel/flags-core`, OpenFeature), the Vercel dashboard, the `vercel flags` CLI (create, inspect, set, split, rollout, rules, segments, evaluations, archive), OIDC vs SDK keys, `FLAGS_SECRET`, and Flags Explorer overrides. For `flag()` declarations, adapters, precompute, and the Flags Explorer endpoint in Next.js or SvelteKit code, load the `flags-sdk` skill.
78
98%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Vercel Flags is Vercel's feature flags platform. Flags are created and managed in the Vercel dashboard or with the vercel flags CLI, evaluated server-side in your app, and switched per environment (Development, Preview, Production) without a redeploy.
Use this skill to decide how a feature should be flagged, to create and change flags, and to run rollouts and experiments. Write app code with the skill that matches the stack (see Choose an approach). Do not leave CLI steps as "next steps" for the user; execute them yourself.
.env.local (except vercel flags override, which reads FLAGS_SECRET).flags in package.json): load the flags-sdk skill right away; it creates the flag on Vercel and declares it in code.Check the project before writing code.
flags-sdk skill. On any other stack, use the provider's own SDK. Rollouts, targeting, and experiments for that provider are configured in its own dashboard, not with vercel flags; the CLI and lifecycle sections of this skill do not apply.flags + @flags-sdk/vercel). It adds Flags Explorer integration and precompute for static pages. Load the flags-sdk skill. If it is not available, suggest npx skills add vercel/flags@flags-sdk (do not auto-install).@vercel/flags-core. See Other frameworks.The dashboard and the vercel flags CLI work the same for every integration.
Decide these before creating the flag; the kind cannot be changed later.
boolean for on/off and kill switches; string, number, or json when the flag selects a variant or carries configuration (Flag types).control, new-checkout), not after the rollout step.key in flag() or the first argument of evaluate()).user.id. Define the entity and attribute under Flags → Entities first; the app must return the same names from its evaluation context (Entities).defaultValue in code.The CLI uses your Vercel account authentication. SDK keys and vercel env pull are application credentials, not CLI prerequisites.
Prerequisite: The Vercel CLI must be installed and authenticated. If it is not installed, run
pnpm i -g vercel. For authentication or linking issues, follow thevercel-cliskill if it is available. If it is not, suggestnpx skills add vercel/vercel@vercel-cli(do not auto-install it) and rely onvercel <command> --helpin the meantime.
Run vercel flags --help for the current subcommand list and vercel flags <cmd> --help before using a subcommand. references/cli.md covers what --help cannot: how CLI concepts map to the app, promotion order, static value vs targeting mode, and the checks to run before archiving or deleting.
Use --project <name-or-id> and --scope <team> to select the target without a local link. If the CLI rejects --project, upgrade it first (pnpm i -g vercel). Without these options the commands use the linked project: run vercel project inspect --non-interactive and check the reported owner and project name; a .vercel/ directory alone does not prove a link. If it reports link_required, the project is not linked. If the user named a project or team and the output differs, stop and ask instead of relinking. In an unlinked directory, prefer --project / --scope over vercel link; if the target project is unknown, ask.
Always inspect first so you know what each environment serves today, and match the CLI key to the flag the application already declares; creating a second flag is not a substitute for adopting an existing one.
vercel flags create <key> --kind boolean --description "<description>". If the key exists, adopt it instead.enable / disable for boolean flags, set <key> to serve one variant of any kind. These put the environment in static value mode.rollout <key> --by user.id ... (Roll out a feature).split <key> --by user.id ... (Run an A/B test).rules, segments, and use-targeting <key> to switch an environment from a static value back to targets and rules.inspect for the served state, versions for history, evaluations to confirm traffic reaches the new variant.archive; rm only for archived flags. Follow Lifecycle and safety.archive, unarchive, rm, and update --remove-variant prompt for confirmation. Pass --yes when the user has approved the action.
vercel env pull writes the Development token to .env.local for local development (Getting started).FLAGS): only for apps outside Vercel, custom environments, or flags owned by another project. Each key is scoped to one environment and shown once, at creation (SDK Keys). Not a recovery path for failed CLI authentication.FLAGS_SECRET: created per environment when Vercel Flags is activated for a project. It signs Flags Explorer overrides and precompute codes, and vercel flags override reads it from the environment or .env.local. Preserve existing values and never rotate them as part of routine setup; a missing local value does not mean the remote value is missing, so check the target environment before generating one. The flags-sdk skill documents how to generate a missing value. Do not print secrets to the terminal, logs, or chat.Flags Explorer is the Vercel Toolbar panel that lists the app's flags and lets you override them per browser through a cookie signed with FLAGS_SECRET (Flags Explorer). The app exposes its flags through a discovery endpoint; the Flags SDK generates it (flags-sdk skill). vercel flags override <key>=<value> produces the same cookie token from the terminal.
For frameworks without a Flags SDK entrypoint, use @vercel/flags-core directly (Core SDK). Create one client at module scope and call evaluate() or bulkEvaluate() inside a request handler; both initialize the client on first use. Do not add a module-scope client.initialize() call or cache its promise for handlers to await.
// src/flags.ts
import { createClient } from '@vercel/flags-core';
const client = createClient();
// Call from a request handler, not during module loading.
export async function showNewCheckout(userId: string): Promise<boolean> {
const result = await client.evaluate<boolean>('new-checkout', false, {
user: { id: userId },
});
return result.value;
}With OIDC the token can come from request context and may not exist during module loading. Even embedded definitions need it to select the entry by the token's project_id, and local .env.local credentials can hide this timing problem. Explicit initialization is optional and must wait until authentication is available; awaiting an already-started initialization promise later does not move it into request context. Outside Vercel, pass the SDK key: createClient(process.env.FLAGS).
The third argument to evaluate() is the evaluation context; its entity and attribute names must match the ones defined under Flags → Entities so rollouts and rules can bucket on them.
vercel flags concepts map to the app (key, kind, variants, fallback, targeting attributes, timestamp conditions, authentication, overrides, embedded definitions), and the lifecycle and safety checklist for promoting, verifying, removing, and archiving flags.vercel/vercel-plugin
0db4408
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.