The Boolean Feature Flag in Flagsmith

The Boolean Feature Flag in Flagsmith

The simplest switch in software, and the one that does the most work. Learn how a true or false flag is created, read, targeted, tested and retired, and how to use it so that releases become calm instead of frightening.

It is five minutes before a big launch. The new checkout page is built, tested and deployed to the servers, yet no customer can see it. A single switch decides whether the page appears. The product manager clicks it once, and within moments thousands of shoppers see the new page. Ten minutes later the error graph starts to climb. She clicks the same switch again, the page disappears, the graph falls, and nobody has been paged out of bed.

That switch is a boolean feature flag. The word boolean comes from a mathematician named George Boole and simply means “something that can only be true or false”. It is the oldest and plainest kind of flag, and in most companies it carries the majority of the load. This guide explains it slowly from the first definition, shows how Flagsmith stores and delivers it, and then teaches the patterns, mistakes and habits that experienced architects use to keep thousands of such switches under control.

No prior knowledge is needed. Every new word is explained the first time it appears, and every big idea is paired with a picture from everyday life.

1What Is a Boolean Feature Flag?

Three short definitions come first: the feature flag, the boolean, and the platform that holds them.

The feature flag

A feature flag (also called a feature toggle or feature switch) is a control placed inside software that decides whether a certain behaviour is active. The code is already deployed on the servers. The flag decides whether users can reach it. Change the flag and the behaviour changes, with no new release.

The boolean

A boolean is a value with exactly two possible states: true or false, on or off, yes or no. A boolean feature flag is therefore a flag with exactly two answers. When the application asks “should I show this feature?”, the reply is either yes or no. There is no “maybe” and no “ten out of twenty”. That narrowness is its strength, because a two state switch is easy to understand, easy to test and easy to reverse.

The platform

Flagsmith is a feature flag and remote configuration service. It provides a dashboard where people manage flags, and small libraries called SDKs that applications install so they can ask, “what is this flag right now?” It is open source, can be hosted by a company itself, and is also offered as a hosted service.

Everyday analogy

A boolean flag is a light switch on a wall. It has two positions. The wiring behind the wall may be complicated, but the person using the switch needs to know only one thing: light on, or light off. You can flip it as often as you like, and flipping it back always restores the earlier state.

2
possible answers: on or off
0
new releases needed to flip it
1
click to reverse a bad change
i
Remember this

In Flagsmith, the plain flag is called a standard feature, and its core is an enabled or disabled state. When people say “boolean flag” in Flagsmith, they mean this on and off state. The exact wording in the dashboard may change over time, but the idea stays the same.

2Why Two Answers Are Enough for Most Work

Many people assume serious engineering needs complex controls. In practice, a plain true or false solves most real problems.

The problem it solves

Before flags, releasing a feature meant deploying new code, and deploying meant risk. If something broke, the only remedy was another deployment to undo the first, which could take an hour while customers suffered. Boolean flags separate two things that used to be glued together: deployment, which is putting code on servers, and release, which is letting users see it. Deployment can happen quietly on a Tuesday. Release happens when the business is ready, at the click of a switch.

Release

Hide until ready

Unfinished work ships inside the code but stays invisible until the team flips the switch.

Safety

Kill switch

If a feature misbehaves, turn it off in seconds without touching the code.

Access

Entitlements

Give a capability to paying or chosen customers only, by switching it on for them.

Operations

Load protection

Turn off a heavy feature during a traffic peak to keep the rest of the product fast.

Everyday analogy

A theatre can build the entire stage set in the afternoon behind a closed curtain. The set is fully “deployed”. The curtain rises at eight o’clock, and that is the “release”. If a prop falls over, the curtain can be lowered at once. The curtain is the boolean flag, and the big idea is that building and showing are two separate acts.

What large companies teach us

Engineering organisations known for frequent releases, such as Amazon, Netflix, Etsy and Facebook, have described in public talks and articles the idea of hiding unfinished work behind switches so that code can be merged and shipped many times a day. Etsy’s writing about “config flags” is a well known example. The reasoning is the same at any size. A plain on and off switch is quick to build, quick to understand and quick to reverse, which is exactly what you want when something might go wrong.

The strongest safety feature in software is a way to say “no” quickly.

What a boolean flag cannot do

It helps to know the limits. A boolean flag cannot tell you how much of something to show, only whether to show it. It cannot choose between three versions of a page. It cannot carry a message or a number. When you need those, Flagsmith offers values and multivariate features. The sensible habit is to begin with the simplest tool that solves the problem, and to reach for a richer one only when the plain switch genuinely is not enough.

3The Anatomy of a Boolean Flag in Flagsmith

Open any flag in Flagsmith and you will find the same handful of parts. Knowing them makes the dashboard feel familiar.

Identity

Name

The text your code uses to find the flag. Treat it like a public label, because renaming it can break applications.

Meaning

Description

A plain sentence explaining what the flag controls and when it should be removed.

State

Enabled or disabled

The boolean itself. It is stored separately for each Environment, so each stage has its own answer.

Labels

Tags

Coloured labels, such as “release” or “payments”, that help people sort and search.

Targeting

Overrides

Special answers for chosen segments of users, or for single users, in one Environment.

History

Audit trail

A record of who flipped the flag, when, and what the earlier value was.

The two layers: definition and state

A flag has two layers that beginners often confuse. The definition is the existence of the flag: its name, description and tags. It lives at the Project level and is shared by every Environment. The state is whether it is enabled in a particular Environment. It lives inside that Environment. So the flag “checkout_new_payment_sheet” exists once in the Project, yet it can be enabled in Development, enabled for testers in Staging, and disabled in Production, all at the same moment.

QuestionDefinitionState
Lives inThe ProjectAn Environment
AnswersDoes this flag exist?Is it on here?
CopiesOne per ProjectOne per Environment
Risk if changedCode that uses the name may breakUsers see something different right now
Everyday analogy

A hotel chain keeps one list of room types. Every branch records which rooms are occupied tonight. Adding a new room type changes the list for every branch. Occupying one room changes only one branch for one night. The list is the definition, and the nightly record is the state.

What you see at a glance

In the dashboard’s feature list, each row typically shows the flag name, its tags, a switch for the current Environment and a short summary of any overrides. A quick scan tells you which flags are on, which are off, and which have special rules for certain groups. Learn to read that list the way a pilot reads a cockpit panel: the important facts are visible without opening anything. If you ever have to open five screens to understand one flag, the flag has probably been set up in a confusing way.

4Boolean Flags Compared with Other Kinds of Flag

Flagsmith offers more than on and off. Seeing the neighbours helps you decide when plain boolean is the right choice.

The three kinds of feature

The boolean flag answers a yes or no question. Remote configuration hands the application a value, such as a number, a piece of text or a limit, that can be changed live without a release. A multivariate feature offers several values and splits users between them by percentage, which is the base of experiments.

KindThe question it answersExampleBest when
Boolean flagShould this happen, yes or no?Show the new payment sheetYou are releasing, hiding or protecting a behaviour
Remote configurationWhat value should be used?Search shows twelve resultsYou tune a number or message live
MultivariateWhich of several versions?Button says Buy now, Get it today or Add to basketYou compare versions with real users

A confusing detail: enabled state versus value

In Flagsmith, a single feature can carry both an enabled state and a value. The enabled state is the on and off switch. The value is an optional extra piece of information. A value may itself be the text “true” or “false”, or a true or false type, and that is not the same as the enabled state. Mixing these up causes real bugs. A flag may be enabled with a value of false, which the code must read as “feature on, setting off”. As a rule, keep a boolean flag pure: use the enabled state for the yes or no question and leave the value empty. If you need a setting as well, use a separate remote configuration feature with its own name.

!
Common trap

Do not use a value of “true” or “false” on a feature when the enabled state would do. Two ways of saying yes in one feature lead to arguments such as “it is enabled but the value says false, so is it on?” Pick one source of truth and write it in the description.

Everyday analogy

A television has a power button, which is the boolean, and a volume dial, which is the value. Turning the volume to zero does not turn the television off, and turning it off does not change the dial. Treat the two controls as separate, and nobody will be confused about why the screen is dark.

5Where the Boolean Flag Sits in the Flagsmith Tree

