Promoting Flags Between Environments in Flagsmith
A complete, plain-English guide to moving a feature flag from Development to Staging to Production without surprises: what actually moves, which tools help, how to automate it, and how to keep every release calm and reversible.
Imagine your team has just finished a new checkout page. The code works on your laptop. It works in the test system. Now someone asks the question every software team asks sooner or later: “Can we turn it on for real customers, but only a few of them, and only when we say so?” That question is the reason feature flags exist, and the daily work of answering it safely is what people mean when they talk about promoting flags between environments.
Flagsmith is a popular open-source feature flag and remote configuration service. It lets you wrap a piece of behaviour in a switch, then control that switch from a dashboard instead of from code. The switch can live in several separate places called environments, such as Development, Staging and Production. Each place keeps its own settings. That separation is wonderful for safety, but it raises a practical puzzle: when a flag is ready in one place, how do you carry that decision to the next place correctly?
This guide walks through that puzzle from the very beginning. You will learn the vocabulary, see what a flag is made of, compare every sensible way to move one, and finish with a repeatable workflow, a safety checklist, a list of common mistakes and a set of answers to questions people ask most. No prior knowledge of Flagsmith is assumed, and no code is needed to follow along.
1Why Environments and Flags Exist
Before moving anything anywhere, it helps to understand what is being moved and why there are several places to move it between.
What is a software environment?
A software environment is a separate copy of your running system, set up for a specific purpose. Your Development environment is where engineers try things and break things. Your Staging environment is a close rehearsal of the real system, used for testing before release. Your Production environment is the real thing, the one customers actually use. Each has its own servers, its own data and, importantly for this guide, its own configuration.
Why keep them apart? Because mistakes are cheap in Development and expensive in Production. A bug that makes a test page crash is a small lesson. The same bug on a live shopping site during a sale is a headline. Environments give you a place to be wrong without anyone outside the team noticing.
Think of a theatre. The empty rehearsal room is Development: actors forget lines, props fall over and nobody minds. The dress rehearsal on the real stage is Staging: costumes, lights and timing are all tested, with only the crew watching. Opening night is Production: the audience is in their seats and every mistake is visible. A good director never skips the dress rehearsal, and never changes the script in the middle of opening night without a very good reason.
What is a feature flag?
A feature flag, also called a feature toggle or feature switch, is a condition in your application that decides whether a piece of behaviour is active. The code for a new feature is shipped to every environment, but it stays hidden behind the flag. When the flag is off, users see the old behaviour. When the flag is on, they see the new one. The decision is stored outside your code, so changing it does not need a new deployment.
This idea separates two things that used to be glued together: deploying code and releasing a feature. Deploying means putting new code on servers. Releasing means letting users experience it. With flags, you can deploy on Tuesday and release on Friday, or release to ten percent of users first, or switch the feature off in seconds if something looks wrong.
What is Flagsmith?
Flagsmith is a service that stores your flags and hands their current state to your applications. You can use the hosted version or run it yourself, because the core is open source. Your application asks Flagsmith a simple question, such as “is the new checkout enabled for this user right now?” and receives an answer. Beyond simple on and off switches, Flagsmith also stores remote configuration values, such as a text message, a number or a small block of settings, and it can give different answers to different groups of users.
All of the answers are organised by environment. The same flag can be off in Production, on in Staging and set to a different value in Development. That freedom is the whole point, and it is also why promotion needs care.
What does promoting a flag mean?
Promoting a flag means taking the decision you made in one environment and applying the same decision in another, usually the next one up the ladder. You tested the new checkout in Staging with the flag on for the internal team. Now you want the equivalent setup in Production, perhaps starting with a small slice of real customers. Promotion is the careful transfer of that intent.
Real-world example: Facebook Chat
Facebook has publicly described launching its Chat feature in 2008 as a “dark launch”: the code ran in production for real traffic long before users could see it, and exposure was widened step by step. That pattern, shipping hidden and revealing gradually, is exactly what flags make routine. Each widening step is a promotion of the flag’s settings to a larger audience.
Promotion is a release-management activity, not a code deployment. Moving a flag does not move code. The code that reads the flag must already be running in the target environment before the flag change can matter.
2The Building Blocks of Flagsmith
Eight words explain almost everything in the dashboard. Learn them once and the rest of this guide reads easily.
Flagsmith organises everything in a simple hierarchy. At the top sits your organisation, which represents your company or team and holds users, billing and permissions. Inside an organisation you create projects, one for each application or product you manage. Inside a project you have environments, and inside each environment you find the state of every feature.
flowchart TD
ORG["Organisation"] --> P1["Project: Web Shop"]
ORG --> P2["Project: Mobile App"]
P1 --> F["Features and Segments defined once per project"]
P1 --> E1["Environment: Development"]
P1 --> E2["Environment: Staging"]
P1 --> E3["Environment: Production"]
E1 --> S1["Feature states and overrides for Development"]
E2 --> S2["Feature states and overrides for Staging"]
E3 --> S3["Feature states and overrides for Production"]
F -.-> S1
F -.-> S2
F -.-> S3
Read the diagram from top to bottom. The organisation holds projects. A project holds one shared list of features and segments, shown in the box on the left. The same project also holds several environments. The dotted lines show that every environment looks at the shared list, but each environment keeps its own private state for every item on that list. This split between “defined once” and “configured many times” is the single most important idea for understanding promotion.
Organisation
The company-level container. It owns members, roles, billing and every project beneath it.
Project
One application or product. Features and segments are defined here and shared by every environment inside it.
Environment
A stage such as Development, Staging or Production. It holds its own flag states, values and overrides.
Feature (flag)
A named switch, with optional remote value. Created once in the project, configured separately in each environment.
Segment
A saved rule describing a group of users, for example “customers in India on the paid plan”. Defined in the project.
Identity
A single user as your app describes them to Flagsmith, with an identifier and optional traits.
Trait
A fact about an identity, such as country, plan or app version. Segments read traits to decide who belongs.
Environment key
The secret-ish identifier your app uses to ask Flagsmith for flags. Every environment has its own, so keys never cross over.
Picture an office tower with three identical floors. The architect drew one plan showing a light switch called “Reception Lamp” (the feature). Each floor then has its own wiring panel, so the lamp can be on at floor one and off at floor three (the environment state). A rule such as “only the sales team’s desks get the brighter bulbs” is a segment. A note saying “Priya’s desk always gets the brighter bulb” is an identity override. Moving the lamp’s setting from floor one to floor three means walking to the other panel and setting it there, because the panels are not connected.
Client-side and server-side keys
Each environment has a client-side environment key and a server-side key. The client-side key is meant for apps that run on a user’s device, such as a web page or phone app. It is considered public and can only read flags. The server-side key is meant for your backend services. It is secret, and it unlocks extra abilities such as local evaluation, where your own server downloads the rules and decides flags without calling Flagsmith each time.
Because these keys belong to one environment, a Staging app can never accidentally read Production flags, and the reverse is also true. That protection is also why nothing moves between environments on its own. Your Staging app asks Staging questions and receives Staging answers.
Never paste a server-side key into a browser app, a mobile app or a public repository. Treat it like a password. If one leaks, rotate it for that environment straight away.
3What a Flag Is Made Of, and What Actually Moves
“Copy the flag to Production” sounds like one action. In reality it is several separate pieces, and you should decide on each one deliberately.
Two layers: the definition and the state
Every flag has a definition and a state. The definition is the flag’s identity: its name, its description, its tags and its type. It is created once, at the project level. The state is how the flag behaves right now in one specific environment: whether it is enabled, what value it carries, which segments get special treatment, and which individual users get their own override.
Because the definition is shared, a newly created flag appears in every environment of the project right away, typically switched off. You do not need to “create it again” in Production. What you do need to do is set its state there. That is the real meaning of promotion.
flowchart LR
DEF["Flag definition: name, description, tags"]
DEF --> ST["Environment state"]
ST --> EN["Enabled or disabled"]
ST --> VAL["Remote value"]
ST --> MV["Multivariate split percentages"]
ST --> SEG["Segment overrides in priority order"]
ST --> ID["Identity overrides"]
SRC["Source environment"] -. "decision to copy" .-> ST
The figure shows the definition on the left and the five pieces of environment state on the right. The dotted arrow at the bottom is promotion: you take decisions made in a source environment and apply them to some or all of those five pieces in the target. Let us look at each piece in plain words.
Enabled or disabled
The main on and off position. This is the piece most people think of first, and the one with the biggest immediate effect on users.
Remote value
An optional piece of data stored with the flag, such as a banner message, a timeout number or a small settings block. Different environments often need different values, for example a test payment address in Staging and the real one in Production.
Multivariate allocation
Some flags offer several variants, such as three button colours, with a percentage of users assigned to each. These percentages are part of the state and are stored per environment.
Segment overrides
Special rules saying “for this group, behave differently”. Each override can have its own enabled position and value, and the overrides are checked in a priority order that you control.
Identity overrides
Special treatment for one specific user, such as a tester or a friendly customer. These are the most personal and the most environment-specific of all the pieces.
Which pieces should you usually copy?
There is no universal answer, but there is a sensible default. Enabled position, segment overrides and multivariate percentages usually describe a release plan, so they are good candidates for promotion. Remote values often contain environment-specific details such as web addresses, account numbers or limits, so copy them only after reading them. Identity overrides almost always belong to people who exist in one environment only, since the user “tester-42” in Staging is not a real customer in Production. Treat them as not promoted unless you have a specific reason.
A cookbook has one recipe for tomato soup, which is the definition. Each restaurant kitchen that cooks it decides how much salt to add tonight, whether to add chilli, and whether the head chef’s special table gets extra cream. Sending the recipe to a new kitchen is easy. Getting the new kitchen to cook it exactly as the first kitchen perfected it needs somebody to carry over the actual decisions, and to adjust the ones that depend on local ingredients.
4The Environment Ladder
Promotion always travels along a path. Knowing the shape of that path tells you how careful each step should be.
Most teams arrange their environments as a ladder with the safest, noisiest rung at the bottom and the most protected rung at the top. A flag climbs one rung at a time, and at each rung it must prove itself before moving up. The number of rungs varies by company. A small start-up may have only Development and Production. A large bank may have six or seven stages, including security testing and a regulatory sign-off stage.
| Environment | Who uses it | Risk if wrong | Who should edit flags | Typical flag behaviour |
|---|---|---|---|---|
| Development | Engineers | Very low | Any developer | Flags flipped constantly while building |
| QA or Test | Testers and automated checks | Low | Developers and testers | Flags set to match test plans |
| Staging | Whole team, sometimes selected partners | Medium | Release owners | A mirror of the planned Production setup |
| Production | Real customers | High | Few named people, often with approval | Gradual rollout, kill-switch ready |
Notice how the column “Who should edit flags” narrows as you climb. This is deliberate. In Development, speed matters most, so everyone can change anything. In Production, accuracy matters most, so changes should be rare, visible and reviewed. Flagsmith supports this with roles, permissions and, on paid plans, formal change approval, which later chapters describe.
Why not just use one environment with a different flag name?
Some beginners try to avoid environments by creating flags named “checkout_test” and “checkout_live”. This quickly turns into chaos. Names drift, people flip the wrong one, and the code needs to know which name to read in which place. Real environments solve this cleanly: the code reads one flag name everywhere, and the environment key decides which set of answers comes back.
Real-world example: Etsy and gradual ramp-ups
Etsy has written publicly about shipping code continuously and using configuration flags to ramp features up in stages, first to employees and then to small percentages of members. The lesson for any team is that the ladder is not only about environments in the technical sense. It is also about audiences, and a flag in Production can itself climb a ladder from staff to one percent to everyone.
Many teams keep Production as an environment but treat percentage steps inside it as sub-stages. Promoting from Staging to Production is therefore not the end of the journey. It is the start of a second, smaller ladder inside the live system.
5Your Options at a Glance
There is more than one good way to carry a flag’s settings upward. The right choice depends on how many flags move, how often, and how much control your organisation needs.
Flagsmith is a flexible tool, and what you see in the dashboard depends on your edition and version. Some helpers, such as approval workflows and scheduling, are part of paid plans. Others, such as the programmable Admin API, are available widely. The table below lists the methods you will meet in this guide, with an honest view of when each one fits.
| Method | Best for | Effort | Safety | Repeatable? |
|---|---|---|---|---|
| Manual edit in the dashboard | One or two flags, small teams | Low | Depends on the person | Not really |
| Compare view, then manual edit | Finding differences before a release | Low to medium | Good, because gaps are visible | Partly |
| Cloning an environment | Creating a new environment from an existing one | Low | Good for starting points | Yes for new setups |
| Change requests and scheduling | Regulated or larger teams | Medium | High, with approvals and history | Yes |
| Admin API and Terraform | Many flags, pipelines, strict consistency | Higher up front | High, once tested | Fully |
Manual promotion
Open the flag in the target environment and set it by hand. Simple and visible, but easy to get wrong when many flags are involved.
Compare, then align
Use the dashboard’s comparison tools to see where two environments disagree, then fix only the differences you intend to fix.
Clone an environment
Create a new environment as a copy of an existing one, which is ideal for fresh Staging, preview or regional setups.
Change requests
Propose a change, have a colleague approve it, and optionally schedule it for a chosen time. Best for Production.
Automation
Script the transfer through the Admin API, or describe flags in Terraform so promotion becomes part of a pipeline.
Menu names and button positions change between Flagsmith versions. Use the names in this guide as signposts, then confirm the exact wording in your own dashboard and in the official documentation for your version before building a team process around any single screen.
Moving house offers the same choices. You can carry a few boxes yourself, which is manual promotion. You can walk through both homes with a checklist to see what is missing, which is the compare approach. You can hire a service that copies the whole layout to a new flat, which is cloning. You can book a professional team with a signed inventory and a booked time slot, which is change requests. Or you can run the same moving company every month with a fixed contract, which is automation. None is wrong. The right one depends on how often you move and what you cannot afford to lose.
6Method 1: Manual Promotion, Step by Step
The simplest method is also the one every team should understand first, because every other method is a faster or safer version of the same moves.
Manual promotion means you open the flag in the source environment, read what it says, open the same flag in the target environment, and make it match. It needs no special tools and no extra permissions beyond the right to edit flags in the target. For a handful of flags, it is perfectly reasonable. The danger is not the method itself but the lack of a written routine, so here is a routine you can follow every time.
Confirm the code is already deployed
Check that the target environment is running the version of your application that reads this flag. A flag change in front of missing code does nothing, and a flag change behind broken code can cause an outage.
Read the source state carefully
Open the flag in the source environment and note four things: the enabled position, the value, any multivariate percentages, and every segment override with its priority order. Write them down or take a screenshot.
Decide what should really be copied
Go through the five pieces from Chapter 3 one by one. Ask for each: does this belong in the target environment as it is, does it need a different value, or should it be left alone?
Start with the safest position
If the flag controls something risky, open it in the target as disabled, then set up values and segments first. Only switch it on at the very end, so you never have a half-configured flag live for even a moment.
Recreate segment overrides in the right order
Add each segment override and then check the priority. When two segments match the same user, the one higher in the list wins, so a different order can give a different result.
Set the enabled position and save
Switch the flag to the intended state, often starting with a narrow audience or a small percentage, and add a short comment describing why. Comments appear in the history and help the next person.
Verify from the outside
Do not trust the dashboard alone. Use the application itself, or a test identity, to confirm that the user experience matches the plan.
Why “start disabled” matters
A flag is read the moment you save it. If you flip the main switch on first and then spend two minutes adding segment rules, then for those two minutes every user can see the feature. Building the safe configuration first and switching on last avoids that window. It is the same habit as plugging in an appliance only after it is assembled.
A pilot never takes off and then reads the checklist. The checklist is completed on the ground, item by item, with the engines off. Setting up a flag with the switch off, then enabling it at the end, is the same discipline: all the checking happens while nothing can go wrong in the air.
Keep a short, shared promotion note for each release listing the flags, their intended Production state and the person who will verify them. It takes five minutes and prevents the classic “I thought you were doing that” mistake.
Where manual promotion breaks down
The method works until the number of flags grows. Copying three flags is an easy afternoon. Copying forty is an invitation for typing errors, forgotten segments and tired eyes. Manual work also leaves no machine-readable record of intent, so two people may follow slightly different routines. When you notice yourself saying “I’ll just do it quickly” about a Production change, that is the signal to move to a more structured method from the next chapters.
7Method 2: Comparing Environments to Find Drift
Before you change anything, it helps to see exactly how two environments differ. That view turns promotion from a guess into a checklist.
What is configuration drift?
Configuration drift is the slow, unplanned difference that grows between environments over time. Someone turns a flag on in Staging for a demo and forgets it. Someone edits a value in Production during an incident and never copies the change back. After a few months, nobody can say with confidence what Staging proves about Production. Drift is dangerous because it quietly weakens the main reason you have Staging at all.
How comparison helps
Flagsmith provides comparison tooling in the dashboard that lets you place two environments side by side and see which features differ in their enabled position or value. Depending on your version, you may also see differences in segment overrides. Treat this screen as a map. Green areas, where both sides agree, need no work. Highlighted rows show the places where promotion would change something.
Choose a source and a target
Typically Staging as the source and Production as the target. For a full release train, repeat the comparison between each neighbouring pair of rungs on the ladder.
Sort differences into three buckets
Intended differences that you are about to promote, accidental differences that need investigation, and permanent differences that should always exist, such as a test payment address.
Promote only the first bucket
Apply the intended changes using whichever method fits. Leave permanent differences alone and write them down so nobody “fixes” them later.
Investigate the second bucket
Use the audit log to find who changed an unexpected flag and why. A surprising difference is often the first sign of a process gap.
Compare again after the change
Repeat the comparison. If the only remaining differences are the permanent ones, the promotion is complete.
Pros of comparing first
- Shows exactly what will change before it changes
- Catches forgotten flags and leftover test settings
- Builds a shared picture for the whole team
- Costs only a few minutes
Cons and limits
- It shows differences, it does not copy them for you
- Coverage of overrides can vary by version
- Intended and accidental differences look identical on screen
- Needs a person who understands the context
Real-world example: a release-day habit
Teams that ship many times a day, a practice Amazon has described publicly for years, cannot afford long manual reviews before every deployment. What they do instead is keep environments close together all the time, so that the comparison on release day is short and boring. A short, boring comparison is the goal, and it is the sign of a healthy promotion process.
A comparison that shows no differences is not proof of safety. It only says two environments are alike. If Staging itself is wrong, a perfect match carries the wrong answer into Production faithfully.
8Method 3: Cloning an Environment
Sometimes you do not need to move one flag. You need an entire new environment that starts life looking like an existing one.
What is cloning?
Cloning means creating a new environment and asking Flagsmith to copy the contents of an existing environment into it. The new environment gets its own fresh keys, but it begins with the same feature states and segment overrides as the original. You then adjust whatever needs to differ. Check your version’s documentation for exactly which items are copied, because identity overrides in particular may or may not be included.
When cloning is the right tool
A fresh Staging
Staging has drifted so far that nobody trusts it. Clone Production into a new Staging environment and you have an honest rehearsal space again.
Preview environments
Create a short-lived environment for one feature branch or one customer demo, then delete it when finished.
Regional rollouts
A new country or data centre needs the same setup as an existing one, with a few local values changed.
Load or security testing
Give a specialist team their own copy so their experiments cannot disturb the shared Staging.
Cloning is like photocopying a filled-in form onto a fresh sheet. You get all the answers on the new page instantly, but the new page is a separate sheet with its own reference number. If you then cross out an answer on the copy, the original is not affected. The risk is that you copy answers that should have been different for the new page, so you must still read it through before using it.
Things to fix straight after cloning
Replace environment-specific values
Web addresses, partner account names, sandbox versus live payment settings and any limit tied to scale. A cloned Staging that points at live payment values is a serious mistake.
Point your apps at the new keys
The clone has its own client-side and server-side keys. Nothing uses them until you configure your application to do so.
Set permissions
Decide who may edit the new environment. Do not assume permissions were copied exactly as you expect.
Reconnect integrations and webhooks
Notification hooks, analytics connections and chat alerts belong to environments, so check that the new one talks to the right places and does not spam production channels.
Cloning is a starting point, not a promotion pipeline. It is brilliant for births of environments and clumsy for the weekly release, because it creates something new instead of updating something that already exists.
9Method 4: Change Requests, Approvals and Scheduling
For Production, many organisations want a second pair of eyes and a clear record. Flagsmith offers a workflow for exactly that on its paid plans.
What is a change request?
A change request is a proposal to change a flag in an environment. Instead of saving the new state immediately, the editor submits it. A colleague with the right permission reviews the difference, then approves or rejects it. Only after approval does the change go live. The idea comes from code review, where nobody merges their own work unseen, applied to configuration instead of code.
sequenceDiagram
participant RO as Release Owner
participant FS as Flagsmith
participant RV as Reviewer
participant APP as Production App
RO->>FS: Propose new flag state for Production
FS->>RV: Notify that a change is waiting
RV->>FS: Inspect the difference and approve
FS->>FS: Apply now or wait for scheduled time
APP->>FS: Ask for current flags
FS-->>APP: Return updated state
Follow the arrows from top to bottom. The release owner proposes a new state, and Flagsmith holds it without applying it. A reviewer is notified, looks at exactly what would change and approves it. At that point Flagsmith applies the change immediately, or waits until a scheduled time you chose. From then on, whenever the live application asks for flags, it receives the new state. The production app never sees a half-reviewed change.
Scheduling
Scheduling lets you attach a date and time to an approved change. This is valuable for launches that must happen at a precise moment, such as the opening of a sale at midnight, when you would rather not have a person awake and nervous. It also helps global teams: the approval can happen during working hours while the switch happens at a quiet time for customers.
Four-eyes principle
No single person can quietly alter Production behaviour, which protects against both honest mistakes and bad intent.
Written reasons
Each request carries a title and description, so the history explains why a change happened, not only what.
Timed launches
Approved changes can wait for the exact moment of a campaign, a regional morning or a maintenance window.
Clear accountability
Requester, approver and applied time are all recorded, which supports audits and calm post-incident reviews.
Real-world example: regulated industries
Banks, insurers and health companies commonly require that changes affecting customers be approved by someone other than the author, whether the change is code or configuration. A flag that switches a loan calculation or a patient message is configuration with real consequences, so approval workflows on Production flags give these companies a way to keep the speed of flags while satisfying their auditors.
Pros
- Strong safety for the most sensitive environment
- Built-in audit trail without extra tooling
- Supports timed releases across time zones
Cons
- Slower for urgent fixes unless you plan an emergency route
- Requires a paid plan and a trained pool of reviewers
- Can become a rubber stamp if reviewers do not look carefully
Decide in advance how an emergency switch-off works. If every kill-switch needs approval and your only approver is asleep, the safety process itself becomes a risk. Many teams allow named on-call people to bypass review for switching a flag off, and then review that action afterwards.
10Method 5: Automation with the Admin API and Terraform
When flags number in the dozens or hundreds, human clicking stops being the safest path. Automation makes promotion boring, and boring is the best quality a release step can have.
What is an API?
An API, short for application programming interface, is a doorway that lets one program talk to another with agreed rules. Flagsmith has an Admin API, a set of doors designed for management tasks rather than for end-user flag lookups. Anything you can do by clicking in the dashboard, such as reading a flag’s state in one environment or changing it in another, can in principle be done by a script calling this API. You need a secure token that proves the script is allowed to do so.
What is infrastructure as code, and where does Terraform fit?
Infrastructure as code means describing your systems in text files that are stored, reviewed and versioned like software. Terraform is a widely used tool for this. A Terraform provider exists for Flagsmith, which means you can describe projects, environments and feature states in files, then let Terraform make reality match the description. Check the current provider documentation to see which resources it supports in your version.
Clicking through the dashboard is like cooking from memory: it works, but each cook makes the dish slightly differently. Terraform is a written recipe that any cook follows to the gram. Because the recipe is a text file, you can read it before cooking, ask a friend to check it, and keep every old version in case you need to go back.
flowchart LR
A["Engineer proposes flag change in a file"] --> B["Peer review of the change"]
B --> C["Automated checks run"]
C --> D["Apply to Staging environment"]
D --> E["Verification tests pass"]
E --> F["Apply to Production through approval gate"]
F --> G["Audit log and webhook alert the team"]
The pipeline in the figure starts with a text change proposed by an engineer. A colleague reviews it exactly as they would review code. Automated checks then look for obvious mistakes, such as a flag named in the wrong style. The change is first applied to Staging, where tests confirm the behaviour. Only then is it applied to Production, and even there it passes through an approval gate. The final step records the change and alerts the team, so nobody is surprised.
Why automation improves safety
Same steps every time
A script does not forget the segment order or mistype a percentage on a tired Friday afternoon.
Many flags in one pass
Moving forty flags takes the same effort as moving four, and it finishes in seconds.
Changes live in version control
Every promotion is a visible, reversible commit with an author and a reason.
Dry runs before real runs
You can preview what a plan would change, much like the compare view, before anything is applied.
Designing a promotion script wisely
Read first, write second
Have the script fetch both environments and print the planned differences. Only proceed on an explicit confirmation or a passing check.
Use an allow list of flags
List the flags that may be promoted in this release by name. A script that promotes “everything that differs” will one day promote a half-finished experiment.
Skip what must never be copied
Exclude identity overrides and environment-specific values by design, and make the exclusions visible in the script’s output.
Protect the token
Store the Admin API token in your pipeline’s secret store, scope it to the least access needed, and rotate it on a schedule.
Make it safe to run twice
Good automation is idempotent, meaning running it again produces the same end state instead of doubling the changes.
Start small. Automate the read-only comparison first, so the team sees the value without any risk. Add writing to Staging next. Only after months of calm results should the same automation touch Production, and even then behind an approval gate.
11Segments, Overrides and Identity Overrides Across Environments
Targeting rules are where promotion gets subtle. The same rule can mean very different things in two environments, because the people inside them are different.
Segments: defined once, applied separately
A segment is a saved description of a group of users, built from rules about their traits. For example, “plan equals premium and country equals India” is a segment. Segments are defined at the project level, so the same definition is available in every environment. That is helpful, because the rule means the same thing everywhere. What differs is which flags use the segment in which environment, and what each override says.
Imagine a segment called “Internal Staff”. In Staging it might give early access to the new checkout to every employee. In Production you may want the same segment to see the feature first, as a safe first audience. Here the segment and the intent carry over neatly. But consider a segment called “Beta Testers”. In Staging it may include dozens of synthetic test users. In Production it might include only a handful of volunteers. The rule is identical, but the audience size and risk are not.
Segment override priority
A flag can have several segment overrides, and a single user can belong to more than one segment. Flagsmith decides which override wins by looking at the order of the list, with the top entry taking priority. This is similar to a set of rules at a building entrance: the guard checks the first rule, and if it applies, stops there. If you rebuild the list in a different order in the target environment, users in two overlapping segments may suddenly see different behaviour.
An airport security line has several fast lanes: crew, families with small children, premium tickets. A premium traveller who is also a parent could use two of them. The airport settles it with a written priority: the first lane that applies is the one used. If one airport copies the lanes but shuffles the priority list, the same traveller walks a different path. Promotion of segment overrides is the same, and order is part of the rule.
Identity overrides
An identity override gives one specific user a special answer regardless of other rules. It is the sharpest tool in the box, useful for letting a support agent preview a feature on a real account, or for excluding a troublesome customer. Because identities are usually unique to each environment, identity overrides rarely make sense to promote. The identifier “user-8841” in Staging might not exist in Production, or worse, might belong to a different real person.
| Piece | Defined where | Usually promoted? | Why |
|---|---|---|---|
| Segment definition | Project | Already shared | One definition serves every environment |
| Segment override on a flag | Environment | Often yes | Describes the release plan for that audience |
| Override priority order | Environment | Yes, check it | Order changes who sees what |
| Identity override | Environment | Rarely | People differ between environments |
| Remote value | Environment | With care | May hold environment-specific details |
Never copy identity overrides to Production automatically. A leftover override in Production for an old test account can expose unreleased features to a stranger, or hide a feature from a real customer, and nobody will notice until a complaint arrives.
Real-world example: staff first
GitHub engineers have publicly described a habit of releasing changes to employees first, then to a growing percentage of users. In flag terms, this is a segment override for staff placed at the top of the priority list, followed by progressively wider overrides. When you promote such a flag, the order of the list is as much a part of the plan as the flag’s on or off position.
12Multivariate Flags and Percentage Rollouts
Not every flag is a simple switch. Some choose between several options, and some reveal a feature to only a slice of users. Both need special attention during promotion.
What is a multivariate flag?
A multivariate flag has more than two possible results, called variants. A button might be blue, green or orange. A recommendation engine might use algorithm A or algorithm B. Each variant gets a percentage, and together they add up to one hundred. Flagsmith assigns each user to a variant using a stable calculation based on their identity, so the same user keeps seeing the same variant visit after visit. That stability matters, because a button that changes colour on every page load would ruin both the experience and the experiment.
What is a percentage rollout?
A percentage rollout is a segment-style rule that includes a fixed share of users, such as five percent. Because the assignment is stable, the five percent who see the feature today are a subset of the twenty-five percent who see it next week. People do not flicker in and out as you widen the audience, which is exactly what you want.
How to promote percentages sensibly
When you copy a multivariate allocation from Staging to Production, resist the urge to copy the final numbers straight over. In Staging, a flag at one hundred percent is normal, because your testers need to see it. In Production the same flag should start at the smallest sensible percentage and climb in steps. The promotion is the same flag with a different, more cautious starting point.
Internal audience first
Production enabled only for the staff segment. Everyone else still sees the old behaviour.
One percent of customers
Watch error rates, speed and support messages for a full working day. Expect nothing dramatic and be pleasantly bored.
Five, then twenty-five percent
Compare business metrics between users who see the feature and those who do not.
Fifty percent, then everyone
Only widen when each earlier step behaved as expected. Pause immediately if a metric moves the wrong way.
Retire the flag
Once the feature is permanent, remove the flag and its old code path so the system does not collect dead switches.
A chef launching a new dish does not serve it to the whole restaurant on the first night. First the kitchen staff taste it. Then it is offered to one table, then to a section, and only later does it join the printed menu. Each step collects feedback while the cost of a mistake is still small, and it is easy to take the dish off again.
Real-world example: Netflix and careful rollouts
Netflix has talked publicly about rolling out changes gradually and measuring their effect before widening them, and about running controlled experiments on the user interface. Assigning users to groups consistently and expanding in steps is the same mechanism that multivariate flags and percentage rollouts provide in Flagsmith.
When an experiment is running, avoid editing the variant percentages halfway through. Changing the split mid-test moves users between groups and muddies the results. Plan the numbers first, promote them once, and then leave them alone until the test ends.
13A Safe End-to-End Promotion Workflow
Everything so far comes together here: one repeatable path a team can follow from first idea to retired flag.
flowchart TD
A["Create flag in project"] --> B["Configure in Development and test"]
B --> C{"Works as planned?"}
C -- "No" --> B
C -- "Yes" --> D["Deploy code to Staging"]
D --> E["Promote settings to Staging"]
E --> F{"QA and checks pass?"}
F -- "No" --> B
F -- "Yes" --> G["Deploy code to Production with flag off"]
G --> H["Compare Staging and Production"]
H --> I["Submit change request for Production"]
I --> J["Approved and applied to small audience"]
J --> K{"Metrics healthy?"}
K -- "No" --> L["Switch off and investigate"]
K -- "Yes" --> M["Widen audience in steps"]
M --> N["Reach everyone"]
N --> O["Remove the flag and old code"]
Trace the figure from the top. The flag is created once in the project and configured in Development. Two diamond-shaped questions follow: does it work as planned, and do the checks in Staging pass? A “no” in either place sends the work back to the beginning, which is cheap. After Staging, the code is deployed to Production with the flag still off, so the new code path exists but nobody can reach it. A comparison and a change request then introduce the flag to a small audience. A third question asks whether the metrics look healthy. If they do not, the flag goes off immediately. If they do, the audience widens in steps until everyone has the feature, and finally the flag and its old code are removed.
The deployment-before-release rule
Notice that the code reaches Production before the flag is switched on there. This ordering matters. It means deployment risk, such as a build problem or a missing database change, is separated from release risk, such as a confusing screen. If something breaks after deployment with the flag off, you know the cause is the deployment. If it breaks after the flag goes on, the cause is the feature. Separating the two makes diagnosis fast.
The pre-promotion checklist
Code is present
The target environment runs the build that reads this flag.
Dependencies are ready
Database changes, partner services and other flags this feature relies on are already in place.
Values are reviewed
No test addresses, sandbox accounts or placeholder text will reach real users.
Audience is chosen
The first exposure is small, named and agreed with the feature owner.
Rollback is clear
Everyone knows who can switch it off and how long that takes to reach users.
Watchers are named
Someone is assigned to watch dashboards and support channels after the change.
Dependent flags deserve a special look. If flag B only makes sense when flag A is on, promote A first and verify it before touching B. Write dependencies in the flag’s description so the next person does not discover them by accident.
14Security, Permissions and the Audit Trail
A flag in Production can change what real customers see in seconds. That power deserves the same protection as a deployment key.
Roles and permissions
Flagsmith lets you control who can do what, at the organisation, project and environment levels. A sensible setup lets many people view flags, a smaller group edit them in lower environments, and only a few named people change Production. On plans that support it, you can also set permissions per environment so that a developer who edits Development freely has read-only access to Production. This is the principle of least privilege: each person gets only the power their job needs.
Organisation
Who can invite members, manage billing and create projects.
Project
Who can create flags, define segments and view the project’s settings.
Environment
Who can change flag states, identities and approvals in each stage.
Machine access
API tokens for scripts and pipelines, scoped as narrowly as possible.
Protecting keys and tokens
Two kinds of secrets matter. The server-side environment key lets backend services read flags and, in local evaluation mode, the full rule set. The Admin API token allows management actions. Store both in a secrets manager, never in source code. Give each environment its own pipeline credentials, so a leak in Staging cannot become a Production incident. Rotate them on a schedule and immediately after any suspected exposure.
The audit log
An audit log is a diary kept by the system that records who changed what and when. Flagsmith keeps one for flag changes, so you can answer the questions that always come after a surprise: who turned this on, at what time, from which state to which state. It is the first place to look when a comparison between two environments reveals something nobody expected.
A bank vault has a lock, a guard and a logbook. The lock is your keys, the guard is your permissions and approvals, and the logbook is the audit trail. Removing any one of the three weakens the others. A lock without a logbook cannot tell you what happened. A logbook without a lock only records that things went wrong.
Good habits
- Few people can edit Production
- Separate credentials for each environment
- Short comments on every Production change
- Regular review of who holds access
Risky habits
- Shared logins used by the whole team
- Admin tokens stored in chat messages
- Production editing rights given “just in case”
- No review when a team member leaves
Flag values are visible to client-side apps. Never store secrets, passwords or private personal data in a remote value that a browser or mobile app can read. Anything a client can read, a determined user can read too.
15How Fast Changes Arrive, and How to Watch Them
Saving a flag in the dashboard is not the same as every user seeing it. Understanding the delay, and watching for trouble, completes the promotion.
Why changes are not instant
Between the dashboard and a user’s screen sit several layers that store recent answers to avoid asking the same question again and again. Your application may keep flags in its own memory for a short time. Client SDKs may cache results on the device. Server SDKs in local evaluation mode download the rule set and refresh it on a timer, often around once a minute by default. Any content delivery network or proxy in front of Flagsmith may hold answers briefly too. The sum of these delays is the time from saving a change to the last user seeing it.
Changing a road sign in a city does not instantly change every driver’s behaviour. Drivers on a familiar route keep following habit until they notice the new sign. Some notice in seconds, some after a week. Caches are the digital version of habit, and they are why you should plan for a short period when old and new behaviour coexist.
Planning around the delay
Know your own refresh settings
Check how long each SDK in your system caches flags, and write the numbers in your runbook.
Wait before judging
After a change, allow at least one full refresh period before concluding that the flag has no effect, or that it has broken something.
Design for both states
Your code should behave safely when some servers see the old value and others the new one for a short time.
Set safe defaults
If Flagsmith cannot be reached at all, your SDK should fall back to a default that is safe for users, which is usually the old behaviour.
What to monitor after promotion
Monitoring means watching measurements that tell you whether a system is healthy. After a flag changes in Production, the most useful measurements are the ones tied to the feature: error rates, response times, successful completions of the journey the flag affects, and any rise in support contacts. Compare the group seeing the new feature against the group not seeing it, because overall averages hide small groups.
Errors and speed
Watch error counts and response times for the specific pages or services behind the flag.
Business results
Track sign-ups, purchases or completions, split by who sees the feature.
Audit and webhooks
Use the audit log and change notifications to post flag changes into your team chat and your monitoring timeline.
Annotations on graphs
Where your monitoring tool allows it, mark each flag change on the charts so cause and effect line up visually.
Real-world example: Google and live experiments
Google has described in public research that its search and ads teams run very large numbers of live experiments, with changes exposed to slices of traffic and measured carefully before wider release. The essential habit is the same one this chapter recommends: change something small, watch the right numbers, and widen only when the evidence supports it.
Send flag change events to the same place where your team already watches graphs. A vertical line labelled “checkout flag set to 5 percent” on an error chart turns a mystery into a one-minute diagnosis.
16A Worked Example: Promoting a Checkout Flag
Theory is easier to trust when you watch it work. Here is one made-up team taking one flag all the way to customers.
Meet BrightCart, an imaginary online shop. Its developers have built a redesigned checkout page and wrapped it in a flag called new-checkout. The flag has a simple on and off position, plus a remote value called payment_mode that tells the page whether to talk to a practice payment system or the real one. BrightCart’s Flagsmith project has three environments: Development, Staging and Production.
Create the flag once
A developer creates new-checkout in the project, adds a description that names the owner, and tags it as a release flag. It now exists in all three environments, switched off everywhere.
Experiment in Development
In Development the flag is on, and payment_mode is set to practice. Developers flip it repeatedly while building. Nobody cares about order or audience here.
Rehearse in Staging
The release owner sets the flag on in Staging, keeps payment_mode as practice, and adds a segment override for the internal staff segment placed at the top of the list. Testers walk through ten shopping journeys. Two bugs appear and are fixed in code, and the flag stays on throughout.
Deploy the code to Production with the flag off
The new build, containing the redesigned page, goes live. The flag is still off in Production, so customers see no change. The team watches error graphs for an hour to confirm the deployment itself is healthy.
Compare Staging and Production
The comparison shows three differences: the enabled position, the staff segment override, and payment_mode. The team writes beside each one what is intended. Enabled position and staff override will be promoted. The payment value will be set deliberately to live, not copied from Staging.
Submit a change request
The release owner proposes the Production state: flag on only for the staff segment, payment_mode set to live. A second engineer reads the difference, notices the value is correct, and approves it.
Staff-only exposure
After one refresh period, employees see the new checkout in Production. They place real orders with real cards, then refund themselves. All is well, and support sees no surprises.
One percent, then five, then everyone
Each step is its own approved change. At five percent, the team notices a slightly slower page for users on older phones. They pause, fix a heavy image, and continue. Five days later, every customer has the new checkout.
Clean up
Two weeks later, with no complaints, a developer removes the old checkout code and the new-checkout flag. The project is tidier, and nobody has to remember what the flag used to do.
Look at step five again. The team did not copy the payment value. They set it by hand to a different number on purpose. That is the single habit that separates careful promotion from copy and paste: knowing which pieces must differ.
What would have gone wrong without the routine?
Suppose the team had skipped the comparison and simply cloned the Staging settings. The flag would have gone on for every customer immediately, and payment_mode would have stayed on practice. Customers would have completed checkouts that looked successful but never charged a card, and the shop would have shipped free goods until someone noticed. The routine described above is not bureaucracy. It is the shortest path around that kind of story.
17Advantages, Disadvantages and Trade-offs
Separate environments with careful promotion bring clear benefits and real costs. Knowing both helps you choose the right amount of process.
Advantages
- Risk is contained: a mistake in Staging never touches customers
- Releases become reversible, because a switch is faster than a redeploy
- Code can be deployed early and released at the best business moment
- Gradual exposure shows problems while few users are affected
- Different teams can work in parallel without waiting on each other
- History and approvals make audits much easier
Disadvantages
- More environments mean more settings to keep aligned
- Drift creeps in silently without regular comparison
- Old flags pile up as hidden complexity if nobody removes them
- Each flag doubles the number of code paths that need testing
- Approval steps can slow urgent changes
- Caches mean changes are not instant everywhere
Choosing how much process you need
There is no single right amount of ceremony. A three-person start-up with ten flags can happily promote by hand with a shared checklist. A company with hundreds of engineers and strict audit duties needs approvals, automation and permissions. The danger lies at both ends: too little process creates incidents, and too much process teaches people to bypass the system. A useful rule of thumb is to add structure only where a mistake would be costly, and to leave lower environments light and fast.
| Team situation | Suggested approach | Reason |
|---|---|---|
| Small team, few flags | Manual promotion with a checklist | Low overhead and easy to understand |
| Growing team, weekly releases | Compare view plus a release note | Catches drift cheaply |
| Larger team, customer-facing risk | Change requests for Production | Second review where it matters most |
| Many flags, many services | Admin API or Terraform in a pipeline | Consistency and speed at scale |
| Regulated industry | Approvals, scheduling, tight permissions and audit review | Evidence for auditors |
A household needs a lock on the front door, but not a security guard. A bank needs both. Matching protection to what is being protected is not laziness. It is how you keep a process people actually follow, which is always safer than a perfect process people ignore.
18Design Patterns and Anti-patterns
Flags come in a few well-known shapes. Recognising the shape tells you how long the flag should live and how carefully it should be promoted.
Release flag
Hides unfinished or newly finished work until you choose to reveal it. Short-lived. Promote in small steps and remove after full rollout.
Kill switch
A permanent flag that lets you turn a risky or expensive feature off quickly during trouble. Keep it on by default and protect the off action carefully.
Experiment flag
Splits users into groups to compare outcomes. Medium-lived. Promote percentages once and leave them alone during the test.
Entitlement flag
Controls which customers have access to paid features. Long-lived. Treat changes like product decisions, since they affect revenue.
Operational flag
Adjusts behaviour such as batch sizes, timeouts or maintenance modes. Often stored as remote values that differ by environment on purpose.
Dark launch
Runs new code on real traffic without showing results to users, so you can measure load and correctness before any visible change.
Anti-patterns to avoid
An anti-pattern is a common habit that looks reasonable but causes harm over time. Each box below describes one, explains the damage and suggests a better route.
What it looks like
Someone copies every flag setting, including values and overrides, from Staging to Production in one sweep, because it feels faster than thinking about each one.
Why it hurts
Staging holds test values, test users and half-finished experiments. Copying all of it can expose unfinished features or point live traffic at practice systems.
Do this instead
Promote from an allow list, review each remote value by hand and leave identity overrides behind.
What it looks like
A release flag stays in the code for a year after the feature went to everyone, because nobody owns its removal.
Why it hurts
Every old flag keeps a dead code path alive, adds confusion for newcomers, and risks being toggled by accident with unexpected effects.
Do this instead
Give every flag an owner and a planned removal date, and add a cleanup task to the release checklist.
What it looks like
During an urgent problem, someone changes a Production flag directly and never repeats the change in lower environments.
Why it hurts
Staging stops resembling Production, so future rehearsals prove less and less. The hotfix is also forgotten and may be overwritten later.
Do this instead
Allow emergency edits, but require a follow-up entry the same day that brings the other environments back in line and records the reason.
What it looks like
A remote value holds a password, a private web address or personal data, because the flag system was convenient.
Why it hurts
Client-side apps can read values, and those values may be copied into logs, caches and screenshots across environments.
Do this instead
Keep secrets in a dedicated secrets manager and store only harmless settings in flag values.
What it looks like
Flag C only works if flag B is on, and flag B only works if flag A is on, but nobody wrote that down.
Why it hurts
Promoting them out of order produces strange half-working features that are very hard to diagnose.
Do this instead
Keep dependencies few, document them in descriptions, and promote in the documented order.
Real-world example: Amazon and small, frequent changes
Amazon has publicly reported deploying code extremely often, and engineers there have described the value of small, reversible changes over large, rare ones. Flags support that habit by letting a risky change be released slowly and withdrawn quickly. The anti-patterns above are mostly ways of accidentally turning those small, reversible changes back into large, scary ones.
19Best Practices, Common Mistakes and Troubleshooting
A short collection of habits that experienced teams share, followed by a guide for the moment when a promotion does not behave as expected.
Habits worth building
Name flags clearly and consistently
Choose a naming style, such as lowercase words with hyphens, and describe what the flag does, not who asked for it. “new-checkout” tells a story. “flag-17” does not.
Give every flag an owner and a purpose
Write both in the description. When something goes wrong at night, the on-call engineer needs to know whom to ask and what the flag protects.
Use tags to organise
Tag flags by team, feature area or type, such as release, experiment or kill switch. Tags make comparison and cleanup far easier.
Keep environments close
Run a comparison on a regular schedule, not only on release day. Small drift is easy to fix. Large drift is a project.
Write a short comment on every Production change
One sentence explaining why will save an hour of detective work later.
Rehearse the rollback
Practise switching a flag off in Staging, and measure how long it takes to reach users. A rollback you have never tried is a hope, not a plan.
Remove flags promptly
When a feature is permanent, delete the flag and the old code in the next release. Treat cleanup as part of finishing the feature, not as optional extra work.
If a promotion does not behave as expected
| Symptom | Likely cause | What to check |
|---|---|---|
| Flag is on in Production but users see nothing | Code not deployed, or a cache has not refreshed | Build version in Production and SDK refresh settings |
| Some users see it, others do not | A segment override or percentage rule is applying | Segment membership, priority order and user traits |
| Staging works but Production errors | Value differences or missing dependencies | Remote values, linked flags, partner services |
| A flag keeps changing by itself | A schedule or script is active | Scheduled changes, pipelines and the audit log |
| Wrong environment affected | App configured with the wrong key | Which environment key each deployed app uses |
| One tester sees something different | An identity override exists | Identity overrides for that user |
When debugging, change one thing at a time and record each change in the audit comment. Flipping several settings at once may cure the problem but leaves you unable to say which change fixed it, and the problem will return.
20Designing Your Project and Environment Layout
Promotion is much easier when the layout underneath it is sensible. A few decisions made early can save months of confusion later.
One project or many?
The first decision is how to divide your work into projects. A project in Flagsmith is a shared pool of flags and segments, so everything inside it can see the same names and the same audience rules. If one product is built by several teams who all need the same segments, such as “paying customers” or “internal staff”, a single project keeps those definitions in one place. If your company runs several quite separate products, each with its own users and its own release rhythm, separate projects stop their flags from cluttering each other’s lists.
A useful question to ask is: would these two systems ever want to share a segment or a flag? If the answer is yes, they probably belong together. If the answer is no, and mixing them would only make the flag list longer and more confusing, give each its own project. Companies with many autonomous teams, such as the squad model Spotify has publicly described, often lean towards one project per product area so each team can move at its own speed without tripping over the others.
How many environments?
Start with as few as your risk allows. Two environments, one for building and one for customers, is a respectable beginning. Add a Staging environment when you find that changes behave differently on real infrastructure than on laptops. Add further stages only when a specific group needs its own space, such as a dedicated test environment for a partner integration or a regulated sign-off stage. Every extra environment is another place for settings to drift, so each one should earn its keep.
A filing cabinet works best when the drawers match how you actually look for things. One drawer per customer is useful if you serve a handful of customers. It is a nightmare if you have ten thousand. Likewise, one environment per purpose helps when the purposes are real. Making a new environment for every small whim fills the cabinet with folders nobody can find.
Naming that survives growth
Names are the cheapest form of documentation. Agree on a style for environments, projects, segments and flags before you have fifty of each. Environment names should say what they are for, such as Development, Staging and Production, not whose they are or when they were made. Segment names should describe the group in business words, such as “internal-staff” or “trial-customers”, not the rule used to build it, because rules change and names stick. Flag names should describe the behaviour being controlled, written the same way every time.
Use the same names everywhere
A flag called one thing in the code, another in the dashboard and a third in the ticket creates mistakes at exactly the wrong moment.
Describe the behaviour
Names such as “express-checkout” explain themselves. Names such as “test2” or “johns-flag” do not.
Keep a consistent style
Pick lowercase with hyphens or underscores and stay with it. Mixed styles slow everyone down when searching.
Avoid dates and names in labels
A date in a name is wrong the next month, and a person’s name is wrong the day they change teams.
Regional and customer-specific environments
Some businesses need environments for different regions, for different legal regimes or for large customers with special arrangements. These are sometimes necessary, but they multiply the promotion work, because each regional Production now needs the same careful steps. Before creating them, ask whether a segment based on region or customer would do the same job inside a single Production environment. Segments are lighter, easier to promote and easier to remove. Create separate environments only when the data, the keys or the legal boundaries truly have to be separate.
Write a one-page “how we use Flagsmith” note covering project layout, environment purposes, naming rules and who owns what. Share it in your team’s onboarding. It is the cheapest guard against slow, accidental disorder.
21Testing Flagged Code and Testing the Promotion Itself
A flag creates two versions of your application in one build. Both must work, and so must the act of switching between them.
Two doors, two tests
Every flag turns a single path through your code into a fork. When the flag is off, users take the old path. When it is on, they take the new one. A common and costly mistake is to test only the new path, because it is the exciting one. The old path matters just as much, since it is the one customers rely on until the release is complete and the one they fall back to if you switch the flag off during trouble.
A shop with a new entrance still needs the old door to be safe and unlocked until the grand opening. If staff only practise using the new door, the first customer through the old one may find it jammed. Test both doors, and test the moment of switching from one to the other.
Layers of testing
Unit tests with the flag in both positions
Small, fast tests that run the code once with the flag on and once with it off. They prove that each path works by itself without needing a live Flagsmith.
Integration tests against a test environment
Tests that talk to a real Flagsmith environment dedicated to automated testing. They confirm that the application reads the flag correctly and respects segment rules.
Journey tests in Staging
Whole-user-journey checks, such as browsing, adding to a basket and paying, run with the flag in the state planned for Production.
Smoke tests after promotion
A short, quick check run straight after a Production change, confirming that the most important journey still works for a test identity in the target audience.
Fallback tests
Tests that simulate Flagsmith being unreachable and confirm that your application falls back to the safe default instead of failing.
The explosion of combinations
One flag gives two paths. Two flags give four. Ten flags give over a thousand combinations. Nobody tests every combination, and nobody should try. Instead, keep flags independent wherever possible, test each in isolation, and test explicitly the few combinations that are likely to meet in Production. This is one more reason to remove old flags quickly: every retired flag cuts the number of possible worlds in half.
Testing the promotion, not only the feature
The feature may work perfectly and the promotion may still be wrong. A segment may have been given the wrong priority. A value may have been copied that should have differed. The wrong audience percentage may have been typed. To catch these, create a small set of test identities that represent each audience, such as a staff member, a trial customer and a regular customer, and check what each one receives in the target environment after every promotion. Doing this takes minutes and catches an entire class of errors that feature tests never see.
Real-world example: trunk-based development
Many large engineering organisations, including Google as it has described in public talks, keep their code on one main line and hide unfinished work behind switches instead of long-lived branches. This only works when tests cover both sides of each switch. The lesson for any team using Flagsmith is the same: a flag is a promise that both worlds are tested, not a way to avoid testing.
Do not let automated tests share an environment with human testers. A tester who flips a flag in the middle of a test run will cause failures that look like bugs and are not. Give automation its own environment, and protect its flag states from casual edits.
22Rollback and Incident Response
One of the greatest gifts of feature flags is the ability to undo a release in moments. That gift is only useful if the team has practised unwrapping it.
What is a rollback?
A rollback means returning a system to a previous, known-good state after a change causes trouble. In traditional releases, this meant deploying the old code again, which could take many minutes or hours. With a flag, the old behaviour is still sitting in the code, so rolling back is a matter of switching the flag. The result reaches users within the refresh period of your SDKs, which is usually seconds to a minute or so, as discussed earlier.
Rollback or roll forward?
Sometimes the best answer is not to undo the change but to fix it quickly and continue. This is called rolling forward. A small, obvious defect with a certain, tested fix may be faster to patch than to withdraw. But when the cause is unclear, customers are affected and the stakes are high, switching the flag off is almost always the safer first move. It buys time. Investigation can then happen calmly, without customers paying for every minute of thought.
flowchart TD
A["Alert: error rate or complaints rising"] --> B{"Started after a flag change?"}
B -- "Yes" --> C["Switch the flag off or reduce its audience"]
B -- "No" --> D["Use the normal incident process"]
C --> E["Wait one refresh period"]
E --> F{"Metrics recovering?"}
F -- "Yes" --> G["Record cause and plan the fix"]
F -- "No" --> D
G --> H["Repeat the change in lower environments"]
H --> I["Review and update the runbook"]
Read the figure from the alert at the top. The first question is whether the trouble began just after a flag change. The audit log answers this in seconds. If yes, the fastest safe move is to switch the flag off or shrink its audience. After waiting for one refresh period, check whether the measurements recover. If they do, the team records the cause and plans a proper fix. If they do not, the flag was not the culprit, and the team continues with the ordinary incident process. At the end, the change is reproduced in lower environments and the runbook is improved so the next incident is easier.
What a good runbook contains
People with authority
The named on-call engineers who may switch Production flags off without waiting for approval.
Exact location
Which project and environment to open, and how to tell Production from Staging at a glance.
Expected delay
The time from saving a change to users seeing it, measured for each SDK your system uses.
Follow-up steps
Announce the change, record it in the audit comment, and open a ticket for the permanent fix.
A building has a fire alarm and marked exits, not because fires are common, but because deciding where the exits are during a fire is far too late. A flag kill switch is an exit. Its value comes from the fact that everyone already knows where it is and that it opens without needing someone’s permission.
Switching off is good when
- The problem started right after a flag change
- The old code path is known to be healthy
- Customers are affected and the cause is uncertain
Think twice when
- The new feature has already changed stored data in ways the old path cannot read
- Other flags depend on this one
- The old path is itself the source of the problem
A flag cannot undo a change to stored data. If the new feature has written records in a new format, switching it off may leave the old code unable to read them. Plan data changes so both old and new code can read them for a while, and only then rely on the flag as your safety net.
23Flag Lifecycle and Governance
Flags are cheap to create and easy to forget. Without a lifecycle, they pile up like unopened mail, and every pile hides a few things that matter.
What is flag debt?
Flag debt is the accumulated cost of flags that have outlived their purpose. Each one keeps an unused code path alive, adds a decision to every future change and invites someone to flip it by accident. A project with two hundred flags, of which only thirty are still doing real work, is slower to understand, slower to test and riskier to change. Like financial debt, a little is normal, and a lot becomes crippling.
The lifecycle of a typical flag
Proposed
The idea is agreed. An owner is named, the purpose is written down and a planned removal date is chosen.
Active in development
The flag is created, wired into code and tested in the lower environments.
Rolling out
The flag is promoted to Production and its audience widened in steps, under watch.
Fully released
Everyone has the feature. This is the moment the clock for removal starts, not the moment of celebration.
Stale
The flag has been at one value for everyone for longer than agreed. It should be flagged for cleanup, for example with a tag created for that purpose.
Removed
The code for the losing path and the flag itself are deleted in the same change, and the flag is archived or deleted in Flagsmith.
Governance in plain words
Governance simply means agreed rules about who may do what, and how the group checks that the rules are followed. For flags, the useful rules are few. Every flag has an owner. Every flag has a purpose and an expected lifetime. Production changes are made by named people or through approval. Stale flags are reviewed on a regular schedule, perhaps monthly or at the end of each release cycle. A short review meeting with the list of long-lived and stale flags is often enough to keep the project healthy.
| Flag type | Expected lifetime | Review rhythm | Removal rule |
|---|---|---|---|
| Release flag | Days to weeks | Weekly during rollout | Remove soon after full release |
| Experiment flag | Weeks to a few months | At the end of each experiment | Remove when the winner is chosen |
| Kill switch | Long-lived by design | Quarterly check that it still works | Remove only if the feature itself is retired |
| Entitlement flag | Long-lived | With each pricing change | Remove when the plan structure changes |
| Operational flag | Long-lived | Twice a year | Review whether a permanent setting would be simpler |
Real-world example: keeping the list short
Engineering teams at companies such as Facebook have publicly described the importance of cleaning up experiment and release switches once their job is done, because leftover switches make systems harder to reason about. The same habit applies at any scale. The healthiest flag lists are short, current and boring.
Add flag removal to your definition of done. A feature is not finished when it reaches everyone. It is finished when the scaffolding around it has come down.
24Performance and Scale Considerations
At small scale, nobody asks how flags are delivered. At large scale, it is one of the first questions, because every request may need an answer.
How applications get their flags
There are two broad ways for an application to learn a flag’s value. In the first, the application asks Flagsmith each time it needs an answer, or at the start of each user session, and Flagsmith replies. In the second, a backend service downloads the whole set of rules for its environment from time to time and evaluates flags locally, in its own memory. The first is simple and always fresh. The second is extremely fast and keeps working even if the network to Flagsmith is briefly interrupted, at the cost of a short delay before changes arrive.
Asking Flagsmith every time is like phoning reception each time you want to know if the pool is open. Local evaluation is like reading the notice board in the lobby, which is updated every few minutes. The phone call is always correct, but a hundred guests phoning at once will overwhelm the desk. The notice board serves everyone instantly and rarely lags behind by more than a moment.
Habits that keep flags fast
Ask once per request
Read the flags you need at the start of handling a request and reuse the answers, instead of asking inside loops or deep helper functions.
Cache sensibly
Use the caching built into the SDK, and set refresh periods that match how quickly you truly need changes.
Keep identities lean
Send only the traits that segment rules truly use. Large bundles of traits slow every call and increase the data you hold.
Plan for failure
Set defaults for every flag in code so the application behaves safely when the flag service cannot be reached.
Thinking about millions of requests
Suppose your shop serves one thousand requests every second, and each request needs the value of three flags. If every request called out to a flag service, that would be three thousand extra calls every second, each adding delay. With local evaluation or good caching, the same traffic causes a small, steady trickle of refreshes, measured in a handful of calls per minute per server. The design choice is the difference between a flag system that disappears into the background and one that becomes a bottleneck during your busiest sale.
Large companies that serve enormous traffic, such as Netflix, have described building systems where configuration is pushed or cached close to where it is used so no single central service is asked each time. Flagsmith’s approach to local evaluation and its edge delivery options are meant for the same style of design, though the exact choices available depend on your edition, so confirm them in the current documentation.
Promotion and performance together
Promotion affects performance in an indirect way. When you widen a flag’s audience, you also widen the load on the new code path. A feature that behaves well for one percent of users may strain a database at fifty percent. This is why gradual steps matter. Each step is a small load test performed on real traffic, with the ability to retreat. Watch response times and resource use at each step, and treat a slowdown as a reason to pause, not as an annoyance to push through.
Do not put flag lookups inside tight loops or inside code that runs thousands of times per request. Even a very fast lookup becomes slow when repeated without need. Read the value once, hold it in a variable and reuse it.
25Growing a Promotion Practice, Step by Step
Nobody starts with automated pipelines and approval gates. Good practice grows in stages, each one earned by a real need.
The maturity ladder
Teams tend to pass through recognisable stages as they adopt feature flags. Seeing the ladder helps you choose the next step instead of attempting the whole climb at once. Skipping rungs usually fails, because the habits of one stage are the foundation of the next.
| Stage | What it looks like | Next improvement |
|---|---|---|
| Beginner | Flags exist, but are flipped by whoever is nearby, in whichever environment is open | Write down the promotion routine and agree who edits Production |
| Developing | A checklist is followed and environments are compared before releases | Add naming rules, owners and a removal date to every flag |
| Established | Production changes need approval, and audit logs are reviewed after incidents | Connect flag changes to monitoring and chat alerts |
| Advanced | Comparison and promotion are scripted, with approval gates for Production | Measure flag age, cleanup speed and rollback time |
| Mature | Flag lifecycle, testing and incident practice are routine and boring | Share the practice and keep it simple |
Roles that help
Even small teams benefit from naming a few roles, though one person may hold several. The flag owner is accountable for a particular flag from creation to removal. The release owner coordinates what is promoted in each release. The reviewer approves Production changes and looks at the difference with fresh eyes. The on-call engineer holds the authority to switch flags off in an emergency. Writing these roles down removes the confusion of “I thought you were doing that”.
Flag owner
Knows why the flag exists, who it affects and when it should be removed.
Release owner
Builds the promotion list for each release and confirms it is complete afterwards.
Reviewer
Reads the difference in each proposed Production change and asks one useful question.
On-call engineer
Can use the kill switch immediately and records the action afterwards.
Learning to drive happens in stages. First you practise in an empty car park, then on quiet streets, then on busy roads, and eventually on the motorway. A beginner who is placed on the motorway on day one is not learning faster, only more dangerously. Promotion practice grows the same way: calm repetition in low-risk settings builds the skill you will need when stakes are high.
Measuring improvement
A few simple measures show whether your practice is getting better. Track how long it takes to roll out a flag from Staging to everyone in Production. Track how many flags are older than their planned removal date. Track how long a rollback takes from the moment someone decides to do it. Track how many Production flag changes were later reversed because they were wrong. None of these needs a special tool, and a monthly glance at them tells the team where to spend its next hour of improvement time.
Real-world example: practice builds calm
Amazon and Netflix have both spoken publicly about practising failure on purpose, through game days and chaos experiments, so that real incidents feel familiar. Rehearsing a flag rollback in Staging is the same idea at a gentler scale. A switch you have flipped a dozen times in practice is one you will flip without fear on the worst day of the year.
26Frequently Asked Questions
Short, direct answers to the questions people ask most often when they first plan flag promotion.
27Summary and Key Takeaways
Promoting a flag is a small act with large consequences. Treat it as a deliberate, repeatable routine and it quietly becomes one of the safest things your team does.
Key Takeaways
- Define once, configure many times. A flag’s definition lives in the project, but its state lives separately in every environment, so promotion means carrying decisions, not creating flags.
- Know the five pieces. Enabled position, remote value, multivariate split, segment overrides and identity overrides each need their own decision. Identity overrides and environment-specific values usually stay behind.
- Deploy first, release second. Put code in Production with the flag off, compare environments, then switch on for a small audience and widen in steps.
- Choose the method that matches the risk. Manual edits for small cases, comparison for visibility, cloning for new environments, change requests for sensitive Production changes and APIs or Terraform for scale.
- Protect Production. Limit edit rights, separate keys per environment, protect tokens, keep secrets out of values and rely on the audit log for accountability.
- Expect delay and watch the results. Caches mean changes are not instant, so wait one refresh period, monitor errors and business metrics and have a rehearsed way to switch off.
- Clean up after yourself. Give every flag an owner and a removal plan, and delete release flags once the feature is permanent.