flags-sdk
Flags SDK and Vercel Flags expert guidance. Use when declaring feature flags with flag(), wiring provider adapters (Vercel, Statsig, LaunchDarkly, PostHog…
от CognitionAI★ 42 звезды на GitHub
Установить flags-sdk в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Flags SDK
The Flags SDK (flags npm package) is a feature flags toolkit for Next.js and SvelteKit. It turns each feature flag into a callable function, works with any flag provider via adapters, and keeps pages static using the precompute pattern. Vercel Flags is the first-party provider, letting you manage flags from the Vercel dashboard or the vercel flags CLI.
- Docs: https://flags-sdk.dev
- Repo: https://github.com/vercel/flags
Core concepts
Flags as code
Each flag is declared as a function. No string keys at call sites:
import { flag } from 'flags/next';
export const exampleFlag = flag({
key: 'example-flag',
decide() { return false; },
});
const value = await exampleFlag();
Server-side evaluation
Flags evaluate server-side to avoid layout shift, keep pages static, and maintain confidentiality. Combine routing middleware with the precompute pattern to serve static variants from CDN.
Adapter pattern
Adapters replace decide and origin on a flag declaration, connecting your flags to a provider. Vercel Flags (@flags-sdk/vercel) is the first-party adapter. Third-party adapters are available for Statsig, LaunchDarkly, PostHog, and others.
import { flag } from 'flags/next';
import { vercelAdapter } from '@flags-sdk/vercel';
export const exampleFlag = flag({
key: 'example-flag',
adapter: vercelAdapter,
});
Version note: The SDK is published as
flags(renamed from@vercel/flags; that old name still appears in changelog history).flags4.2.0+ accepts the adapter factory by reference (adapter: vercelAdapter) and resolves it once per declaration. Older versions require calling it (adapter: vercelAdapter()). The called form still works on new versions, so prefer the shorthand unless you're targetingflags< 4.2.0.
Agent workflow: Creating a new flag
When a user asks you to create or add a feature flag, follow these steps in order. Do not leave CLI steps as "next steps" for the user — execute them yourself.
Before you start
Check the project state to adapt commands and decide which steps you can skip:
- Which lockfile is present (
pnpm-lock.yaml,package-lock.json,yarn.lock,bun.lockb)? → Adapt all package manager commands accordingly (pnpm add,npm install,yarn add,bun add). - Is
flagsinpackage.json? → Skip install (step 1) - Does
.vercel/directory exist? → Project is linked, skipvercel linkin step 2 - Does
.env.localcontainFLAGS=? → Env vars already pulled, skip step 3 - Does
flags.ts(orlib/flags.ts,src/flags.ts) exist? → Add to it rather than creating from scratch (step 4) - Is
@vercel/toolbarinpackage.json? → Skip toolbar setup (step 6) - Does
app/.well-known/vercel/flags/route.tsexist? → Flags Explorer already set up, skip step 7
Steps
Install packages (if not already in
package.json):pnpm i flags @flags-sdk/vercelRegister the flag with Vercel: Run
vercel flags add <flag-key> --kind boolean --description "<description>".Prerequisite: The
vercel flagscommands require the Vercel CLI to be installed and authenticated. If the Vercel CLI is not installed, runpnpm i -g vercel. For authentication or linking issues, follow thevercel-cliskill if it's already available. If it isn't, suggest the user install it withnpx skills add vercel/vercel@vercel-cli(don't auto-install it) and rely onvercel <command> --helpin the meantime.Before running
vercel flags add, verify the project is linked to Vercel. Check for a.verceldirectory in the project root. If it doesn't exist, runvercel linkfirst.Pull environment variables: Run
vercel env pullto writeFLAGSandFLAGS_SECRETto.env.local. Without these environment variables,vercelAdapterwill not be able to evaluate flags. This step is mandatory after creating a flag.Declare the flag in code: Add it to
flags.ts(or create the file if it doesn't exist) usingvercelAdapter:import { flag } from 'flags/next'; import { vercelAdapter } from '@flags-sdk/vercel'; export const myFlag = flag({ key: 'my-flag', adapter: vercelAdapter, });Use the flag: Call it in your page or component and conditionally render based on the result:
import { myFlag } from '../flags'; export default async function Page() { const enabled = await myFlag(); return <div>{enabled ? 'Feature on' : 'Feature off'}</div>; }Set up the Vercel Toolbar (if not already present):
- Run
pnpm i @vercel/toolbar - Wrap
next.config.tswith the toolbar plugin - Render
<VercelToolbar />in the root layout See references/nextjs.md — Toolbar Setup for the full code.
- Run
Set up Flags Explorer (if not already present): Create
app/.well-known/vercel/flags/route.ts— see the [Flags Explorer setup](#flags-explor
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- overlay.yaml
- references/api.md
- references/nextjs.md
- references/providers.md
- references/sveltekit.md
- upstream/SKILL.md
- upstream/references/api.md
- upstream/references/nextjs.md
- upstream/references/providers.md
- upstream/references/sveltekit.md
FAQ
Что делает скилл flags-sdk?
Flags SDK and Vercel Flags expert guidance. Use when declaring feature flags with flag(), wiring provider adapters (Vercel, Statsig, LaunchDarkly, PostHog, and others), managing flags with the vercel flags CLI, implementing the precompute pattern for static A/B tests, or integrating the Flags Explorer.
Как установить скилл flags-sdk?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл flags-sdk запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…