Flagsmith is organised as a tree. Locating the flag in that tree explains who can change it and where its answer is stored.

At the top is the Organisation, which holds people, groups and billing. Beneath it are Projects, one for each product. Inside each Project the features are defined, and beneath each Project are Environments such as Development and Production. The enabled or disabled state of each flag is stored in each Environment.

graph TD
  ORG["Organisation: Acme Corp"] --> PRJ["Project: Store"]
  PRJ --> FEAT["Feature definition: checkout_new_payment_sheet"]
  PRJ --> DEV["Environment: Development"]
  PRJ --> STG["Environment: Staging"]
  PRJ --> PRD["Environment: Production"]
  DEV --> S1["State: Enabled"]
  STG --> S2["State: Enabled for testers"]
  PRD --> S3["State: Disabled"]
  FEAT -.-> S1
  FEAT -.-> S2
  FEAT -.-> S3
    
Fig 1. One flag definition in the Project, with a separate state in each Environment.

What this means in practice

Because the state belongs to the Environment, you can safely turn a flag on in Development without affecting customers. Because the definition belongs to the Project, your code can ask for the flag by name in any stage and always get an answer. And because the Organisation sits above, it decides which people are allowed to flip the flag in each place.

✓
Good habit

Use identical Environment names in every Project: Development, Staging and Production. A person who learns the pattern once can work in any Project without asking.

6Creating a Boolean Flag Step by Step

Creating a flag takes a minute. Creating a flag well takes a minute and a half, and the extra thirty seconds saves hours later.

1

Open the right Project

Choose the Project of the product that will use the flag. A flag belongs to exactly one Project.

2

Choose a clear name

Use your agreed style, such as lower case words with underscores, starting with the product area. The name should say what the flag does when it is on.

3

Write a short description

Say what it controls, who owns it and when it should be removed. This sentence will be read by strangers.

4

Attach tags

Mark the kind (release, operational, permission or experiment) and the owning team.

5

Decide the starting state

The safe choice is disabled everywhere, so creating a flag never changes what customers see. Check your Project settings for how new flags start.

6

Enable it in Development first

Flip it on where mistakes are free, and confirm the application reacts.

Weak nameWhy it is weakBetter name
flag1Says nothing about purposecheckout_new_payment_sheet
NewStuffInconsistent style and vaguesearch_show_rich_previews
disable_old_bannerA “disable” flag that is enabled means off, which confuses everyonehome_show_legacy_banner
johns_testTied to a person, not a purposeprofile_enable_dark_mode
Everyday analogy

Labelling a fuse box takes a few minutes when the electrician is installing it, and saves frantic guessing in the dark months later. A clear name and a short description are the labels on your fuse box.

✓
Plan the ending

When you create a release flag, create the ticket to remove it at the same time and link the two. Removal that is not planned on day one tends to lose every later competition for attention.

Questions people ask at creation time

Should the flag start on or off? Off, almost always. A new flag that starts on can change what customers see the moment it is created, which defeats its purpose. Should I create it in code first or in Flagsmith first? Create it in Flagsmith first, disabled, then write the code. That way the code can be deployed safely at any time, because asking for a flag that exists and is off simply returns the old behaviour. Should several features share one flag? Rarely. One flag per behaviour keeps testing and reversal simple. If two features must move together, give them one flag on purpose and say so in the description.

7Reading a Boolean Flag from Your Application

A flag in a dashboard does nothing until an application asks about it. This chapter explains that conversation in plain language.

The SDK

An SDK (software development kit) is a ready made library that your application installs so it can talk to Flagsmith without you writing the network code. Flagsmith provides SDKs for many languages, for websites, for mobile apps and for servers. Each SDK offers a very simple question for boolean flags, which can be read aloud as “is this feature enabled?” The answer is true or false.

The Environment key

To know which Environment to ask, the SDK holds an Environment key, a string that identifies the stage. Development builds use the Development key, and the live product uses the Production key. This is why a test build can never accidentally read live values.

The shape of the check

In the application, the idea is always the same. The code asks whether the flag is enabled. If yes, it runs the new behaviour. If no, it runs the old behaviour. Both paths exist in the code at the same time, which is what lets the flag be flipped instantly in either direction.

flowchart TD
  A["User opens the checkout page"] --> B["App asks SDK: is checkout_new_payment_sheet enabled?"]
  B --> C{"Answer"}
  C -- "True" --> D["Show the new payment sheet"]
  C -- "False" --> E["Show the old payment sheet"]
  C -- "No answer" --> F["Use the coded safe default"]
  F --> E
    
Fig 2. Every flag check has two code paths, plus a safe default for when no answer arrives.

The safe default

A safe default is the answer your code uses when it cannot get one from Flagsmith, for example because of a network problem or because the flag was deleted. For almost every release flag, the safe default is “off”, meaning the old, proven behaviour. For an operational protection flag, the safe default might be “on”, because losing the protection would be worse. Decide the default flag by flag, and write it down.

Everyday analogy

A shop with an electronic door lock should decide in advance what happens in a power cut. Some doors stay locked to protect the stock. A fire exit swings open to protect people. The default is a decision about which failure is less harmful, and it must be made before the power goes out.

!
Design note

Never write code that assumes Flagsmith will always answer. A flag platform is a network service like any other, and your application should behave sensibly if it is slow or unreachable.

Environment-level and person-level questions

An application can ask about a flag in two ways. The first asks for the Environment’s flags, with no information about the person. The answer is the same for everybody and is based on the Environment defaults. The second asks for flags for an identity, sending a user ID and perhaps traits. The answer is tailored through segments and overrides. Choose the first for simple switches, such as a site-wide maintenance banner. Choose the second whenever the flag must be different for different people, such as a rollout to ten percent.

When to ask

A common design question is whether to ask for a flag when the application starts or at the moment it is needed. Asking at start gives a consistent experience, because the user sees one version for the entire session, and it keeps the number of network calls low. Asking at the moment of use gives fresher answers, but can cause a screen to change halfway through someone’s task. For most products, fetch at the start of a session and refresh gently on a timer.

8Different Answers in Different Environments

One flag, three stages, three independent switches. This separation is what makes a careful release possible.

The usual Environments are Development, where engineers experiment, Staging, where the product is tested as a whole, and Production, where real customers live. A boolean flag has a separate on or off state in each. Here is how one flag might move over a week.

DayDevelopmentStagingProductionWhat is happening
MondayOnOffOffEngineers build and try the feature
WednesdayOnOnOffTesters run the whole journey
FridayOnOnOn for staff onlyFirst real exposure, with colleagues
Next TuesdayOnOnOn for ten percentA small slice of customers
Next FridayOnOnOn for everyoneFull release
Everyday analogy

A restaurant tries a new dish first in the back kitchen, then serves it to staff, then offers it to a few regular guests, and finally puts it on the printed menu. The recipe is the same at every step, but the audience grows. Environments and targeting give a flag the same slow widening of the audience.

Keeping Environments honest

Environments only help if they resemble each other. A common trap is a Staging Environment whose flag states drifted away from Production, so a test passes in Staging and a real customer finds a bug. Review the two side by side before big releases, and consider cloning Staging from Production to begin from a known state, where your version offers that option.

✓
Rule of thumb

Open the flag in Staging and in Production, side by side, before every launch. If the difference is not exactly the one you intend, stop and find out why.

9Targeting a Boolean Flag: Segments and Individuals

A flag that is the same for everyone is useful. A flag that is on for some people and off for others is powerful.

Identities and traits

An identity is Flagsmith’s name for one end user or account that your application tells it about, usually a user ID. A trait is a fact attached to an identity, such as “plan equals premium” or “country equals India”. The application sends these so Flagsmith can tailor the answer to the person.

Segments

A segment is a named rule that selects identities by their traits or by a percentage. Examples are “staff”, “premium customers” and “ten percent of all users”. A segment is defined once in the Project and reused by any flag.

Overrides

An override changes the answer of a flag for a segment or a person in one Environment. A segment override says “for staff, this flag is on, even though the default is off”. An identity override says the same for one specific person. Together, they let one boolean flag give different answers to different people.

Who wins when several rules apply

