feature-flags
Skill0 starsChanged 32 days agoMITView on GitHub
Implementing, gating, and cleaning up feature flags: picks the right flag type (boolean, percentage rollout, user-targeted), wires up a flag client (LaunchDarkly, Unleash, Flagsmith, or homegrown config), wraps new code in flag checks without coupling business logic to the flag system, tracks flag age, and removes stale flags safely. Use when you want to add a feature flag, do a gradual rollout, gate a feature for specific users, implement a kill switch, set up LaunchDarkly or Unleash, clean up an old flag, or roll back without deploying.
- Reads credentials
20 other projects use a version of this.
Adopted by
Most recently taken up by
- Cure-Consulting-Group/ProductEngineeringSkillstheir own version, first seen Nov 4, 2026
- primer/reacttheir own version, first seen Nov 1, 2026
- MiguelSavignano/claude-code-systemtheir own version, first seen Nov 1, 2026
- macro-inc/macrotheir own version, first seen Oct 25, 2026
- vindreshsingh/engineering-skillstheir own version, first seen Oct 20, 2026
- irahardianto/awesome-agvtheir own version, first seen Oct 14, 2026
Used with
Projects with it also use observability, incident-response and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 6 projects that use this
AnthropicSkillincident-response
Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.
Also in 5 projects that use this
etewiahSkille2e-testing
Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.
Also in 3 projects that use this
0xSeroSkillsecurity
Also in 3 projects that use this
Other versions20 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 20
- react/react★ 252ksame name
- facebook/react★ 252ksame name
- getsentry/sentry★ 46ksame name
- redis/RedisInsight★ 8.9ksame name
- BuilderIO/agent-native★ 7.6ksame name
- macro-inc/macro★ 6ksame name
- primer/react★ 3.9ksame name
- marcus/sidecar★ 1.1ksame name
- kid-sid/claude-spellbook★ 190same name
- irahardianto/awesome-agv★ 157same name
10 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository68 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- accessibilitySkill
- api-designSkill
- api-versioningSkill
- authSkill
- background-jobsSkill
- cachingSkill
- capacity-planningSkill
- changelogSkill
- chaos-engineeringSkill
- ci-cdSkill
- circuit-breakerSkill
- claude-best-practicesSkill
- code-commentsSkill
- code-hygieneSkill
- code-reviewSkill
- code-structureSkill
- commit-styleSkill
- concurrency-and-lockingSkill
- database-transactionsSkill
- data-consistencySkill
- debug-infra-startupSkill
- debug-sessionSkill
- demo-video-creatorSkill
- demo-video-script-creatorSkill
- dependency-injectionSkill
- dependency-updateSkill
- disk-cleanupSkill
- distributed-tracingSkill
- dockerSkill
- env-configSkill
- env-setupSkill
- error-handlingSkill
- event-driven-architectureSkill
- file-storageSkill
- graceful-shutdownSkill
- idempotencySkill
- input-validationSkill
- jars-engineering-blogsmithSkill
- jars-workshop-builderSkill
- licensingSkill
- loggingSkill
- memory-and-allocationsSkill
- migrate-dbSkill
- monitoringSkill
- multi-tenancySkill
- notificationsSkill
- openapiSkill
- paginationSkill
- perf-profileSkill
- pr-descriptionSkill
- query-optimizationSkill
- rate-limitingSkill
- refactorSkill
- releaseSkill
- runbook-writerSkill
- searchSkill
- secrets-auditSkill
- simplifySkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 13 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 17 edited versions we read keep these.
13
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Add, use, and eventually remove feature flags cleanly.
- Distinctive: line 19
Start with the simplest type that satisfies the requirement.
- Distinctive: line 35
Keep flags in a config file or environment variable and parse them at startup.
- Distinctive: line 49
Never call the flag SDK directly in business logic.
- Distinctive: line 123
Keep flag checks at the controller / handler / route level where possible.
- Distinctive: line 124
Never make a flag check affect database schema or migrations — those changes must be backward-compatible on their own.
- Very specific: line 129
Use kebab-case. Include a prefix that groups related flags.
- Distinctive: line 137
Add a comment or description in the flag dashboard explaining: what it gates, who owns it, and the intended removal date.
- Very specific: line 144
When you create a flag, open a ticket for its removal (e.g., "Remove new-checkout-flow flag after 100% rollout stabilises — target: 2 weeks …
- Distinctive: line 160
Search the codebase for every reference to the flag key string.
- Very specific: line 162
Delete the OLD code path and any types / helpers that only existed for it.
- Distinctive: line 164
Remove the flag key from any test overrides.
- Distinctive: line 174
Test both branches. Use the stub client, not the real SDK.
- Very specific: line 196
Always provide a safe default (usually false / the old behaviour).
- Distinctive: line 198
Never read flags in migrations, seed scripts, or schema definitions.
- Distinctive: line 199
Never hard-code a user ID as the only way to enable a flag in production — use targeting rules in the dashboard.
- Very specific: line 202
If the flag SDK is unavailable at startup, default to false and log a warning — don't crash.
- Distinctive: line 203
Treat the flag key string as an API: once it's in production, don't rename it.
“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
feature-flags
Add, use, and eventually remove feature flags cleanly.
1. Decide the flag type before writing any code
| Type | When to use | Example |
| Boolean (on/off) | Kill switch, staff-only preview | new-checkout-flow |
| Percentage rollout | Gradual exposure to reduce blast radius | Roll out to 5% → 25% → 100% |
| User / segment targeting | Beta testers, paying customers, internal team | user.plan === 'pro' |
| Multivariate | A/B testing or configuration values | button_color = blue|green|red |
Start with the simplest type that satisfies the requirement. Over-engineering flags is a common source of long-lived flag debt.
2. Pick a flag backend
Managed service (recommended for teams):
- LaunchDarkly — SDKs for every language, percentage rollouts, targeting rules, real-time streaming.
- Unleash — open-source, self-hostable, strong gradual rollout support.
- Flagsmith — open-source, supports remote config values alongside booleans.
Homegrown (fine for simple cases):
Keep flags in a config file or environment variable and parse them at startup. This works for kill switches and staff-only flags but does not support percentage rollouts or targeting without extra code.
// flags.json — simplest possible homegrown approach
{
"new-checkout-flow": false,
"enable-new-search": true
}3. Wrap the SDK in a thin abstraction
Never call the flag SDK directly in business logic. One wrapper keeps the system swappable and makes testing trivial.
// lib/flags.ts
export interface FlagClient {
isEnabled(flagKey: string, context?: FlagContext): boolean;
getVariant<T>(flagKey: string, defaultValue: T, context?: FlagContext): T;
}
export interface FlagContext {
userId?: string;
email?: string;
plan?: string;
[key: string]: string | undefined;
}
// LaunchDarkly implementation
import LaunchDarkly from '@launchdarkly/node-server-sdk';
const ldClient = LaunchDarkly.init(process.env.LD_SDK_KEY!);
await ldClient.waitForInitialization();
export const flags: FlagClient = {
isEnabled(key, ctx = {}) {
return ldClient.variation(key, { key: ctx.userId ?? 'anonymous', ...ctx }, false);
},
getVariant(key, defaultValue, ctx = {}) {
return ldClient.variation(key, { key: ctx.userId ?? 'anonymous', ...ctx }, defaultValue);
},
};// Stub for tests — no SDK needed
export const stubFlags = (overrides: Record<string, boolean> = {}): FlagClient => ({
isEnabled: (key) => overrides[key] ?? false,
getVariant: (key, defaultValue) => (overrides[key] as typeof defaultValue) ?? defaultValue,
});4. Write the flag check
Gate the new code path; always provide a fallback.
// ✅ Good — flag isolated at the call site, fallback is explicit
import { flags } from '../lib/flags';
export async function handleCheckout(req: Request, res: Response) {
const ctx = { userId: req.user.id, plan: req.user.plan };
if (flags.isEnabled('new-checkout-flow', ctx)) {
return newCheckoutHandler(req, res);
}
return legacyCheckoutHandler(req, res);
}// ❌ Bad — flag check buried inside business logic, hard to find and remove later
export function calculateTotal(items: Item[], userId: string) {
const base = items.reduce((s, i) => s + i.price, 0);
if (ldClient.variation('discount-rounding-fix', { key: userId }, false)) {
return Math.round(base * 100) / 100; // hidden deep in a helper
}
return base;
}5. Avoid coupling business logic to the flag system
- Pass the evaluated boolean into functions; don't call
flags.isEnabledfrom inside pure functions or domain models. - Keep flag checks at the controller / handler / route level where possible.
- Never make a flag check affect database schema or migrations — those changes must be backward-compatible on their own.
6. Name flags consistently
Use kebab-case. Include a prefix that groups related flags.
checkout-new-flow ✅
enable_new_checkout_FLOW ❌ inconsistent case
flag123 ❌ meaninglessAdd a comment or description in the flag dashboard explaining: what it gates, who owns it, and the intended removal date.
7. Track flag age and set a removal date
Flags are temporary by design. Long-lived flags become invisible tech debt.
- When you create a flag, open a ticket for its removal (e.g., "Remove
new-checkout-flowflag after 100% rollout stabilises — target: 2 weeks after full rollout"). - Enforce a maximum age with a lint rule or CI check:
# Simple shell check — fails CI if a flag string is older than 90 days in the codebase
# (adapt to your flag naming convention)
git log --all --diff-filter=A --format="%ai %H" -- "*.ts" \
| grep "new-checkout-flow" \
| awk '{ if (systime() - mktime(gensub(/-/, " ", "g", $1) " " gensub(/:/, " ", "g", $2) " 0") > 7776000) exit 1 }'8. Remove a stale flag
Once a flag is at 100% and stable:
- Search the codebase for every reference to the flag key string.
- Replace each
if (flags.isEnabled('my-flag')) { NEW } else { OLD }with justNEW. - Delete the
OLDcode path and any types / helpers that only existed for it. - Archive or delete the flag in the dashboard.
- Remove the flag key from any test overrides.
- Commit:
refactor: Remove my-flag feature flag (fully rolled out).
# Find all references before you start
grep -r "new-checkout-flow" src/9. Test flag-gated code
Test both branches. Use the stub client, not the real SDK.
import { stubFlags } from '../lib/flags';
describe('handleCheckout', () => {
it('uses new flow when flag is on', async () => {
const handler = buildHandler(stubFlags({ 'new-checkout-flow': true }));
const res = await handler(mockRequest());
expect(res.body.flow).toBe('new');
});
it('falls back to legacy when flag is off', async () => {
const handler = buildHandler(stubFlags({ 'new-checkout-flow': false }));
const res = await handler(mockRequest());
expect(res.body.flow).toBe('legacy');
});
});Rules
- Always provide a safe default (usually
false/ the old behaviour). The flag should fail closed, not open. - Never read flags in migrations, seed scripts, or schema definitions.
- Never hard-code a user ID as the only way to enable a flag in production — use targeting rules in the dashboard.
- One flag = one decision. Don't reuse a flag for a second, unrelated feature.
- If the flag SDK is unavailable at startup, default to
falseand log a warning — don't crash. - Treat the flag key string as an API: once it's in production, don't rename it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

