Skip to content
Back to skills

Feature Flags

ASecurity

Feature flags: a flag for every new feature or domain and for risky changes, a safe default declared in code, a system that stays healthy with the flag off, server-side checks at every entry point, the flag system chosen by the project's profile (configuration, the application's database, or a remote flag service) and managed per project, recommending one where it's missing, local evaluation that survives an outage of the flag service, gradual rollouts and kill switches, tests in both states,...

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
developmentgonextjstestinggitapidatabasesecurity

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add the-up/ai --skill feature-flags --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Feature Flags?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Feature Flags
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/the-up-feature-flags/badge)](https://www.skillsdirectory.com/skills/the-up-feature-flags)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: feature-flags
description: "Feature flags: a flag for every new feature or domain and for risky changes, a safe default declared in code, a system that stays healthy with the flag off, server-side checks at every entry point, the flag system chosen by the project's profile (configuration, the application's database, or a remote flag service) and managed per project, recommending one where it's missing, local evaluation that survives an outage of the flag service, gradual rollouts and kill switches, tests in both states, and removing flags after release. Load when building a new feature or domain, changing a flagged one, rolling out a risky change, or choosing a flag system."
---

# Feature Flags

## Which changes get a flag

- Put every new feature and every new domain behind its own feature flag, so that each one can be turned on and off on its own. Give a risky change to existing behavior a flag too, such as a new query path, a cache, or a third-party integration. A bug fix, a refactor that keeps the behavior, a text change, or a dependency update doesn't need one: every flag is code to maintain and test until it's removed.
- Gate all of a new domain's entry points with one flag, and give a part of it its own flag only when that part rolls out on its own schedule.
- In a library or a CLI, ship a new feature as an option that callers turn on, instead of a runtime flag.
- Give each flag a type, which decides how long it lives and who switches it:
  - **Release:** ships unfinished or untested work turned off, and goes away within weeks after the feature reaches everyone.
  - **Experiment:** splits people into variants until the result is clear.
  - **Operational:** guards a risky technical change for a few days.
  - **Kill switch:** turns off a costly or fragile part when it misbehaves, and stays.
  - **Permission:** opens a feature to a plan, a tenant, or a group of people, and stays.

## How each project manages its flags

- Choose the flag system by the [Project Profile](../project-profile/SKILL.md), record it in the profile, and use one system for all of the project's flags. The systems differ in where the flag values live:
  - **Configuration:** a value for each stage in the project's configuration files or environment. It suits a content site or a small project with only release flags, but changing a value takes a deploy or a restart, so it can't serve as a kill switch.
  - **The application's database,** through the framework's flag library, such as Laravel Pennant: for a monolith that switches flags at runtime, targets users, teams, or tenants, and lets staff switch flags from an admin screen, without another service to run. Pennant's database driver stores the first result for each user or other scope, so purge a flag after you change its definition.
  - **A remote flag service,** open source and self-hosted, such as Unleash, Flagsmith, or GrowthBook, or hosted, such as LaunchDarkly or ConfigCat: for flags that several services or apps share, mobile apps that can't wait for a store release, percentage rollouts and experiments, and flags that people outside the development team switch. Where personal data or data residency matters, self-host it or choose a provider in the required region.
- Whichever system holds the values, declare each flag once in code with its default value, and reach the system through one interface, such as the framework's flag library, the Flags SDK in Next.js, or the OpenFeature SDK, so that the code that checks flags doesn't change when the provider does.
- Keep the project's flags in its own catalog: its project in the flag service, with an environment for each stage, or the module that declares the flags. For each flag, record its key, description, type, owner, the task that added it, and, unless it's a kill switch or a permission flag, the date to remove it; keep these as data in the catalog or in the task, not as code comments. Make each flag's current state in each stage visible to the team.
- Name each flag in kebab-case after its domain and feature, such as `billing-autopay`. A key is unique in the project and is never reused for something else, even after its flag is removed, because an old deployment or a stored value can still read it.
- When a project has no flag system, don't build one inside a feature task, as the [Core Rules](../core-rules/SKILL.md) say. Recommend the system that fits the profile and ask in one multiple-choice question: add the flag system first as separate work (recommended), put this feature behind a value in the project's existing configuration for now, or build it without a flag. The separate work sets up the system, the catalog, the test helpers, and the CI run with every flag on. Recommend it as well when you notice a project without a flag system during other work.

## Building a flagged feature

- Make the default the safe value: off for a new feature, and the old behavior for a change, so that off always means the existing behavior. The system falls back to the default whenever the flag system can't answer.
- Keep the system fully working with the flag off: no errors, no empty sections, no links or menu items that lead to the feature, none of its jobs, schedules, listeners, webhooks, emails, or notifications running, and no other feature that breaks without it. Data the feature already wrote stays valid and readable after the flag goes back off.
- Check the flag on the server at every entry point of the feature: routes and API endpoints, jobs and schedules, event listeners, webhooks, console commands, and notifications. Hiding a button isn't enough: a disabled feature's routes and endpoints respond as if they didn't exist, for example with 404. A flag isn't authorization, so check permissions as well, as the [Security](../security/SKILL.md) rules require.
- Check a flag in as few places as possible, at the edge of the feature, and pass the decision inward instead of checking the flag deep in the business logic. For a long-lived flag, choose the implementation in one place, for example by binding a strategy in the dependency injection container, instead of repeating `if` statements.
- Evaluate a flag once at the start of a request, a job, or a multi-step flow, and carry the decision through it, so that a flag switched midway doesn't leave half-done work.
- Don't put the database schema behind a flag: run migrations whatever the flag's state, and keep the schema working for both states (expand, migrate, then contract), as the [Architecture and Code](../architecture-and-code/SKILL.md) rules require.
- Merge unfinished work in small PRs behind its flag while it's off, instead of keeping a long-lived branch.

## Evaluation

- Evaluate flags locally, from a copy that the flag system keeps current in the background, not with a network call for each check. When the flag system is down or slow, or sends a value that isn't valid, use the last known value or the default and log the problem once: a flag check never fails a request.
- Validate flag configuration when it's loaded, the way you validate external input.
- Load the flags that a request or a job needs once, not with one query per item inside a loop.
- Evaluate flags on the server. Send the flag system only the attributes that targeting needs, preferably IDs, and send browsers and mobile apps only the evaluated values they need, never the rules or a server key. Render a flagged variant on the server, so that the page doesn't shift when the flags arrive.
- Bucket a percentage rollout by a stable ID, such as the user, the account, or the tenant, so that a person stays in the same group on every request and device.
- A mobile app keeps the last values it received and ships with the defaults, so that it starts offline. Keep a flag in the flag service until no supported app version reads it, or make its default its final state.

## Rollouts and kill switches

- Roll a flag out in steps that can be undone: the team, then staff or internal accounts, then a small share of users, then everyone. Watch the error rate and the metrics the feature affects at each step, and turn the flag off at the first regression, before you fix it.
- Treat a change to a flag in production as a production change: record who changed what and when, require approval for critical flags where the flag system supports it, let the change reach production in steps rather than everywhere at once, and keep the previous state one step away.
- Give a feature that depends on an external service, or that is costly under load, a kill switch that degrades it to a fallback without a deploy. Flip the switch in tests and on staging: a kill switch that has never been flipped is untested code.

## Testing and removal

- Test a flagged feature in both states: with the flag on, the new behavior; with the flag off, the old behavior, the rejected entry points, and the jobs that don't run. In CI, run the tests with every flag at its default and again with every flag on, rather than in every combination. Set flags in tests through the flag library's test helpers, never through the real flag service.
- When you add a temporary flag, open the task that removes it. Make overdue flags visible, with a test that fails after a flag's removal date or with the flag service's report of stale flags.
- Remove a flag in one PR: its checks, the code path that lost, its tests, and its catalog entry. Delete it from the flag service only when no running version reads it.

Sources:

- [Feature Toggles (aka Feature Flags)](https://martinfowler.com/articles/feature-toggles.html), Pete Hodgson on martinfowler.com, 2017-10-09.
- [11 principles for building and scaling feature flag systems](https://docs.getunleash.io/guides/feature-flag-best-practices) and [feature flag types](https://docs.getunleash.io/reference/feature-toggles), Unleash.
- [Flag evaluation](https://openfeature.dev/specification/sections/flag-evaluation), the OpenFeature specification.
- [Architecture](https://launchdarkly.com/docs/home/getting-started/architecture), LaunchDarkly.
- [Laravel Pennant](https://laravel.com/docs/13.x/pennant), Laravel.
- [Flags as code](https://flags-sdk.dev/principles/flags-as-code), Flags SDK.
- [Reliable Product Launches at Scale](https://sre.google/sre-book/reliable-product-launches/), Site Reliability Engineering, Google.
- [Holistic Configuration Management at Facebook](https://sigops.org/s/conferences/sosp/2015/current/2015-Monterey/printable/008-tang.pdf), SOSP 2015.
- [How we ship code faster and safer with feature flags](https://github.blog/engineering/infrastructure/ship-code-faster-safer-feature-flags/), GitHub, 2021-04-27.
- [Piranha: Reducing Feature Flag Debt at Uber](https://2020.icse-conferences.org/details/icse-2020-Software-Engineering-in-Practice/16/Piranha-Reducing-Feature-Flag-Debt-at-Uber), ICSE SEIP 2020.
- [Simplest possible feature toggle](https://www.thoughtworks.com/radar/techniques/simplest-possible-feature-toggle), Thoughtworks Technology Radar, 2020-05.
- [Google Cloud incident report](https://status.cloud.google.com/incidents/ow5i3PPK96RduMcb1SsW), 2025-06-12.
- [Cloudflare outage on November 18, 2025](https://blog.cloudflare.com/18-november-2025-outage/) and [on December 5, 2025](https://blog.cloudflare.com/5-december-2025-outage/), Cloudflare.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.