Flagsmith always takes the most specific rule. It checks for an identity override first, then segment overrides in their ranked order, then falls back to the Environment default.

flowchart TD
  START["Request: is flag X enabled for identity Y?"] --> Q1{"Identity override for Y?"}
  Q1 -- Yes --> R1["Use the identity override"]
  Q1 -- No --> Q2{"Does Y match a segment override?"}
  Q2 -- Yes --> R2["Use the highest ranked matching segment"]
  Q2 -- No --> R3["Use the Environment default state"]
    
Fig 3. The most specific rule wins: identity, then segment, then Environment default.
ShopperIdentity overrideSegments matchedFinal answerReason
Asha, staffNoneStaffOnThe Staff segment says on
Ben, in the ten percentNoneTen percentOnThe percentage segment says on
Chloe, outside the ten percentNoneNoneOffThe Environment default applies
Dev, staff with a known problemOffStaffOffThe identity override beats every segment
Everyday analogy

A school has a general rule that phones stay in lockers. A teacher may allow phones for a project, which is more specific. A doctor’s note allowing one pupil a phone for health reasons is the most specific of all. The most specific rule wins, and the general rule applies only when nothing more specific does.

!
Common trap

A segment that depends on a trait such as “country” will never match if the application never sends that trait. When a person sees an unexpected answer, first check that the trait really arrived and is written in the exact format the segment expects.

Designing segments that last

Good segments describe who people are, not which feature they should get. A segment called “Beta programme members” can be reused by many flags for years. A segment called “New checkout testers” will be used once and then abandoned. Keep the list of segments short, give each a one line description, and remove those no flag uses any more.

Segment order matters when a person matches several. The segment ranked highest wins, so put the most specific or most important rules first. A typical order is: individual exceptions first, then staff, then named pilot groups, then percentage rollouts last. If you place a broad percentage rule above a narrow staff rule, staff members may be treated like everyone else and surprise you.

10Percentage Rollouts with a Two State Flag

A boolean flag has only two answers, yet it can still be released gradually. The trick is that different people get different answers.

How a percentage rollout works

Create a segment that selects a percentage of all identities, for example ten percent, and give it a segment override that turns the flag on. Ten percent of people see the new behaviour. Ninety percent see the old. The next day, raise it to twenty-five percent, then fifty, then a hundred. At each step the team watches errors and complaints.

Why the same person stays in the same group

The split is steady for each identity. Flagsmith works out a position for the person from their identity, so the same person always lands in the same bucket. Someone in the first ten percent stays included as the percentage grows. Nobody flickers between the old and new experience when the app restarts. That steadiness makes slow rollouts calm for users and clean for analysis.

1%

Canary

A tiny audience, just enough to prove the feature does not crash. Named after the canary in the coal mine.

10%

Early slice

Enough users to notice patterns in errors and speed, with limited harm if something is wrong.

50%

Half and half

The system now carries serious load from the new path. Watch capacity as well as errors.

100%

Full release

Everyone sees the new behaviour. The flag now has one remaining job: wait to be removed.

Scenario: a streaming home screen

A subscription video service redesigns its home screen. It enables the boolean flag first for staff, then for a beta group, then for one percent, ten percent, twenty-five percent and finally everyone, while watching playback errors. Large streaming companies are widely known for this slow, measured style of exposure, and a plain boolean flag with percentage segments is enough to do it.

i
Measure before widening

Decide in advance what “healthy” means, such as error rate below a certain level and no rise in slow responses. Widening the rollout should be a calm decision based on numbers, not a hopeful click.

Choosing steps and signals

A rollout is only as safe as the signals you watch. Before starting, agree which measures matter, how long to wait at each step, and what number means “stop”.

StepSuggested waitSignals to watchStop if
Staff onlyOne to three daysColleague reports, error logsAny crash or data problem
One percentA few hours to a dayError rate, response timeErrors clearly higher than the old path
Ten percentOne to two daysErrors, speed, support ticketsAny rise in tickets about this feature
Fifty percentOne to two daysCapacity, database load, costLoad approaching limits
EveryoneOne to two weeksAll of the above, plus business numbersAny sustained decline in key results

The waits above are only examples. A tiny internal tool may move in an afternoon, and a payment system may wait a week at each step. What matters is that the plan is written before the first click, so the decision to widen is made against a standard rather than against excitement.

11Pattern One: The Kill Switch

The most valuable boolean flag is often one you hope never to use.

What is a kill switch?

A kill switch is a flag that exists to turn something off quickly when it causes harm. It wraps a risky or expensive behaviour, such as a heavy recommendation engine, a third-party integration or a new payment route. Normally the flag is on and nobody thinks about it. In an emergency, an engineer switches it off, the risky behaviour stops, and the rest of the product carries on.

flowchart LR
  A["Normal day: flag is on"] --> B["Feature runs, users happy"]
  B --> C{"Incident detected?"}
  C -- No --> B
  C -- Yes --> D["Engineer flips flag off"]
  D --> E["Risky path stops within seconds"]
  E --> F["Product continues without the feature"]
  F --> G["Fix the cause, then flip it on again"]
    
Fig 4. A kill switch turns an outage into a short, controlled loss of one feature.
Everyday analogy

Every house has a main water stopcock under the sink. You almost never touch it, but when a pipe bursts, knowing where it is turns a flood into a small puddle. A kill switch flag is that stopcock for a feature.

Making a good kill switch

  • Guard the whole risky path. The flag check should sit at the start of the behaviour, so turning it off truly stops the work.
  • Make the off state boring. The product must work properly with the flag off. Test that path regularly, because it is the one you will use at the worst moment.
  • Choose the default carefully. If Flagsmith cannot be reached, decide whether the safe behaviour is on or off, and code it.
  • Keep it long lived. Unlike a release flag, a kill switch is meant to stay. Tag it “operational” so nobody deletes it as clutter.
  • Practise. Flip it in Staging every quarter, so the team remembers where it is and what happens.

Scenario: protecting a sale day

An online retailer of the kind Amazon popularised expects a huge traffic peak. Its product page includes a “people also bought” panel that makes many database calls. The panel sits behind a kill switch. When the database slows, an engineer disables the panel in seconds, pages load fast again, and customers still buy. Afterwards the team investigates calmly and switches the panel back on.

Rehearse the kill switch

A kill switch you have never used is a kill switch you cannot trust. Hold a short drill each quarter in Staging.

1

Announce the drill

Tell the team in the channel, so nobody mistakes the practice for a real incident.

2

Flip the switch off

Use the real flag in the Staging Environment, as the on call engineer would in an emergency.

3

Time the effect

Measure how long until the application stops using the risky path. Compare it with what the runbook says.

4

Check the off state

Confirm the product works properly without the feature and nothing else broke.

5

Restore and record

Switch it back on, note the timing and fix any surprise in the runbook.

12Pattern Two: The Release Flag and the Dark Launch

The most common use of a boolean flag is to hide work in progress. Done well, it lets teams merge code daily without fear.

The release flag

A release flag hides a feature that is not ready. Developers can merge unfinished code into the main code line every day, because the flag keeps it invisible. This avoids long lived side branches that drift away from the main code and cause painful merges. The flag is temporary. Once the feature is released and stable, the flag and the old code path are both removed.

The dark launch

A dark launch goes one step further. The new code runs in Production, but its results are not shown to users. A new recommendation engine might calculate suggestions silently while the old one still serves the page, so the team can compare the two and measure speed and load under real traffic before anybody sees the new output. Boolean flags control which parts run, and which results are displayed.

StageNew code deployed?Does it run?Do users see it?Flag state
HiddenYesNoNoOff
Dark launchYesYes, silentlyNoDark flag on, display flag off
CanaryYesYesA tiny groupOn for a small segment
ReleasedYesYesEveryoneOn for all
Cleaned upOld path removedYesEveryoneFlag deleted
Everyday analogy

A baker tests a new recipe by baking a small batch each morning, tasting it in the back, and comparing it with the usual bread, long before it reaches the shop window. The window is the flag. The tasting is the dark launch. Only when the bread is right does it go on display.

!
Watch the cost

A dark launch makes your system do extra work with no visible benefit. Start with a small percentage and watch load, so the experiment does not itself cause a slowdown.

Why flags help teams merge daily

Many modern teams practise trunk-based development, which means everyone merges small changes into one shared main line of code every day, instead of working for weeks on private branches. The practice is popular because long lived branches drift away from the main code, and merging them later is slow and risky. The difficulty is that a half finished feature must not be visible to customers while it sits in the main line. A boolean release flag solves exactly that problem. The unfinished code is merged and deployed, but it stays behind a flag that is off. Companies such as Google and Facebook have spoken publicly about working with one main line of code for thousands of engineers, and hidden-by-default switches are a natural part of that style.

The bargain is simple: you gain small, frequent, low risk merges, and you pay by remembering to remove each flag once its feature is finished.

13Pattern Three: The Permission Flag

Boolean flags can also decide who gets a capability. This is powerful, and it comes with one important warning.

What is a permission flag?

A permission flag (also called an entitlement flag) switches a capability on for chosen customers or staff. A premium reporting tool might be enabled only for the “premium customers” segment. An internal admin screen might be enabled only for the “staff” segment. The flag is off for everyone by default, and segment overrides turn it on for the right groups.

Business

Plan based features

Advanced exports for paying customers only, controlled by a plan trait on each identity.

Pilot

Early access

A new tool for a loyal group of customers who agreed to try it first.

Internal

Staff tools

Debug panels and admin screens visible only to employees.

Contract

Customer specific

A capability promised to one named customer, switched on through an identity override.

!
Important warning

A flag decides what the interface shows. It is not a security lock. Anything that really must be protected, such as viewing someone’s bank balance, has to be enforced again on your own servers by proper permission checks. A flag that hides a button does not stop a determined person from calling the underlying service directly.

Everyday analogy

A “staff only” sign on a door tells honest visitors where not to go. It does not stop a thief. For that you need a real lock and a key. A permission flag is the sign, and your server side checks are the lock.

How long should one live?

Unlike release flags, permission flags may be permanent, because they reflect a business rule: premium customers get this. Because they are permanent, they need clear owners, careful names and regular review, otherwise they become the hardest kind of flag to understand years later.

Designing entitlements well

When a permission flag follows a customer’s plan, let the plan itself drive the answer. The application sends a trait such as “plan equals premium”, a segment called “Premium customers” selects those identities, and the flag’s segment override turns the capability on. Now upgrading a customer is a data change in your own system, not a manual edit in Flagsmith. For one-off promises to a single customer, an identity override is acceptable, but record the reason in your own system, because a stray override with no explanation is easy to forget and hard to explain later.

14Pattern Four: The Operational Flag

Some flags exist to help engineers run the system, not to deliver features to customers.

What an operational flag does

An operational flag changes how the system behaves under stress. It might switch to a lighter version of a page during a traffic peak, reduce how often a background job runs, or send traffic to a backup service. It is close kin to the kill switch, but where the kill switch stops something entirely, the operational flag tunes the system.

PatternTypical lifetimeWho flips itDefault when Flagsmith is unreachable
Release flagDays to weeksProduct and engineeringOff, the old proven behaviour
Kill switchYearsOn call engineersUsually on, so the feature keeps running as designed
Permission flagYearsProduct ownersOff, so nobody gets a capability by accident
Operational flagMonths to yearsPlatform and on call engineersThe safest load behaviour, decided case by case
Experiment flagWeeksProduct and data teamsThe control version
Everyday analogy

A city has traffic lights that can be switched to a simpler pattern during a big event, with some junctions closed and others reversed. The roads themselves do not change, but the behaviour does. Operational flags are those controls for software.

Scenario: tuning for a big match

A sports streaming service expects millions of viewers at once for a final. A boolean flag turns off a costly “similar videos” panel and another reduces how often the app refreshes the score. Both are switched on before kick off. The team keeps the savings for the evening and restores everything the next morning. No code changes, no release, and engineers are calm.

A ladder of graceful degradation

Large systems rarely have only one emergency button. They have a ladder of smaller steps, each giving up a little to protect the whole. A retailer might prepare four boolean flags for a peak day. The first hides the personalised recommendations. The second reduces the number of search results. The third turns off the review summaries. The fourth shows a plain page without images. Each step is smaller and kinder than switching off the whole site, and the team climbs the ladder only as far as needed, then climbs back down as pressure eases.

15Naming Boolean Flags: Avoiding the Double Negative

Good names are the cheapest bug prevention available, and bad names are a famous source of mistakes.

The problem with “disable” flags

Suppose a flag is named “disable_new_checkout”. When the flag is enabled, the new checkout is disabled. To turn the checkout back on, someone must disable the flag. Read that twice and you will see how easily a tired engineer at midnight flips the wrong way. This is called a double negative, and it has caused real incidents.

NameFlag is enabled meansFlag is disabled meansClear?
checkout_new_payment_sheetNew payment sheet is shownOld payment sheet is shownYes
disable_new_checkoutNew checkout is hiddenNew checkout is shownNo, a double negative
search_show_rich_previewsRich previews appearPlain results appearYes
no_legacy_bannerBanner is hiddenBanner is shownNo, a double negative

Simple rules for names

  • Name the behaviour when on. The name should describe what happens when the flag is enabled.
  • Never start with “disable” or “no”. Flip the sense and rename. “Enable” or “show” words keep flipping honest.
  • Start with the area. Prefixes such as checkout, search or profile make long lists easy to scan.
  • Use one style. Lower case words with underscores is common. Choose and stick to it.
  • Avoid people and dates. Names such as “johns_flag” or “march_launch” become meaningless fast.
Everyday analogy

A tap marked “do not turn off” invites exactly the confusion a double negative creates. A tap with a simple arrow showing “water on this way” is understood in a second, even in the dark. Positive names are the arrow.

✓
Let the tool help

Flagsmith can enforce a naming pattern for feature names at the Project level in many versions. Turning that on early catches mistakes at creation time, long before they reach code.

16Defaults and Failure Behaviour

The boolean answer you get depends not only on the rules, but also on what happens when something goes wrong. This chapter lists the cases.

SituationWhat the app receivesWhat the user seesHow to stay safe
Normal, flag exists and Flagsmith answersTrue or false from the rulesWhatever the flag saysNothing special needed
Flagsmith slow or unreachable at startNo answer, so the coded defaultThe default behaviourChoose a harmless default and test it
Flagsmith becomes unreachable laterThe last cached answer, if the SDK keeps oneLast known behaviourUse SDK caching, and accept slightly old values
Flag was deleted but code still asksNo such flag, so the coded defaultThe default behaviourRemove code before deleting the flag
Flag exists but the name has a typo in codeNo such flag, so the coded defaultThe default, silentlyShare names through constants and review changes
Trait missing for a segmentSegment does not match, so the Environment defaultThe general behaviourCheck that the app sends the traits

The silent failure

The dangerous rows in that table are the quiet ones. A typo in a flag name does not crash anything. It just returns the default, and the feature simply never switches on, leaving the team puzzled for hours. Teams avoid this by keeping flag names in one shared place in the code, and by checking in Staging that flipping the flag really changes the screen.

Everyday analogy

If you call a friend and the phone rings out, you act on your best guess of where they are. A thoughtful friend leaves a message about what you will do if you cannot reach them. The coded default is that message: your plan if no answer arrives.

!
Test the unhappy path

Once in a while, deliberately run your application with Flagsmith unreachable, in a test setting, and confirm the product still behaves sensibly. It is the best five minutes a team can spend on resilience.

Keep a register of defaults

Decisions about defaults are easy to forget, so write them down in one place. A small table in your team’s documents is enough, listing each flag, the default in code, the reason for that choice and the owner.

FlagKindDefault in codeReasonOwner
checkout_new_payment_sheetReleaseOffOld sheet is proven and safeStore team
search_show_rich_previewsOperationalOnNormal day behaviour, protection is used only in emergenciesSearch team
reports_enable_advanced_exportPermissionOffNobody should gain a premium feature by accidentReports team
payments_use_backup_providerOperationalOffSwitching providers must be a deliberate choicePayments team

17Client-Side, Server-Side and Local Evaluation

Where the flag check runs changes its speed, its cost and how fresh the answer is.

Client-side SDKs

A client-side SDK runs on the user’s own device, in a browser or a mobile app. It uses the public Environment key and asks Flagsmith for flags for the current user, then keeps a copy. The key is safe to be visible, because it can only read flag values for one Environment.

Server-side SDKs

A server-side SDK runs on your own backend. It uses a secret server-side key, which must never leave your servers. It may ask Flagsmith for each decision, or it may use local evaluation.

Local evaluation

Local evaluation means the server downloads the complete rule set for an Environment once, keeps it in memory and decides flags itself, without a network call per decision. It is extremely fast and greatly reduces requests. The trade-off is freshness: changes reach the server on a refresh schedule, so a flip may take a short while to show.

ModeWhere it runsKey typeSpeedFreshness
Client-sideBrowser or phonePublicOne call, then cachedUpdates at refresh or next start
Server-side, remoteYour backendSecretA call per lookup, or cachedFresh when asked
Server-side, local evaluationYour backendSecretMicroseconds, no callUpdates on a refresh timer

How fast does a flip take effect?

People are often surprised that a kill switch is not instant everywhere. A mobile app that cached flags at start may keep the old answer until it next refreshes or restarts. Some setups offer near real-time updates for client applications, while others rely on polling timers, so check what your SDK and plan support. Know your refresh interval, write it on the runbook, and design kill switches knowing that “seconds” may really mean “within a minute or two”.

Everyday analogy

A newspaper stand posts today’s headlines on the board each morning. Asking the editor for every single sale would be exhausting, so you read the board. The board is slightly out of date by evening, but fast and cheap. The refresh timer is how often someone updates the board.

Mobile apps and the stale answer

Mobile apps face a special challenge. A phone may be offline, or may keep an app open in the background for days. A flag value fetched on Monday may still be in use on Thursday. Plan for this in three ways. Refresh flags whenever the app returns to the foreground. Treat flags that affect safety, such as a kill switch, as needing a short refresh interval. And remember that older versions of your app remain in the world for months, so a flag must keep working for them until the last old version is gone.

18How It Works Internally: Control Plane and Data Plane

Architects divide a system into the place where humans decide and the place where applications ask. Flagsmith follows that pattern.

The control plane is where people manage configuration: creating flags, editing segments, flipping states. The data plane is where high volume requests are served: millions of applications asking “is this flag on for this person?”. Your decision to flip a boolean happens in the control plane, and its effect is carried by the data plane.

flowchart LR
  subgraph CP["Control plane"]
    ADM["Dashboard used by your team"] --> API["Management API"]
    API --> DB[("Primary database")]
  end
  subgraph DPL["Data plane"]
    LB["Load balancer"] --> FE["Flag evaluation service"]
    FE --> CACHE[("Cache")]
  end
  DB --> FE
  APP["Your web or mobile app with SDK"] --> LB
  SRV["Your backend with SDK"] --> LB
    
Fig 5. A flip made in the dashboard is stored, then served to applications through the data plane.

What happens when you click the toggle

1

You flip the flag

The dashboard sends the change to the management API, which checks that you have permission for that Environment.

2

The change is stored

The new state is saved in the database and written to the audit log with your name and the old value.

3

The data plane picks it up

The evaluation service and its caches learn the new state, and any integrations or webhooks are notified.

4

Applications see it

Each SDK receives the new answer the next time it asks or refreshes, according to its mode.

Everyday analogy

A television network has an office where the schedule is decided and transmitters that send the picture to millions of living rooms. If the executives go home, the broadcast carries on. The dashboard is the office, and the evaluation service is the transmitter.

The split has a practical benefit: if the dashboard is slow or briefly unavailable, applications can still be served their flags. It also means the heavy daily work of editing and importing never slows the customers using your product.

19The Life of a Boolean Flag

Every flag should have a short, planned life. The ones with a planned ending are the ones that never become a problem.

flowchart LR
  A["Create flag in Project"] --> B["Enable in Development"]
  B --> C["Test in Staging"]
  C --> D["Release gradually in Production"]
  D --> E{"Stable and fully released?"}
  E -- Yes --> F["Remove flag checks from code"]
  F --> G["Delete or archive the flag"]
  E -- No --> H["Adjust or switch off"]
  H --> D
    
Fig 6. A release flag travels through Environments, then is removed once its job is done.

The stages in words

Create. Name it clearly, describe it, tag it and plan its removal. Develop. Enable it in Development while engineers build. Test. Enable it in Staging for testers. Release. Introduce it to real customers gradually in Production. Stabilise. Watch for a calm period after full release. Remove. Delete the flag check and the old code path, release that clean-up, and only then delete the flag in Flagsmith.

The last two steps are the ones most often forgotten. A flag left behind turns into hidden complexity, because the old code path is still there, untested, waiting to be woken by a mistake.

The best flag is the one you remembered to delete.
Everyday analogy

Scaffolding is essential while a building goes up, and a hazard if it is left standing for years. A release flag is scaffolding. Put it up, use it, and take it down when the work is finished.

How long should each kind of flag live?

KindExpected lifeReview rhythmEnd of life
Release flagDays to a few weeksWeekly during rolloutRemove code, delete flag
Experiment flagWeeksAt the end of each experimentKeep the winner, remove the rest
Operational flagMonths to yearsQuarterly drillRemove when the risk it protects is gone
Kill switchYearsQuarterly drillRemove when the feature is retired
Permission flagYearsTwice a yearRemove when the rule becomes standard for all

20Testing Code That Sits Behind a Flag

A flag doubles the number of paths your code can take. Testing must take that into account, or the flag becomes a hiding place for bugs.

Two paths, two sets of tests

Every boolean flag creates two behaviours: the old one when off, and the new one when on. Both must be tested. Teams that test only the new path discover, on the night they flip the kill switch, that the old path quietly broke weeks ago. The simplest rule is that every flag check has at least one test with the flag on and one with the flag off.

The combination problem

With one flag there are two combinations. With two flags there are four. With ten flags there are one thousand and twenty-four. Nobody tests them all, so the sensible approach is to keep flags independent. Each should control one behaviour and should not depend on the state of another. When two flags must be related, such as a new page that needs a new service, make that relationship explicit in the code and in the descriptions.

Number of flagsPossible combinationsPractical advice
12Test both states
38Test each state, plus the combinations that really occur together
101,024Keep flags independent, and test each alone
201,048,576Impossible to test all, so remove old flags aggressively
Everyday analogy

A car with two seat settings, one for height and one for angle, is easy to check. A car with twenty independent seat adjustments has more combinations than you could ever try, so engineers test each adjustment alone and trust that they do not interfere. Independent flags let you do the same with software.

Testing in Staging

Staging is the place to rehearse real flips. Before launch, flip the flag on and off in Staging with the real application, confirm the screen changes both ways, and confirm the audit log recorded it. If you will use a percentage rollout, test it with a few named test users and confirm they land in the groups you expect.

✓
Make it easy

Write a small helper in your test code that lets a test choose the flag state without calling Flagsmith at all. Fast tests that do not depend on the network are tests people actually run.

A short test checklist for every flag

  • With the flag on, the new behaviour works from start to finish.
  • With the flag off, the old behaviour still works and nothing is broken.
  • With no answer at all, the coded default behaves as intended.
  • Flipping the flag while the application is running does not corrupt anything that is half done.
  • The flag name in the code is exactly the name in Flagsmith.
  • The audit log shows the flip with the right person and time.

21Flag Debt and Clean-Up

Flags are borrowed convenience. If you never repay the loan, interest accumulates in the form of confusion and risk.

What is flag debt?

Flag debt is the pile of switches that have served their purpose but still live in code and in Flagsmith. Each one adds a little complexity: a branch nobody tests, a name nobody remembers, a risk that someone flips it by accident. A few are harmless. Hundreds are a hazard.

Spotting stale flags

A stale flag is one that has been fully on, or fully off, in every Environment for a long time. Look for release flags older than a few weeks, flags with no owner, and flags whose description is empty. Newer Flagsmith versions can help highlight such features, and tags and last changed dates help you find them on any version.

The safe order of removal

1

Confirm the flag is fully released

It should be on for everyone in Production and stable for a calm period.

2

Remove the check from the code

Keep the new path. Delete the old path and the flag condition entirely.

3

Release the clean code everywhere

Make sure every server and every app version in use has the cleaned code, or old versions will still ask for the flag.

4

Delete the flag in Flagsmith

Only now is it safe. Deleting earlier makes live code fall back to its default.

Scenario: a cautionary tale from finance

One of the best known software disasters involved the trading firm Knight Capital in 2012. In widely reported accounts, a release reused an old switch that woke long-dead code on a server that had not been updated, and the firm lost roughly four hundred million dollars in about forty-five minutes. Details have been debated, but the lessons are plain for any flag user: remove old flags, never reuse the meaning of an old name, and make sure every server runs the same version of the code.

Everyday analogy

A kitchen cupboard that nobody ever cleans fills up with expired tins. One day you need a specific spice and cannot find it, or worse, you cook with something that went off. A monthly ten minute tidy keeps the cupboard trustworthy.

Ownership and expiry notes

The most reliable defence against flag debt is a short note in the description of every release flag: who owns it, what it protects and the date by which it should be gone. When that date passes, a reminder goes to the owner, and silence is treated as a signal that the flag is probably safe to remove after a quick check. Teams that adopt this habit rarely find themselves with hundreds of mysterious switches, because each one carried its own retirement plan from birth.

22Who May Flip the Switch? Permissions and Change Control

A boolean flip can change what every customer sees. Treat the right to flip it with the respect you give the right to deploy code.

Permissions at three levels

Flagsmith controls access at the Organisation, Project and Environment levels. For boolean flags, the most important permission is the one that lets a person change a flag’s state in a given Environment. Give it widely in Development, to a smaller group in Staging, and to a small named group in Production. People are best given permissions through groups, such as “Release Group”, rather than one by one.

GroupCreate flagFlip in DevelopmentFlip in StagingFlip in Production
Product engineersYesYesYesNo
Release groupNoYesYesYes
SupportNoNoNoNo, view only
AuditorsNoNoNoNo, view and read the history

Approvals and scheduling

On plans that offer them, change requests require a second person to approve a change before it takes effect, which is the software equivalent of a pilot and co-pilot reading the checklist together. Scheduling lets a team set a flag to change at an exact time, such as nine in the morning on launch day, so nobody has to be awake at dawn. Always rehearse a schedule in Staging and check the time zone shown on screen.

Two lanes of change

The standard lane covers routine changes, such as raising a rollout from ten to twenty-five percent, and needs the normal permission and a note in the team channel. The emergency lane covers urgent actions, such as switching off a failing feature, and is intentionally fast. The emergency lane must still leave a trail: a message in the incident channel and a short review the next working day.

Everyday analogy

In a restaurant kitchen, any cook may adjust a dish while testing in the back. Only the head chef approves the dish for the menu. Power narrows as the cost of a mistake rises, and the same shape suits Development, Staging and Production.

!
Check current options

Exact permission names, approval flows and scheduling are tied to your Flagsmith version and plan. Treat the principles here as stable, and confirm specifics in your own dashboard before writing a policy.

Handover and on-call

The most stressful moment to learn who may flip a switch is during an incident. Make the on call engineer a member of the Release Group for the duration of their shift, or give them a documented route to ask someone who is. Keep an up to date page with the names of the most important kill switches, what each does, and what the safe default is. When a new engineer joins the rota, walk through that page together once. It takes ten minutes and prevents a very bad night.

23Security Thinking for Boolean Flags

A flag platform can change what every customer sees. It deserves the same care as any system that can alter production.

Know your keys

Public

Client-side key

Belongs to one Environment, is safe in websites and mobile apps, and can only read flag values.

Secret

Server-side key

Belongs to one Environment and must stay on your own servers. It unlocks richer access such as local evaluation.

Master

Organisation key

Lives above the Project and can manage Flagsmith itself. Never place it in an application.

Everyday analogy

A hotel gives a guest a room card for one door, a cleaner a floor card for many, and keeps one master key in a safe. You never hand the master key to a guest. Match each key to the smallest job it needs to do.

What an outsider can see

Anything sent to a browser or phone can, in principle, be read by the user. That means the names of flags sent to a client may reveal unannounced features to a curious visitor. Where your version offers the option, hide disabled flags from client applications, so only features that are on are visible. Avoid putting secrets, internal code names or private commentary in flag names or descriptions that clients can read.

Flags are not locks

Never rely on a flag alone to protect something sensitive. The flag decides what the screen shows. The server must still check that the person is allowed to see the data. Treat the flag as a convenience for honest users, and the server check as the guard for everyone else.

!
Danger

Automated scanners crawl public code sites around the clock looking for leaked secrets, and they find them within minutes. If a server-side key is ever pasted into a public repository, assume it is compromised even if you delete it seconds later. Rotate it at once.

Practical protections

  • Separate keys per Environment. A test build should never hold a Production key.
  • Store secrets in a vault. Never in chat messages, documents or code files.
  • Rotate on a schedule. Replace keys every few months and after any staff change that could have exposed them.
  • Limit who flips Production. A small named group, with approvals where the plan allows.
  • Turn on two-step sign-in. A stolen password alone should never be enough to flip a live switch.

24Monitoring and the Audit Trail

Flipping a flag is easy. Knowing what the flip did is the real skill.

The audit log

The audit log is a diary of changes. For each flip it records who did it, when, and what the earlier value was. When a customer reports that something vanished at three in the afternoon, the audit log turns guesswork into a thirty second lookup, and tells you exactly how to undo the change. How long history is kept can depend on your plan.

Webhooks and integrations

A webhook is an automatic message sent from Flagsmith to another system when something happens. Many teams connect it to a chat channel so that each Production flip is announced to everyone. Flagsmith also provides integrations with tools such as Datadog and Slack, so that a flag change appears as a marker on the same graph as error rates and response times.

1

A flag is flipped in Production

The audit log records the person, the time and the old and new values.

2

A message is sent

A webhook or integration tells the team channel and the monitoring tool.

3

The graph shows the effect

Error rates and speed appear next to the marker for the change.

4

A quick decision is made

If the graph turns red, the flag is flipped back within moments.

This pairing is extremely powerful, because most production incidents are caused by a change, and flag flips are changes. When a graph shows a spike, the first question, “what changed just before?”, is answered by the marker on the graph.

Age
how long each release flag has lived
Count
how many flags exist, and the trend
Reversal
how fast a bad flip is undone
i
Leave a note

When flipping something important, write a short reason in the team channel. “Turned off similar-videos panel to protect the database during the match” saves long debates later and teaches new colleagues how the product behaves under stress.

A simple flag health view

Many teams build a one screen view of flag health, using tags and last changed dates. It lists the number of flags by kind, the oldest release flag, flags with no owner, flags changed in the last week and flags on in Production for everyone for more than a month. A glance at that screen each week keeps debt visible, and visible debt gets paid down.

25Anti-patterns and Common Mistakes

These traps appear in almost every company that adopts feature flags. Learn them now, and avoid paying for them later.

ANTI-PATTERN 01Avoid
The mistake

Flags that live forever.

Why it hurts

Old flags leave untested code paths and multiply the combinations the product can take. A forgotten flag is a loaded switch you forgot you owned.

Do this instead

Give every release flag an owner and an expected end date, and review them monthly.

ANTI-PATTERN 02Avoid
The mistake

Names with “disable” or “no”, creating double negatives.

Why it hurts

A tired engineer flips the wrong way during an incident, making things worse at the worst moment.

Do this instead

Name the behaviour when the flag is on, and always use positive words such as “show” and “enable”.

ANTI-PATTERN 03Avoid
The mistake

Reusing an old flag name for a new purpose.

Why it hurts

Old code anywhere may still read that name and behave in a surprising way. This is the lesson of the Knight Capital story.

Do this instead

Always create a fresh name for a fresh purpose. Names are cheap, and surprises are expensive.

ANTI-PATTERN 04Avoid
The mistake

Using a flag as the only security check.

Why it hurts

A hidden button does not stop a direct call to the service behind it. Sensitive data can leak even though the screen looked locked.

Do this instead

Always enforce permission on the server, and let the flag only shape what honest users see.

ANTI-PATTERN 05Avoid
The mistake

Flags that depend on other flags in hidden ways.

Why it hurts

Nobody can predict what happens when two are in unusual combinations, and testing becomes impossible.

Do this instead

Keep each flag independent. If two must be related, write the relationship in both descriptions and test it on purpose.

More small mistakes worth naming

  • No safe default in code, so a flag outage becomes a product outage.
  • Flipping a flag in Production before rehearsing it in Staging.
  • Mixing the enabled state with a “true” or “false” value in the same feature.
  • Letting Production permissions widen over time, because “just this once” was never undone.
  • Putting a Production key in a test build.

26Failure Scenarios and Recovery

Things will go wrong. Calm teams are the ones that already know what to do.

Scenario one: the wrong flag was flipped in Production

The first move is always to put it back to its previous value, which the audit log shows. Only after customers are safe should you ask how it happened. Teams that rehearse this typically recover in a minute or two.

Scenario two: the flag is on but nothing changed

Check three things in order. Is the application reading the right Environment key? Has it refreshed since the flip, or is it still holding a cached answer? Is the flag name in the code exactly the same as in Flagsmith? Most “it does not work” reports end at one of these three.

Scenario three: the flag works for some people but not others

Walk down the evaluation ladder from Chapter 9. Look for an identity override, then segment overrides and their order, then the Environment default. Confirm that the traits the segment needs are actually sent by the application, in the right format.

Scenario four: a flag was deleted while code still used it

The application falls back to its coded default, which is why defaults matter. Recreate the flag with the same name, restore its states from what the history shows, and plan the clean removal from code before deleting again.

Scenario five: a secret key leaked

1

Create a replacement key

Make the new key first so real systems can be updated without downtime.

2

Roll it out

Update secrets stores and applications. Confirm traffic uses the new key.

3

Revoke the old key

Delete the leaked key so it can never be used again.

4

Review the audit log

Look for unfamiliar changes during the exposure, and reverse anything suspicious.

Scenario six: Flagsmith is unreachable

Applications should be designed so that the worst case is boring. SDKs can keep serving the last known values, and your code supplies defaults for anything missing. For a flag that protects something essential, such as the ability to log in, decide the default carefully and test that path on purpose.

RUNBOOK NOTEKeep handy
Write these down

Who may flip Production, where to find a flag’s previous value, how long an SDK takes to notice a change, how to rotate each key, and who to tell. If any answer is “I would have to search for it”, write it down today.

Everyday analogy

Aircraft crews rehearse engine failures long before one happens. The checklist is on a card, and they follow it without trying to be clever under stress. A runbook for your flags is that card.

Scenario seven: a flip works on the website but not in the mobile app

This is usually a freshness problem rather than a broken flag. The web page fetches flags every time it loads, while the app may be holding values fetched earlier. Check when the app last refreshed, whether it is an older version that never asks for this flag, and whether the app is pointing at the correct Environment key. If the flag is a kill switch, this is the moment to remember the refresh interval from your runbook, and to decide whether it is short enough for the risk the switch protects.

27Performance and Scaling for Millions of Checks

A boolean check is tiny, but a busy product makes billions of them. Good design keeps each one cheap.

Ask once, decide many times

The core idea is to separate fetching flags from checking them. Fetching is a network call and takes milliseconds. Checking, once the flags are in memory, takes microseconds. A well built application fetches at the start of a session or on a timer and then makes hundreds of checks from memory.

flowchart LR
  U["Millions of users"] --> APPS["Your application servers"]
  APPS --> SDK["SDK with local cache"]
  SDK -- "periodic refresh" --> PROXY["Optional local proxy"]
  PROXY -- "occasional sync" --> FS["Flagsmith platform"]
    
Fig 7. Layers of caching keep millions of checks away from the central platform.

A small capacity thought experiment

Suppose an application serves one hundred thousand requests per second at its busiest moment. If every request caused a fresh flag lookup, the platform would need to answer one hundred thousand questions per second, which is wasteful. With caching inside each application server, perhaps only one lookup per server every thirty seconds is needed. With two hundred servers that is about seven requests per second, a reduction of over ten thousand times, and users still get a decision in microseconds from memory.

DesignNetwork calls per decisionTypical speed of a decisionCost to your usage
Ask Flagsmith on every checkOneMillisecondsVery high
Fetch once per session, check from memoryAlmost noneMicrosecondsLow
Local evaluation on the serverNoneMicrosecondsVery low
Everyday analogy

A city does not ask the central water plant every time someone turns a tap. Water waits in local towers, which keep houses supplied even if the plant has a short problem. SDK caches and local proxies are those towers.

Resilience comes free with the design

Delivery of flags is separate from the dashboard, so a dashboard outage does not stop evaluation. SDKs can keep serving the last known values if the network is down. And your own code defines defaults, so the worst case is a safe and familiar experience rather than an error page. Companies that serve very large traffic, such as Netflix and Google, speak often about designing for failure and for cost, and a flag lookup deserves the same thought as any other network call.

Counting the cost

Flag usage is typically measured in requests to the platform, not in the number of checks your code makes. That is why caching is both a speed measure and a cost measure. A mobile app with two million users that fetches flags three times a day makes six million requests a day. If a bug makes it fetch on every screen change, that number can grow many times over without anyone touching a flag. Review the usage page each month, and treat an unexplained jump as a bug in the application, not as growth.

28Worked Example: Launching a New Checkout Page

Ideas become clear when applied. Follow one flag through a complete launch for a fictional retailer called Northwind.

The situation

Northwind sells goods through a website and a mobile app. A team of about twenty engineers is replacing the payment sheet in its checkout. The change is important and risky, because a broken checkout means lost sales. The team decides to use one boolean flag named “checkout_new_payment_sheet”, tagged as a release flag and owned by the Store team.

1

Create and describe

The flag is created in the Store Project, disabled everywhere, with a description explaining what it does, who owns it and that it should be removed after full release.

2

Write both code paths

Engineers add the check. When on, the new sheet appears. When off, the old one remains. Both are tested.

3

Enable in Development

The team flips the flag on, confirms the new sheet appears, flips it off, and confirms the old sheet returns.

4

Rehearse in Staging

Testers run full purchases with the flag on and off. The release group practises the flip and checks the audit log.

5

Staff only in Production

A segment override enables the flag for the “Staff” segment. Employees make real purchases and report problems quietly.

6

Gradual widening

One percent, ten, twenty-five, fifty, then everyone, with the team watching error and purchase graphs at each step.

7

Calm period

For two weeks the flag is on for everyone. The team confirms nothing odd appears.

8

Clean up

The old payment sheet and the flag check are removed from code, the clean release goes everywhere, and only then is the flag deleted.

StageDevelopmentStagingProduction defaultProduction overrides
BuildingOnOffOffNone
TestingOnOnOffNone
Staff trialOnOnOffStaff segment on
Slow rolloutOnOnOffStaff and percentage segment on
Full releaseOnOnOnNone needed
After clean-upFlag deleted. Code has only the new payment sheet.

What went right

At no point did the team deploy to change what customers saw. Each step was a click, each click was recorded, each was reversible within seconds, and each decision was made with graphs in front of the team. If the one percent stage had shown a rise in errors, the flag would have been flipped off and customers barely affected.

Everyday analogy

It is like opening a new shop counter. First you rehearse behind a curtain with staff. Then you invite friends. Then you open the door to a few shoppers, watch how it goes, and finally take down the curtain for good. The flag is the curtain, and good practice means you do take it down.

What the team learned afterwards

A week after cleaning up, Northwind held a short review. Three lessons were written on one page. The first was that rehearsing the flip in Staging caught a misspelled flag name in the mobile app before any customer saw it. The second was that the one percent step was long enough to reveal a slow database query, which was fixed before reaching ten percent. The third was that the removal ticket created on day one made clean-up routine rather than a chore nobody owned. Reviews like this turn a single launch into lasting habits for every launch afterwards.

29Moving Existing Switches onto Boolean Flags

Few teams start from nothing. Most already have switches hidden in configuration files, environment settings and database tables.

Why homemade switches struggle

A homemade switch, such as a setting in a file, is perfectly reasonable for a handful of toggles. Trouble arrives with growth. Changing the file needs a deployment, so it is not instant. Nobody records who changed it. It cannot be targeted at a percentage or a group. There is no permission control, so anybody with file access can alter it. A managed platform supplies those missing pieces, and the structure of Projects, Environments and permissions is the part homemade systems tend to lack and later regret.

The four kinds of flag

Practitioners often sort flags into four groups, a classification popularised by engineers writing on well known software design sites. Release flags hide unfinished work and are short lived. Experiment flags split users to measure which version performs better. Operational flags protect the system and may live for years. Permission flags give certain customers or staff special access and may be permanent. Knowing the kind tells you how long a flag should live and who should be allowed to change it.

1

Take inventory

Search code and configuration for existing toggles. List what each does, who owns it and whether it is still needed.

2

Set up the structure first

Create the Project, Environments, naming rules, tags and groups before anyone moves in.

3

Pilot with one low risk switch

Move one real but harmless toggle and let the team find the rough edges while stakes are small.

4

Migrate in waves

Move a few at a time. Retire the old mechanism as each one moves, so two systems never run side by side for long.

5

Measure the outcome

Track how often releases happen, how long a rollback takes and how many flags are removed on schedule.

✓
Success signal

You know adoption is working when nobody is afraid of releasing on a busy afternoon, because everyone knows a switch exists to go back.

30Advantages, Disadvantages and Trade-offs

No design is perfect. Knowing both sides lets you decide with open eyes.

Advantages

  • Releases separate from deployments, so shipping becomes routine.
  • Instant reversal, with no new code needed.
  • Gradual exposure through segments and percentages.
  • Simple to understand: two states, one question.
  • Safer experiments, because a bad idea can be turned off at once.
  • Built-in history of who changed what and when.

Disadvantages and trade-offs

  • Every flag doubles the code paths and the testing needed.
  • Old flags become hidden complexity if not removed.
  • Only two answers, so richer needs call for values or multivariate features.
  • A flip is not always instant everywhere, because of caching.
  • Flags can create false confidence if used as the only security.
  • Teams must agree conventions, because the tool will not invent them.

When a boolean flag is not the right tool

If a value is a true business rule needing legal review, such as a tax rate, it belongs in a controlled data store. If something needs complex relationships and queries, it belongs in a database. If a change is permanent and risk free, put it straight into the code. And if you need to compare several versions, reach for a multivariate feature instead of stacking boolean flags. A healthy Flagsmith holds switches and settings, not the whole configuration of the company.

31Best Practices Checklist

A short list to keep nearby. If you do these ten things, you will avoid most of the pain described in this guide.

01

Name for the on state

Describe what happens when enabled. Never use “disable” or “no” in a name.

02

Describe and tag

Write a sentence of purpose, name an owner and mark the kind of flag.

03

Start disabled

New flags begin off everywhere so creation never changes what customers see.

04

Always code a default

Choose the least harmful behaviour for when Flagsmith cannot answer.

05

Test both paths

Every flag check has a test with the flag on and one with it off.

06

Rehearse in Staging

Flip the real flag in Staging before every launch and confirm the screen changes.

07

Roll out gradually

Staff first, then small percentages, watching numbers before widening.

08

Limit Production flips

A small named group, with approvals where available and notes in chat.

09

Never trust a flag as a lock

Enforce real permissions on the server, always.

10

Plan the ending

Remove the code first, then delete the flag, and review for stale flags monthly.

32Glossary: Every Term in One Place

Keep this table nearby while reading documentation or talking with your team.

TermPlain meaning
BooleanA value with exactly two states, true or false.
Feature flagA switch inside software that decides whether a behaviour is active.
Boolean flagA flag that answers only yes or no, on or off.
Remote configurationChanging a value in a running application without releasing new code.
Multivariate featureA feature with several values split between users by percentage.
ProjectThe home of one product’s features, segments and tags.
EnvironmentOne stage, such as Development or Production, holding live states.
Feature definitionThe existence of a flag, shared by all Environments of a Project.
Feature stateWhether a flag is on in one Environment.
IdentityAn end user or account whose flags are being worked out.
TraitA fact attached to an identity, such as plan or country.
SegmentA rule that selects a group of identities.
Segment overrideA different answer for a segment in one Environment.
Identity overrideA different answer for one specific identity.
Release flagA short lived flag that hides unfinished work.
Kill switchA flag that turns a risky feature off quickly in an emergency.
Permission flagA flag that switches a capability on for chosen customers or staff.
Operational flagA flag that changes system behaviour under stress.
Dark launchRunning new code in Production without showing its results.
CanaryA very small first audience used to prove a release is safe.
Safe defaultThe value your code uses when it cannot reach Flagsmith.
SDKA ready made library that lets your application talk to Flagsmith.
Local evaluationDownloading rules once and deciding flags inside your own server.
Control planeThe part of a system where humans manage configuration.
Data planeThe part that serves high volume requests from applications.
Audit logA diary of who changed what and when.
Stale flagA flag that has served its purpose but still remains.
Flag debtThe accumulated cost of flags that were never removed.
Double negativeA name like “disable_x” where enabling the flag turns something off.

33Frequently Asked Questions

Quick answers to the questions that come up most often.

Q1Is a boolean flag the same as a standard feature in Flagsmith?
In everyday use, yes. A standard feature’s core is an enabled or disabled state, which is the boolean. It can also carry an optional value, which is a separate idea.
Q2Can a flag be on in Production and off in Development?
Yes. The state is stored separately in each Environment, so each stage has its own answer.
Q3Can I create a flag in only one Environment?
No. The flag is defined once for the Project and exists in every Environment. You control where it is switched on.
Q4If a flag has only two states, how can I roll it out to ten percent of users?
Use a segment with a percentage rule and give it an override that turns the flag on. Ten percent of people see it enabled and the rest see the default.
Q5Why does a person see a different answer from a colleague?
They probably match different rules. Check for an identity override, then the segments they belong to and their order, then the Environment default.
Q6How fast does a flip reach users?
It depends on how the application fetches flags. Server-side checks that ask each time see it at once, while apps and servers that cache see it at their next refresh. Know your refresh interval and write it in the runbook.
Q7What happens if Flagsmith is down?
Delivery is designed to be separate from the dashboard, and SDKs can keep serving the last known values. Your code should always define a safe default as a final safety net.
Q8Should I name a flag “disable_something”?
Avoid it. Enabling a “disable” flag turns the behaviour off, which is a double negative that confuses people under pressure. Name the behaviour when the flag is on.
Q9Can I use a flag to protect private data?
No, not on its own. A flag shapes what the interface shows. Real protection must be enforced by permission checks on your servers.
Q10When should I delete a flag?
After the flag check is removed from all code and the cleaned code is released everywhere. Deleting earlier makes live code fall back to its default.
Q11Is a client-side key safe to put in a mobile app?
Yes, that is its purpose, because it only reads flag values for one Environment. Never place a server-side or Organisation key in an app or web page.
Q12How many flags is too many?
There is no fixed number, but the combinations multiply fast. If the team cannot say what each flag does and who owns it, you already have too many, and a cleanup is overdue.
Q13Should one flag guard several places in the code?
It can, when all those places belong to the same behaviour. Keep the checks close together, and list them in the description, so that removal later is a single clean job rather than a hunt.
Q14Can I rename a flag safely?
Treat names as permanent. Code finds a flag by its name, so renaming it in Flagsmith while code still uses the old name makes applications fall back to their defaults. If a rename is truly needed, create the new flag, update the code, release it everywhere, and then remove the old one.

34Summary and Key Takeaways

Remember these seven ideas

  • A boolean flag is a two state switch. It answers yes or no, and that narrowness makes it easy to understand, test and reverse.
  • Definition and state are different. The flag exists once in the Project, but its on or off state lives separately in each Environment.
  • The most specific rule wins. Identity overrides beat segment overrides, which beat the Environment default, so always walk that ladder when an answer surprises you.
  • Choose the right pattern. Release flags are short lived, kill switches and operational flags are long lived protections, and permission flags express business rules.
  • Always code a safe default and test both paths. Your product should behave sensibly if Flagsmith is unreachable, and the old path must stay healthy until you remove it.
  • A flag is not a lock. Use it to shape what honest users see, and enforce real permissions on your servers.
  • Plan the ending. Remove the code first, then delete the flag, and review for stale flags on a regular schedule.