Environment Cloning in Flagsmith

Environment Cloning in Flagsmith

A complete, plain-English guide to copying an entire set of feature flag settings into a brand-new environment: what gets copied, what stays behind, how it works inside, and how to do it safely at scale.

Imagine you spend two weeks setting up a new board game for your family. You write the rules, place every piece in the right spot, and decide which houses get which bonuses. Then your cousin says, “Can we play a second copy of the same game in the next room, but without touching your game?” You would not want to rebuild everything from zero. You would want to take a photo of the board and set up an identical one. That is exactly the idea behind environment cloning in Flagsmith.

Flagsmith is a tool that lets software teams turn features on and off without shipping new code. Those on and off switches are called feature flags. Teams keep different sets of switches for different stages of their work, such as development, testing and production. Each set lives in its own environment. When a team needs a new environment that starts life looking like an existing one, cloning is the fast, safe way to get there.

In this guide you will learn what environments are, what cloning really copies, what it leaves out, how the process works behind the scenes, how to protect your data while doing it, and which habits keep large teams out of trouble. We will use simple pictures, everyday comparisons and examples from well-known companies along the way.

i
Before you start

Flagsmith is actively developed, and small details such as button names, plan limits and exactly which settings are copied can change between versions. Treat this guide as the mental model, and confirm fine details in the official Flagsmith documentation for the version or plan you use.

1What Is Flagsmith and Why Does It Exist?

Before we copy anything, we need to know what we are copying. Let us start with the big picture of feature flags.

The problem feature flags solve

In the old days, a software team would finish a feature, bundle it with other changes, and release everything on one big day. If something broke, the only fix was to undo the whole release. That was slow, stressful and risky. Teams often called these days “release nights” because everyone stayed awake hoping nothing would fail.

A feature flag changes this. A flag is a small switch stored outside the code. The code says, “If this switch is on, show the new checkout page. If it is off, show the old one.” The new code can be shipped to everyone, hidden behind a switch that is off. Later, somebody flips the switch and the feature appears, with no new release at all. If it misbehaves, flipping it back takes seconds.

Analogy

Think of a theatre with stage lights. The wiring for every light is installed before the show. The lighting operator sits at a control panel and decides which lights glow at each moment. Flags are the panel. The code is the wiring. You can change the show without rebuilding the theatre.

Where Flagsmith fits

Flagsmith is a feature flag and remote configuration service. “Remote configuration” simply means that besides on and off, a flag can also carry a value, such as a number, a piece of text or a small block of structured data. For example, a flag called “max_upload_size” could hold the number 25 in one place and the number 100 in another.

Flagsmith can be used as a hosted cloud service, or teams can run it themselves on their own servers or in their own cloud account. It is open source, which means its source code is public. It was originally known by another name, Bullet Train, before being renamed Flagsmith. It offers a web dashboard for people, an API for automation, and software development kits, usually called SDKs, for many programming languages.

What Flagsmith manages for you

Flags

On and off switches

Each feature gets a flag that can be enabled or disabled without changing code.

Values

Remote configuration

A flag can carry a value, so you can tune numbers and text without a release.

Segments

Groups of users

Rules that pick out certain people, such as “users in India on the paid plan”.

Experiments

Multivariate options

Split traffic between several versions of a value to compare them.

Identities

Per-user settings

Flagsmith can remember individual users and give each one their own flag results.

Control

Permissions and audit

Roles decide who can change what, and a log records who changed it.

Real-world context

Large technology companies have talked publicly about using flags for years. Facebook has described an internal system called Gatekeeper that controls who sees new features. Etsy became well known for deploying code many times a day while hiding unfinished work behind configuration switches. GitHub has shared that it uses feature flags to release changes to staff first, then to small groups, then to everyone. The idea is the same everywhere: ship the code quietly, then reveal it carefully. Flagsmith gives smaller teams access to that same style of working.

2Environments: The Rooms Where Flags Live

Cloning only makes sense once you understand what an environment is and how it is arranged inside Flagsmith.

The three-level structure

Flagsmith organises everything in three layers. At the top is the organisation, which usually represents a company or a team. Inside an organisation you create one or more projects, and each project normally represents one product or application. Inside each project you create environments, which represent the stages that product moves through.

flowchart TD
    ORG["Organisation: Acme Corp"] --> P1["Project: Shopping App"]
    ORG --> P2["Project: Admin Portal"]
    P1 --> F["Features defined once per project"]
    P1 --> S["Segments defined once per project"]
    P1 --> E1["Environment: Development"]
    P1 --> E2["Environment: Staging"]
    P1 --> E3["Environment: Production"]
    E1 --> V1["Own flag states and values"]
    E2 --> V2["Own flag states and values"]
    E3 --> V3["Own flag states and values"]
Figure 1: Organisation, project and environment layers in Flagsmith

Notice something important in the picture. A feature, such as “new_checkout”, is created once for the whole project. But what that feature does in each environment, whether it is on, which value it holds, and which groups of users see it, is stored separately per environment. The feature is the name of a light switch. The environment decides whether that switch is up or down in each room.

Why teams keep separate environments

Different stages of work have different needs. Developers want to experiment freely, so they keep most flags on in the development environment. Testers want a stable copy that behaves like the real thing, so they use staging. Customers only ever touch production, and production must be changed with care. If all three shared one set of switches, a developer turning on an unfinished feature could expose it to real customers by accident.

Analogy

A restaurant has a practice kitchen, a tasting table for staff, and the real dining room. A chef can burn three dishes in the practice kitchen without anyone outside knowing. Environments give software teams the same safety.

What each environment owns

  • Its own keys. Each environment gets an identifier that applications use to say, “Please give me the flags for this environment.” There are also separate server-side keys for trusted backend services.
  • Its own flag states. The enabled or disabled setting and the stored value of every feature.
  • Its own segment overrides. Rules that change a flag for certain groups of users.
  • Its own identities. Records of individual users and their traits, such as a plan type or a country.
  • Its own settings. For example, who may approve changes, and whether sensitive data is hidden from viewers.
!
Remember

Environments inside one project share the list of features and segments. They do not share the settings of those features. That separation is the whole reason cloning is useful and also the reason it needs care.

Typical environment layouts

LayoutEnvironmentsBest for
SimpleDevelopment, ProductionSmall teams and early products
ClassicDevelopment, Staging, ProductionMost product teams
RegionalProduction-EU, Production-US, Production-IndiaProducts with data or behaviour rules per region
Short-livedOne environment per pull request or demoFast-moving teams with automated testing

3What Is Environment Cloning?

Cloning is easy to describe in one sentence, but the details matter. Let us define it carefully.

A simple definition

Environment cloning means creating a new environment that begins with the same flag configuration as an existing environment. You pick a source environment, give the new one a name, and Flagsmith copies the settings across. The result is a separate environment, with its own new keys, that you can then change freely without touching the original.

Analogy

Cloning is like duplicating a spreadsheet file. The copy has the same rows and formulas on the first day. After that, any edit you make to the copy never travels back to the original, and edits to the original never travel to the copy. They become two independent files with a shared past.

Cloning versus creating from scratch

When you create a blank environment in Flagsmith, every feature in the project appears in it with default settings, usually disabled. If your project has five features, that is quick. If your project has four hundred features, a blank environment means someone must walk through hundreds of switches and set each one by hand. That is slow and easy to get wrong.

A clone saves that effort. Flags that should be on are already on. Values that should be 100 are already 100. Rules for special groups are already in place. You start from a known good state rather than an empty one.

Cloning versus copying values by hand

Some teams try to avoid cloning by writing scripts that read one environment and write to another. This can work, but it takes time to build, needs maintenance and can miss details. Cloning is built into the product, tested by its makers, and does the whole job in one step.

Cloning is a snapshot, not a link

This point surprises many beginners. A clone is not connected to its source. It is a snapshot taken at the moment you press the button. If you later change a flag in the source, the clone does not change. If you want the clone to match the source again, you either clone again into a fresh environment or you update the differences yourself.

!
Watch out

Because a clone is a snapshot, it begins to drift from its source straight away. Teams that keep cloned environments around for months often discover that “staging” no longer matches “production” in ways nobody noticed.

1
source environment chosen
1
new independent environment created
0
live links left between them

4Why Teams Clone Environments

Cloning is not a trick for its own sake. It solves real problems that appear as products and teams grow.

Use case 1: Spinning up a staging copy of production

Test with real-looking settings

A bug only appears when ten particular flags are on together, the way they are in production. The team clones production into a new test environment, reproduces the bug safely, fixes it, and deletes the clone. Nobody touched live customers.

Use case 2: Preview environments for each code change

One environment per pull request

Many teams build an automated pipeline that creates a fresh preview of the app for every code change under review. Each preview needs its own flag settings. Cloning from a trusted template environment gives every preview a consistent starting point, and the pipeline removes it after the change is merged.

Use case 3: Launching in a new region or for a new customer

Same product, new market

A company opens a new regional deployment, or an enterprise customer gets a dedicated instance. Rather than hand-building the settings, the team clones an existing healthy region and then adjusts the few values that differ, such as currency or language rules.

Use case 4: Training, demos and sales

A safe place to show features

A sales engineer wants to demonstrate an upcoming feature to a prospect. A cloned demo environment lets them switch things on and off during the call without risking the real product.

Use case 5: Rehearsing a risky change

Practice before the real thing

Before changing forty flags in production for a big launch, a team clones production, performs the change in the clone, checks the app, and only then repeats the plan on the real environment. This is the same habit pilots use when they practise in a simulator.

Use case 6: Recovering from mistakes

Keeping a safety copy

Before a major cleanup of old flags, a team clones production to keep a record of how things looked. If the cleanup goes wrong, they have a reference to compare against. This is not a perfect backup, but it is a useful reminder of the earlier state.

Clone to practise, clone to test, clone to start fast, but never confuse a clone with the real thing.
i
Tip

If you find yourself cloning the same source again and again, make that source a clearly named “template” environment that nobody uses for real traffic. A calm, well-kept template produces dependable clones.

5What Gets Copied and What Does Not

This is the most important chapter for avoiding surprises. A clone copies the flag configuration, not everything that exists around it.

The simple rule of thumb

Cloning copies configuration, meaning the decisions people made about how features behave. It does not copy live data, meaning the records created by real users and real traffic, and it does not copy secrets, meaning the keys that let software talk to the environment.

Analogy

Imagine photocopying a restaurant’s menu and kitchen instructions. You get the dishes, the prices and the cooking steps. You do not get the customers who ate there yesterday, the receipts in the till, or the keys to the front door. A new restaurant needs its own customers and its own keys.

The comparison table

ItemUsually copied?What to know
Flag enabled or disabled stateYesEvery feature starts with the same on or off setting as the source.
Flag values (remote config)YesNumbers, text and structured values are carried across.
Segment overridesYesRules that change a flag for a group of users are kept, because the segments themselves live at project level.
Multivariate allocationsYesThe percentage split between variations is carried across.
Environment keysNoThe clone gets brand-new keys. Applications must be pointed at them.
Identities and traitsNoIndividual user records belong to the environment where they were created.
Identity overridesNoPer-person special cases do not travel to the clone.
Audit historyNoThe clone starts with a fresh history of its own.
Usage analyticsNoCounts of flag requests start from zero.
Integrations and webhooksCheckBehaviour may differ by version. Review them after cloning and re-create any that are missing.
!
Verify for your version

The table shows the general behaviour people should expect. Exact coverage, especially for integrations, webhooks and newer features such as versioning and approval settings, can differ by release. After your first clone, open the new environment and compare it to the source before trusting it.

Why identities are left out

Identities are records of real people, such as “user 48213 lives in Canada and has the premium plan”. They are created by live traffic. Copying them into a test environment would spread real customer information into a place with weaker protection. Leaving them out is a safe default, and it also keeps clones small and fast.

Why keys are not copied

If keys were copied, two environments would answer to the same identifier and applications could not tell them apart. A key is like an address. Two houses cannot share one address. Every clone gets its own, which also means a leaked development key never exposes production.

Why history is not copied

An audit log answers the question, “Who changed what, and when, in this environment?” A clone is a new environment, so its story begins on the day it was created. Starting with an empty log keeps the record honest.

A short checklist after any clone

  • Compare ten or so important flags between the source and the clone.
  • Check that segment overrides are present for any rule-based flags.
  • Copy the new environment key into the application settings meant for it.
  • Review integrations and webhooks for anything that still points at the source.
  • Check who has permission to the new environment.

6Architecture and Core Components

To understand how cloning works, we need to meet the building blocks it moves around.

The building blocks

Project level

Feature

The named thing you can switch. Defined once per project and shared by every environment inside it.

Environment level

Feature state

The setting of one feature in one environment: on or off, plus its value.

Project level

Segment

A reusable rule that describes a group of users, such as “country is India”.

Environment level

Segment override

A special setting of a feature for one segment inside one environment.

Environment level

Identity

A record for one individual user, including traits that describe them.

Environment level

Identity override

A special setting of a feature for one specific person.

How the pieces relate

Picture a grid. Down the side you list every feature in the project. Across the top you list every environment. Each cell of the grid is a feature state. A clone creates a new column and fills it with the same values as an existing column. Segment overrides are extra notes attached to certain cells, saying “for this group, do something different”. Cloning copies those notes too.

flowchart LR
    PRJ["Project"] --> FEAT["Feature: new_checkout"]
    PRJ --> SEG["Segment: Premium Users"]
    PRJ --> ENV["Environment: Staging"]
    FEAT --> FS["Feature State: enabled, value 100"]
    ENV --> FS
    SEG --> SO["Segment Override: enabled, value 200"]
    ENV --> SO
    FEAT --> SO
    ENV --> ID["Identities and Traits"]
    ID --> IO["Identity Overrides"]
Figure 2: How features, segments and environment-level settings connect

The services that surround the data

Flagsmith is made of several cooperating parts. There is a web dashboard where people click buttons. There is an API, which is a doorway that software uses to read and change data. There is a database that stores everything durably. In many setups there is also a fast read layer, such as a cache or an edge service, that answers flag requests from applications very quickly without disturbing the main database.

Cloning happens on the management side. A person or a script asks the API to create a new environment based on an existing one, and the application code that evaluates flags is not involved at all. That separation is a key design idea: management traffic is small and careful, while flag-reading traffic is huge and fast.

A word about scale

Flag-reading traffic can be enormous. A popular mobile app might ask for flags every time a screen opens, which can reach millions of requests per minute across a user base. Management actions like cloning happen a few times a day at most. Flagsmith designs for both by keeping the two paths apart, so cloning a big environment does not slow down the apps that depend on flags.

7How Cloning Works Internally

Let us follow a clone request from the moment you press the button to the moment the new environment is ready.

The journey in plain steps

1

You ask for a clone

You choose the source environment and type a name for the new one, through the dashboard or by calling the API.

2

Permissions are checked

Flagsmith confirms that you are allowed to create environments in this project and to read the source.

3

A new environment record is created

A fresh entry appears with your chosen name and brand-new keys. Basic settings are carried over from the source.

4

Feature states are copied

For every feature, Flagsmith reads the state in the source and writes a matching state in the clone: same enabled setting, same value.

5

Segment overrides and variation splits are copied

Special group rules and multivariate percentages are written to the new environment too.

6

Everything is saved together

The work is done as one unit, so you get either a complete clone or none at all, never a half-finished one.

7

The new environment is ready

You receive its details and can start using the new keys. Reads from the fast layer begin to be served from the new data.

sequenceDiagram
    participant U as User or Pipeline
    participant D as Dashboard or API Client
    participant A as Flagsmith API
    participant P as Permission Check
    participant DB as Database
    participant C as Read Cache or Edge Layer
    U->>D: Request clone of Staging as Preview-42
    D->>A: Clone request with source and new name
    A->>P: Is this user allowed?
    P-->>A: Allowed
    A->>DB: Create environment and new keys
    A->>DB: Copy feature states
    A->>DB: Copy segment overrides and variations
    DB-->>A: Saved as one unit
    A->>C: Publish new environment data
    A-->>D: New environment details
    D-->>U: Preview-42 is ready
Figure 3: The sequence of a clone request, from click to ready

Why all-or-nothing matters

Databases offer something called a transaction. A transaction groups several writes together so they succeed or fail as one. Think of paying at a shop: either the money leaves your account and you get the item, or neither happens. If a clone failed halfway and left an environment with only half its flags, someone might test against it and trust wrong answers. Treating the clone as one unit prevents that.

Time and size

The time a clone takes grows with the number of features and overrides. A project with a few dozen features clones almost instantly. A project with thousands of features and many segment overrides takes longer, because every one of them is a row to copy. For that reason, teams with very large projects often keep the number of features trimmed by removing old flags regularly. A tidy project clones faster and is easier to understand.

What happens to the apps already running

Nothing, and that is the point. Applications talking to the source environment keep using the source keys and see no change. Only software configured with the new keys sees the new environment. This is why cloning is safe to do during working hours.

i
Production example

Teams that run automated pipelines, in the style popularised by companies like Netflix with their deployment tooling, often treat environment creation as just another pipeline step. The pipeline clones, tests, reports results and tears the clone down, all without a human touching the dashboard.

8Cloning Step by Step: The Dashboard Way

For most people the first clone happens with a mouse. Here is the shape of that journey. Labels can vary a little between versions.

Before you begin

  • Make sure you have permission to create environments in the project. Project administrators usually do.
  • Decide on a clear name for the clone, such as “Staging-Copy-Nov” or “Preview-Checkout-Redesign”.
  • Decide which source is the best starting point. A calm staging environment is often better than production.
  • Confirm that your plan allows the number of environments you want. Some plans limit this.

The steps

1

Open your project

Sign in to Flagsmith and select the project that holds the environment you want to copy.

2

Find the environment creation option

Look for the option to create a new environment. Depending on the version, you will see a choice to base it on an existing environment, or a clone action in the menu of the environment you want to copy.

3

Choose the source

Pick the environment to copy from. Read the name twice. Choosing production by accident is a common slip.

4

Name the new environment

Type a clear, honest name. Names are the main way people avoid mixing environments up.

5

Confirm

Press create. Wait a short moment for the copy to finish.

6

Review the result

Open a handful of features and compare them to the source. Check segment overrides.

7

Collect the new keys

Find the new environment key in the settings and give it to the applications that should use the clone.

Doing it with automation

Flagsmith also offers an API for creating and cloning environments. Teams use it inside build pipelines, command-line helpers and infrastructure tools, so that a clone is created whenever a new test run starts. The details of the calls are in the official API reference, and a good habit is to keep the automation small: create the clone, run the checks, and delete the clone at the end. A pipeline that cleans up after itself prevents hundreds of forgotten environments from piling up.

!
Keys are secrets

Never paste environment keys into chat messages, shared documents or public repositories. Store them in a proper secrets manager, the same place you keep database passwords.

9Data Flow and Lifecycle of a Cloned Environment

A clone has a life of its own. It is born, used, drifts away from its source, and eventually retires. Understanding each stage helps you plan.

Stage 1: Birth

The clone appears with new keys and a copy of the source’s flag configuration. Its audit log is empty, and its usage numbers sit at zero. At this moment it is the most faithful it will ever be.

Stage 2: Connection

Applications are pointed at the new environment by giving them the new key. This might be a test build, a preview website or a sandbox. From now on, those applications ask Flagsmith for flags and receive answers from the clone.

Stage 3: Use and change

People begin to change flags in the clone. A tester turns on a new feature. A developer tries a different value. Each change is recorded in the clone’s own audit log, and none of it affects the source.

Stage 4: Drift

Meanwhile, the source keeps changing. Production teams flip flags as part of their normal work. The clone, frozen at its birth moment, falls behind. After a few weeks the two may differ in dozens of places.

Stage 5: Retirement

When the clone has done its job, it is deleted. Deleting removes its configuration and keys. Any application still pointed at those keys will start receiving errors or defaults, so confirm that nothing important depends on the clone first.

stateDiagram-v2
    [*] --> Cloned: Clone requested
    Cloned --> Connected: Apps given new keys
    Connected --> InUse: Flags changed by team
    InUse --> Drifting: Source keeps changing
    Drifting --> Refreshed: Re-clone or sync by hand
    Refreshed --> InUse
    InUse --> Retired: Work finished
    Drifting --> Retired: No longer needed
    Retired --> [*]
Figure 4: The lifecycle of a cloned environment

How flag requests reach a clone

When an application starts, its SDK, which is a small helper library, contacts Flagsmith with the environment key. There are two main styles of evaluation. In remote evaluation, the application asks Flagsmith for the answer each time, or on a schedule, and Flagsmith works out which flags apply to that user. In local evaluation, a trusted server-side application downloads the whole environment configuration once, keeps it in memory, and works out answers on its own, refreshing from time to time. Both styles work the same with cloned environments, because from the outside a clone is just another environment with its own key.

Analogy

Remote evaluation is like phoning a helpline for every question. Local evaluation is like keeping a printed copy of the rulebook on your desk and checking it yourself, with a fresh copy delivered now and then.

Refreshing a stale clone

If you want the clone to match the source again, you have two realistic choices. The first is to delete the clone and create a new one from the source. This is clean and fast, but you lose any changes you made in the old clone. The second is to compare the two environments by eye or by script and update the differences. The second takes longer but keeps the clone’s own work. Many teams choose the first for short-lived environments and the second for long-lived staging.

10Segments, Overrides and Experiments in a Clone

Flags are not always a simple yes or no. Cloning has to carry the clever parts too.

What segments are

A segment is a named group of users defined by rules. For example, “Beta Testers” might mean users whose trait “beta” is true, and “India Premium” might mean users whose country is India and whose plan is premium. Segments are written once at the project level and can be reused in every environment.

What segment overrides are

A segment override says, “In this environment, for this segment, give this feature a different setting.” Suppose the feature “new_dashboard” is off for everyone, but on for Beta Testers. That second part is a segment override. If a segment has overrides on many features, the clone needs to copy every one of them, or the new environment would behave differently for important groups.

Priority and order

When several segments apply to one person, Flagsmith decides which override wins. Overrides are ranked, and the highest one that matches decides the answer. Cloning keeps those rankings, so the order of precedence in the clone matches the source.

i
Good to know

Because segments live at project level, editing the rules of a segment changes it for every environment, including your clone and the source. Changing a segment’s definition is a project-wide act, not an environment-wide one. Cloning does not make a private copy of the segment itself.

Multivariate flags

A multivariate flag has several possible values with a percentage split. Imagine a button colour test where 50 percent of visitors see blue, 30 percent see green and 20 percent see orange. A clone starts with that same split. This is useful for rehearsals, but be careful: if your clone shares real visitors with the source by mistake, you may accidentally run the test twice and muddy your results.

Identity overrides stay behind

Sometimes a product manager gives one named person special access, such as an executive who wants to see a feature early. That is an identity override, and it belongs to that person’s record in the original environment. It does not travel in a clone. If you need the same person to have special access in the clone, add it again on purpose.

A worked example

Rehearsing a staged rollout

Production has “new_search” enabled for the Beta Testers segment, with a value of 50 for the page size, and disabled for everyone else. The team clones production into “Rollout-Rehearsal”. In the clone they see the same pattern, then switch the feature on for a second segment called “Staff”. They open the test app wired to the clone and confirm that staff users see the new search and everyone else does not. Satisfied, they repeat the single change in production.

A table of what to double-check

ThingWhere it livesAfter cloning
Segment definitionProjectShared with the source. Not duplicated.
Segment overrideEnvironmentCopied into the clone.
Multivariate splitEnvironmentCopied into the clone.
Identity overrideEnvironmentNot copied. Add again if needed.
Traits on usersEnvironmentNot copied. Created by live traffic.

11Security When Cloning Environments

Copying configuration sounds harmless, but it can spread more than you intend. A little care protects both customers and your company.

Know your two kinds of keys

Each environment has a client-side key, which is meant to be placed inside apps that run on user devices, such as web pages and mobile apps. Because users can find it, it is not a secret and it only allows reading flags. There are also server-side keys, which are meant for trusted backend software only. They can do more, including downloading the whole environment for local evaluation, so they must be kept secret. A clone gets its own set of both kinds.

Analogy

A client-side key is like the street address of a shop, which anyone can read. A server-side key is like the key to the back office. You share the address freely and guard the key carefully.

Control who can clone and who can see

Flagsmith lets you grant permissions at several levels: organisation, project and environment. A sensible setup lets many people view and edit development environments, fewer people edit staging, and only a trusted few edit production. When you create a clone, check who has access to it. A clone of production sometimes carries sensitive values such as internal addresses or partner settings in its flag values. Those values may now sit in an environment with looser access.

Watch what is stored in values

Remote configuration values are convenient, but they are not a vault. Passwords, private keys and secret tokens should never be stored as flag values. If someone already did that in production, a clone spreads the mistake. Use a proper secrets manager for secrets and keep flag values to harmless settings.

Use the hide-sensitive-data option when available

Flagsmith offers an environment setting that hides flag values from certain views and responses, which is helpful when an environment holds values you do not want widely seen. Check whether the setting carried over to your clone and turn it on where needed.

Approvals for important changes

On plans that offer them, change requests and approval rules let a second person review a flag change before it takes effect, similar to a code review. If your source environment demands approvals, make sure your clone either has the same rule or has a good reason not to. A clone with no approvals can be a hidden side door if it is ever connected to something important.

Customer data and privacy

Because identities and traits are not copied, cloning does not duplicate your users’ personal information. That is a real privacy benefit. Do not undo it by importing real user records into test environments. If you need realistic test users, create fake ones.

Safe habits

  • Give each environment its own keys and never reuse them.
  • Keep production edit rights small.
  • Delete clones when work finishes.
  • Use fake users for testing.
  • Store keys in a secrets manager.

Risky habits

  • Putting secrets inside flag values.
  • Leaving forgotten clones connected to real services.
  • Giving everyone admin rights for convenience.
  • Pasting keys into shared chats.
  • Importing real customer records into tests.

12Monitoring, Logging and Audit

When many environments exist, the ability to answer “what changed, who did it and when?” becomes extremely valuable.

The audit log

Flagsmith records changes in an audit log. When someone flips a flag, edits a value or adds an override, a line appears with the person’s name, the time and the change. Each environment has its own trail. That is why a clone starts with a clean log: the log tells the story of that environment alone.

When something odd happens, the audit log is the first place to look. If checkout suddenly changes in staging, a quick look shows that someone enabled a flag twenty minutes ago.

Integrations and webhooks

Flagsmith can send information to other tools when things change. A webhook is a message sent automatically to a web address whenever a certain event happens, such as a flag change. Teams use them to post notices in chat tools, create tickets or trigger tests. Some teams also connect analytics and monitoring tools. After a clone, check whether these connections exist for the new environment. A missing one means silent changes; a wrong one might send test notices to the production channel.

Usage and traffic numbers

Flagsmith can show how many times flags were requested, which helps spot environments that nobody uses anymore. A clone begins with zero. If a clone shows traffic you did not expect, something is pointing at it that should not be.

Naming and tagging for visibility

Good names make monitoring easy. Use patterns such as “preview-pr-1234”, “demo-acme-nov” or “staging-eu”. Flagsmith also supports tags on features, which let you label flags by team, risk or lifecycle. Tags are applied per feature at project level, so they appear the same in every environment.

Question

Who changed this flag?

Open the environment’s audit log and look for the time of the change.

Question

Is this clone still used?

Check request counts. No traffic for weeks usually means it can go.

Question

Did a rollout work?

Combine flag change times with your monitoring graphs to see the effect.

Question

Are clones piling up?

List environments regularly and remove old ones.

i
Production habit

Site reliability teams, a practice popularised by Google, like to line up “what changed” events next to graphs of errors and speed. Flag changes are among the most common causes of sudden behaviour changes, so recording them in the same timeline as deployments saves hours during incidents.

13Advantages, Disadvantages and Trade-offs

Every tool has a price. Cloning is wonderful, but it is not free of costs.

Advantages

  • Speed: hundreds of flags are set up in moments.
  • Consistency: the new environment begins in a known state.
  • Safety: practice changes without touching live customers.
  • Fewer human errors: no manual copying of values.
  • Privacy friendly: user records are not duplicated.
  • Automation friendly: ideal for pipelines and previews.

Disadvantages

  • Drift: a clone is a snapshot and goes stale.
  • Gaps: keys, identities and some settings need manual work.
  • Clutter: forgotten clones pile up.
  • Plan limits: some plans cap environment count.
  • False confidence: a clone may differ from production in ways nobody notices.
  • Shared segments: editing a segment affects every environment.

The trade-off between freshness and stability

A clone made from a very recent copy of production is fresh but may carry half-finished experiments. A clone made from a calm template is stable but may be missing recent changes. Choose based on the question you are trying to answer. If you are chasing a bug that appears in production, clone production. If you are rehearsing a new feature, clone a quiet template.

The trade-off between many small environments and a few big ones

Short-lived per-change environments give excellent isolation. Each test sees only its own settings. But they add moving parts and require tidy-up automation. A few shared long-lived environments are simpler to manage but cause people to step on each other’s changes. Teams often use both: a few shared environments for general work and temporary clones for risky or parallel work.

The trade-off between clone and sync

ApproachStrengthWeakness
Clone again when neededClean, quick, predictableLoses changes made in the old clone
Update the clone by hand or scriptKeeps local workSlow and error prone
Rely on separate blank environmentsNothing hidden is copiedLarge manual setup effort
The right amount of cloning is the amount that makes you faster without making you forgetful.

14Design Patterns and Anti-Patterns

Patterns are habits that other teams have already tested. Anti-patterns are habits that looked clever and then caused pain.

Pattern 1: The golden template

Keep one environment whose only job is to be a clean, well-reviewed starting point. Nobody sends real traffic to it. When you need a new environment, you clone the template. Because it never gets messy experiments, every clone starts healthy. Update the template deliberately, after each major release, so it stays current.

Pattern 2: The disposable preview

For every code change under review, an automated step clones the template, runs the tests with the new keys, reports the results and deletes the clone. Nothing is left behind. This gives each change a private playground and prevents tests from fighting each other over shared flags.

Pattern 3: The regional family

For products that run in several regions, create one well-tuned region first, then clone it for the others and adjust only the values that differ. Keep a short written list of what is allowed to differ between regions. This makes it easy to spot accidental differences later.

Pattern 4: The rehearsal clone

Before a high-stakes release day, clone production, perform the full plan of flag changes in the clone, check the result, and only then perform it live. Record what you learned, and fix the plan if something surprised you.

flowchart TD
    T["Golden Template Environment"] --> C1["Clone: Preview for Change 101"]
    T --> C2["Clone: Preview for Change 102"]
    T --> C3["Clone: Regional Copy EU"]
    T --> C4["Clone: Demo for Sales"]
    C1 --> X1["Run tests then delete"]
    C2 --> X2["Run tests then delete"]
    C3 --> L["Long-lived with its own owner"]
    C4 --> X4["Delete after demo week"]
Figure 5: A golden template feeding short-lived and long-lived clones

Anti-pattern 1: Cloning production for everything

ANTI-PATTERN 01 Avoid
What it looks like

Every new environment, even a quick developer experiment, is cloned straight from production.

Why it hurts

Production holds live-experiment settings and sensitive values. Spreading them widely increases risk, and developers end up testing against settings that are in the middle of a real rollout.

Better approach

Clone from a calm template for everyday work. Clone production only when you must reproduce a production-only problem.

Anti-pattern 2: The forgotten clone farm

ANTI-PATTERN 02 Avoid
What it looks like

Dozens of environments with names like “test2”, “test-final” and “new-test-real” sit around for months.

Why it hurts

Nobody knows which ones matter. Plan limits are consumed, permissions become messy, and somebody eventually deletes the wrong one.

Better approach

Use names that include a purpose and an owner, attach an expiry date in the name or in your notes, and run a regular clean-up.

Anti-pattern 3: Trusting a stale clone

ANTI-PATTERN 03 Avoid
What it looks like

A staging environment cloned a year ago is used as proof that production will behave well.

Why it hurts

The two have drifted. The test passes, production fails, and the team is surprised.

Better approach

Re-clone or compare regularly, and write down the known differences.

Anti-pattern 4: Secrets in flag values

ANTI-PATTERN 04 Avoid
What it looks like

A password or token is stored as a flag value because it was handy.

Why it hurts

Every clone and every person with view access now holds that secret.

Better approach

Store only a harmless name or reference in the flag, and keep the real secret in a dedicated secrets service.

15Best Practices and Common Mistakes

Here are the habits that experienced teams build around cloning, and the slips that beginners make most often.

Best practices

1

Name with purpose

Include the reason and, if useful, the date or owner. “demo-acme-nov” tells the whole story at a glance.

2

Clone from a template, not from chaos

A tidy source gives tidy copies.

3

Verify right after cloning

Open a few important flags, a segment override and the settings page. Do not assume.

4

Give new keys to the right place only

Store them in a secrets tool and restrict who can read them.

5

Set permissions on purpose

Decide who may view and who may edit the clone instead of accepting whatever default appears.

6

Automate creation and deletion together

If a pipeline creates clones, make the same pipeline responsible for removing them.

7

Clean up old flags in the source

Retire flags that have finished their job. Fewer flags means faster clones and fewer surprises.

8

Write down the differences

If an environment is meant to differ from its source, keep a short note explaining how and why.

Common mistakes

Mistake

Wrong source chosen

Picking production when staging was intended. Always read the source name before confirming.

Mistake

Old keys left in the app

The test build still talks to the source, so your experiments change the wrong environment.

Mistake

Assuming integrations came along

Notifications silently stop, or fire into the wrong channel.

Mistake

Expecting a live link

Changing the source and wondering why the clone did not follow.

Mistake

Editing shared segments casually

A rule change meant for a test affects every environment.

Mistake

Deleting a clone still in use

Apps still using its keys begin to fail. Check traffic first.

!
Pre-flight check

Before deleting any environment, ask three questions. Is anything still sending traffic to it? Does anyone depend on its settings? Do you have what you need from its audit log? If the answer to any is yes or maybe, wait.

A quick troubleshooting guide

SymptomLikely causeWhat to do
App shows flags from the wrong environmentOld key still configuredReplace with the clone’s key and restart the app.
A group of users sees the wrong behaviourSegment override missing or segment rules differCompare overrides with the source and check the segment definition.
Specific person lacks early accessIdentity override was not copiedAdd it again in the clone.
No chat notifications from the cloneIntegration not configured for the new environmentSet it up again for the clone.
Clone cannot be createdPlan limit or missing permissionRemove an unused environment or ask an administrator.
Values look oldSource changed after cloningRe-clone or update the differences by hand.

16Cloning Compared With Other Ways to Copy Settings

Cloning is one tool in a toolbox. Knowing the other tools helps you pick the right one for each job.

Option 1: Build a blank environment and fill it by hand

This is the slowest path, but it gives you total control. Every feature appears in the new environment with default settings, and you walk through them one by one. It makes sense when the new environment is meant to be very different from every existing one, for example a brand-new product line that happens to share a project, or when you want to prove that nothing unwanted came along from a messy source.

Option 2: Clone an existing environment

This is the fast path and the subject of this guide. It is best when the new environment should start out close to an existing one. You change only the differences afterward.

Option 3: Script the setup through the API

Flagsmith exposes an API that can read and write flag settings. A team can write a small program that reads the desired settings from a file kept in their code repository and applies them to an environment. This approach has one big advantage: the settings are written down in a file that people can review, compare and keep a history of. It also has a cost: someone must write and maintain the program, and it must be updated whenever Flagsmith adds new kinds of settings.

Option 4: Describe environments with infrastructure tools

Some teams describe their cloud resources in text files, using what is called “infrastructure as code”. Tools of this kind can create servers, databases and networks from written descriptions, and community or vendor-provided plugins exist for various services. A Flagsmith provider for such a tool allows environments and features to be described in the same way. The benefit is repeatability and review. The cost is a learning curve and the need to keep the descriptions in step with changes people make by hand in the dashboard.

Option 5: Use the command-line helper to download and reuse data

Flagsmith provides a command-line helper that can fetch the flag data of an environment and save it in a file. That file is mainly used so that applications can start with a known set of flags even when the network is down, but it is also a convenient way to take a look at the settings of an environment offline and compare two of them.

Analogy

Think of setting up a new classroom. You can furnish it from scratch, photocopy the layout of an existing room, follow a written floor plan stored in the school office, or hire a company that builds rooms from blueprints. All four produce a classroom. They differ in speed, in how repeatable the result is, and in how much effort it takes to keep a record of what you did.

A comparison table

MethodSpeedRepeatabilityBest for
Blank environment, set by handSlowLowVery different new environments
CloneFastMediumPreviews, regions, rehearsals, demos
Script through the APIMediumHighTeams that want settings reviewed like code
Infrastructure description filesMediumVery highLarger organisations with many environments
Download data with the helperFastMediumOffline defaults and comparisons

How to choose

If you only create a new environment once in a while, cloning is almost always enough. If you create many environments every day, add some automation around cloning. If you have strict rules that every setting must be reviewed before it takes effect, keep the settings in files and use cloning only for throwaway environments.

i
Mix and match

These methods are not rivals. A common setup uses written settings files for the golden template, cloning for everything that grows from that template, and manual checks for the few details that cloning does not carry.

17Performance, Scalability and High Availability

Products that serve millions of users need flag systems that stay fast and stay up. Here is how cloning fits into that picture.

Two very different kinds of traffic

Flagsmith deals with two kinds of work. The first is flag reading: applications asking, “What are my flags?” This happens constantly. A large consumer app might send thousands of such requests every second at busy times. The second is management: people and pipelines creating features, flipping switches and cloning environments. This happens occasionally. Good design keeps the two apart so that a burst of management work never slows down flag reading.

Millions
flag reads per minute in big deployments
Few
clones per hour in a busy team
Seconds
typical time for flags to update after a change

How reading stays fast

Flag data is read far more often than it changes. That pattern is perfect for caching, which means keeping a ready copy of popular answers close to where they are needed, so they do not have to be worked out again. Flagsmith’s managed service uses a separate, fast read layer at the edge of the network, so applications talk to a nearby server instead of the main database. Self-hosted setups can add their own caches in front of the API. SDKs also keep results in memory for a short time, so a single application does not repeat the same request again and again.

Analogy

A library keeps popular books on a front shelf so people do not have to ask the librarian to fetch them from the basement each time. The basement is the main database, the front shelf is the cache, and cloning is the librarian adding a whole new shelf of books copied from an existing one.

What a clone does to the read layer

When a clone is created, its data must also appear in the fast read layer so applications can ask for it. There may be a short delay, a matter of moments, before the new environment answers requests from every location. Pipelines that create a clone and immediately run tests should therefore wait until the new environment responds correctly before starting the tests, instead of assuming it is ready the very instant the clone call returns.

Size matters

The amount of work in a clone depends on how many features and overrides the project holds. A project with 50 features and a handful of overrides is trivial. A project with 3,000 features and thousands of overrides is a bigger job, and each environment in that project also makes every flag-reading response a little heavier. This is one of the strongest reasons to retire old flags.

Keep small

Retire finished flags

A flag that is on for everyone for months should become normal code, and the flag deleted.

Keep small

Limit overrides

Overrides are powerful, but hundreds per feature slow things and confuse people.

Keep small

Limit environments

Delete temporary clones quickly so the system carries only what is needed.

Keep small

Use local evaluation wisely

Heavy servers can download the environment once and decide locally, cutting network chatter.

High availability: what if Flagsmith itself has a bad day?

Because flags control behaviour, a flag service outage could matter. Good teams plan for this in three layers. First, SDKs can be configured with default values in the code, so if the service cannot be reached, the app falls back to sensible behaviour. Second, SDKs can keep a recent copy of flag data, so the app keeps working with slightly old answers. Third, the service itself can be run in several places, with data stored in a database that has a standby copy ready to take over.

!
Pick safe defaults

For every flag, ask: “If this flag cannot be read, what should the app do?” For a brand-new risky feature, the answer is usually “stay off”. For an important safety switch, such as a kill switch that disables a failing partner service, think carefully about which direction is safer.

Scaling cloning itself

If a pipeline creates a fresh clone for every code change, and a hundred changes arrive in an hour, you will have a hundred clones. That is fine for the system if each is deleted promptly, but it can run into plan limits or rate limits. Teams solve this by sharing a small pool of reusable preview environments, by cleaning up aggressively, or by cloning only for changes that touch flag-related code.

18Deployment and Cloud: Hosted and Self-Hosted Flagsmith

Where Flagsmith runs changes what cloning feels like in daily life. Let us look at the main choices.

The hosted service

Flagsmith offers a hosted service where the company runs everything. You sign up, create a project and start working. Updates arrive automatically, performance tuning is handled for you, and the read layer is already spread across the world. Cloning in the hosted service is a matter of using the dashboard or API. Limits depend on your plan, including how many environments or projects you can have.

Self-hosting

Because Flagsmith is open source, a team can run it on its own servers or in its own cloud account. Common ways include containers started with a container tool and packaged installs for container-orchestration systems such as Kubernetes. A self-hosted setup needs a database, usually PostgreSQL, and one or more copies of the API service. Teams choose this path when they must keep data inside their own network, when rules forbid sending certain data outside, or when they want complete control.

What changes for cloning

  • Database load. A clone writes many rows. On a self-hosted system, make sure your database has room to handle bursts, especially if pipelines create many clones at once.
  • Background work. Some actions in Flagsmith are handled by background workers. Make sure workers are running and healthy, or follow-up tasks after cloning may be delayed.
  • Backups. You own the backups. A scheduled database backup is your real safety net, not a clone.
  • Upgrades. When you upgrade Flagsmith, new settings may appear. After an upgrade, clone once into a test environment and verify the result.
  • Access. You decide who can reach the dashboard, usually behind your company login system.
flowchart LR
    DEV["Developer or Pipeline"] --> LB["Load Balancer"]
    LB --> API1["Flagsmith API Copy 1"]
    LB --> API2["Flagsmith API Copy 2"]
    API1 --> DB[("Primary Database")]
    API2 --> DB
    DB --> STBY[("Standby Database")]
    API1 --> CACHE["Cache Layer"]
    API2 --> CACHE
    APPS["Applications using SDKs"] --> LB
    API1 --> WORK["Background Workers"]
    API2 --> WORK
Figure 6: A typical self-hosted Flagsmith layout with two API copies and a standby database

Private cloud and hybrid styles

Some vendors offer a private installation, where the service is run for you but in a space dedicated to your company. This gives some of the comfort of the hosted service along with isolation. Companies with strong rules often use this middle path.

Analogy

The hosted service is like eating at a restaurant, self-hosting is like cooking in your own kitchen, and a private installation is like hiring a chef to cook in your own kitchen. Same meal, different mix of control, effort and cost.

Cost thinking

Cloning itself costs almost nothing in compute. The real costs are indirect: plan tiers that charge by number of projects or requests, the time people spend maintaining many environments, and the storage that old clones occupy. A tidy habit of deleting temporary clones keeps all three low.

Multi-region and multi-cloud

Large companies often run products in several regions. Flagsmith can be deployed in more than one place, but a single environment lives in one Flagsmith installation. If you want an identical set of flags in two installations, a clone does not cross that boundary, because it only works inside one project of one installation. Teams handle this with scripts that read from one and write to the other, or by keeping the settings in files. Always plan for this early if you operate across several clouds.

19Failure Scenarios and Recovery

Things go wrong. The aim here is to know the usual troubles in advance and to have a calm response ready.

Scenario 1: The clone call fails halfway

Because the copy is done as one unit, the usual result is that nothing was created. Check the environment list. If nothing new appears, simply try again. If something partial does appear, delete it and start again, then report the problem to your administrator or to Flagsmith support, because partial results are not expected behaviour.

Scenario 2: The clone looks right, but the app behaves differently

This almost always means the application is still using the old key, or a setting that was not copied is involved. Check the key first. Then check segment overrides, identity-specific rules and integrations.

Scenario 3: A clone was accidentally given real traffic

Someone put the clone’s key in a live app. Customers now see test settings. Fix this by swapping back to the correct key at once, and then look at the audit log of the clone to see what, if anything, was changed. Add a rule in your review process that production configuration changes need a second pair of eyes.

Scenario 4: The wrong environment was deleted

Deleting an environment is serious. Its configuration and keys are removed, and applications using it begin to fail. If you have a recent clone, you can create a new environment from it and restore most of the flag settings, though the keys will be new and must be updated in every application. This is the best argument for using clear names, restricting delete rights and keeping periodic backups on self-hosted installations.

Scenario 5: Plan limits stop a clone

The error says you have reached the environment limit. Look for forgotten clones to delete, or ask an administrator about a higher plan. Do not delete anything you are unsure about.

Scenario 6: A source changed during the clone

If someone flips a flag in the source at the very moment you clone it, the clone may include the change or not. For routine uses this is unimportant. For a critical rehearsal, agree on a short freeze on the source while the clone is made.

flowchart TD
    S["Something looks wrong"] --> Q1{"Is the app using the right key?"}
    Q1 -- "No" --> F1["Swap in the correct key and restart"]
    Q1 -- "Yes" --> Q2{"Do the flag states match the source?"}
    Q2 -- "No" --> F2["Re-clone or fix the differences"]
    Q2 -- "Yes" --> Q3{"Are overrides and segments right?"}
    Q3 -- "No" --> F3["Copy the missing override by hand"]
    Q3 -- "Yes" --> Q4{"Do integrations point to the right place?"}
    Q4 -- "No" --> F4["Set the integration up again"]
    Q4 -- "Yes" --> F5["Check the audit log for recent changes"]
Figure 7: A simple troubleshooting path when a cloned environment behaves oddly

Recovery habits that pay off

  • Use names that make mistakes harder, such as adding “PROD” in capital letters to production.
  • Limit delete permission to a very small group.
  • Keep a template environment as a spare reference.
  • On self-hosted installations, test restoring from a database backup, not only taking one.
  • Write a short runbook that explains how to create, verify and delete clones. A runbook is simply a checklist for a repeating task.
!
Not a backup

A clone preserves flag configuration only. It does not preserve identities, history or keys. Treat it as a convenience for configuration, and use proper backups for anything you could not afford to lose.

20Governance, Teamwork and Compliance

As more people use feature flags, rules and habits matter as much as buttons. This chapter covers the human side of cloning.

Who owns an environment?

Every environment should have an owner, a person or a team who answers questions about it. For long-lived environments, record the owner in a shared document. For short-lived clones, put an owner or ticket reference in the name. Unowned environments become mysteries after a few months.

A simple naming convention

PatternExampleMeaning
stage-purposestaging-euLong-lived, a regional staging environment
preview-ticketpreview-shop-1432Short-lived, tied to one work item
demo-customer-monthdemo-acme-novShort-lived, made for a sales demo
rehearsal-eventrehearsal-launch-q4Short-lived, a practice run before a launch
template-purposetemplate-baseLong-lived, used only as a clone source

Roles and permissions in practice

A workable model has three levels of trust. Everyone in engineering can create and edit temporary clones. A smaller group can edit shared staging environments. A very small group, often those on call, can edit production. Clones made from production inherit sensitive values, so decide in advance whether they may exist at all, and if so who may view them.

Approvals and change control

Companies in finance, health and government often need proof that important changes were reviewed. Approval workflows on production environments give that proof. Make sure the approval setup is applied to any clone that is promoted to something more permanent. Temporary clones used for experiments can usually skip approvals, as long as they cannot affect real users.

Privacy and compliance

Rules such as the European data protection law and similar rules elsewhere care about personal data. Because cloning does not copy identities or traits, it is naturally friendly to those rules. Keep it that way. Avoid loading real personal data into test environments, and avoid storing personal data in flag values. If your company is audited, the audit log and the permission list are the first things reviewers ask to see.

Teaching new teammates

New joiners should learn four things in their first week: what each environment is for, how to clone safely, how to find the audit log, and how to ask for help. A one-page guide with screenshots from your own project, written in plain words, is worth more than a long manual.

Hand-offs between teams

Product, QA and operations

A product manager wants to try a new onboarding flow. A QA engineer clones the template into a preview environment and switches the feature on for a test segment. The operations team reviews the exact list of flags that will change in production and schedules the change at a quiet hour. Each person works in a space that fits their role, and the clone makes the hand-offs smooth.

Tools make cloning easy. Habits make cloning safe.

A governance checklist

  • Every environment has a written purpose and an owner.
  • Production edit rights are limited and reviewed every quarter.
  • Temporary clones are deleted within an agreed number of days.
  • No secrets or personal data live in flag values.
  • Approval rules are checked after any promotion of a clone.
  • A runbook describes how to clone, verify and delete.

21A Complete Walkthrough: Launching a New Checkout

Let us follow a made-up online shop, “Acme Cart”, through a full launch to see how every idea in this guide fits together.

The situation

Acme Cart sells home goods to about two million monthly shoppers. The team has built a faster checkout and wants to release it carefully. They use Flagsmith with one project, “Shop”, and three long-lived environments: Development, Staging and Production. They also keep a quiet template environment called “template-base”.

Stage 1: Plan the change

Product, engineering and operations agree on the plan. A new feature called “fast_checkout” will be created. It will be enabled first for staff, then for a small segment of loyal customers, then for half of all shoppers, then for everyone. A kill switch called “fast_checkout_kill” will exist so that anyone on call can instantly turn the feature off.

Stage 2: Build and test in Development

Developers create the new features in the project. They appear in all environments, disabled by default. In Development, developers switch “fast_checkout” on and test freely.

Stage 3: Clone for rehearsal

Operations clones Production into a new environment named “rehearsal-checkout-q4”. They want to practise the exact sequence of changes against settings that match what customers see today. They give the new key to a test copy of the shop website. The clone has the same segments, overrides and values as production, but no customer records and no history.

Stage 4: Practise the rollout

In the rehearsal environment, the team enables the feature for the Staff segment, then for the Loyal Customers segment, then sets a percentage split. At each step, testers confirm the behaviour on the test site. They discover that an old override on a related flag, “legacy_discount_banner”, clashes with the new design. They fix the plan: the banner must be disabled at the same moment.

flowchart LR
    A["Plan the rollout"] --> B["Build features in Development"]
    B --> C["Clone Production into rehearsal"]
    C --> D["Practise each step and note problems"]
    D --> E["Fix the plan"]
    E --> F["Apply steps to Production with approval"]
    F --> G["Watch graphs and the audit log"]
    G --> H["Delete the rehearsal clone"]
Figure 8: The Acme Cart rollout from plan to clean-up

Stage 5: Apply the plan in Production

With a corrected, proven plan, an engineer proposes the changes in Production. A second person reviews and approves them. At the agreed quiet hour, the steps are applied one at a time, with a pause between each to watch error rates and checkout success numbers on the monitoring dashboards.

Stage 6: Watch and learn

The team places the flag change times next to their graphs. When the percentage reaches half of shoppers, checkout speed improves as expected, and no new errors appear. They move to everyone a day later.

Stage 7: Clean up

The rehearsal clone is deleted. Two weeks later, the team removes the old checkout code, deletes the “fast_checkout” flag and keeps the kill switch for a while longer. The template environment is refreshed so that new clones include the final settings.

What went well, and why

Worked well

  • Rehearsal found a real clash before customers did.
  • No customer data was copied into the test space.
  • Approvals gave a clear record of who changed what.
  • The clone was deleted promptly.

Could be better

  • The test site briefly used the wrong key until a teammate noticed.
  • The team forgot to re-create a chat notification for the clone.
  • Nobody wrote down the lessons until a week later.
A

Lesson one

Put the key change in a checklist item so it is never forgotten.

B

Lesson two

List integrations to be re-created right inside the clone runbook.

C

Lesson three

Write the lessons down the same day, while memories are fresh.

DECISION RECORD 01 Accepted
Context

Acme Cart needs a safe way to rehearse high-impact flag changes.

Decision

Before any launch that touches checkout, clone Production into a temporary rehearsal environment and practise the whole plan there.

Consequences

Launch preparation takes an extra hour, but surprises during the real launch fall sharply. The team must remember to give the rehearsal environment its own key and delete it afterward.

22Testing Strategies Built on Cloned Environments

The most common reason to clone is to test something safely. Here are the testing styles where a clone earns its keep.

Why flags make testing harder, and how clones help

A normal program has one behaviour. A program with ten flags has, in theory, over a thousand possible combinations, because each flag can be on or off. No team tests every combination. Instead, they test the combinations that matter most: the one that exists in production today, the one that will exist after the next release, and a few risky mixtures in between. A cloned environment gives each of those combinations a home with its own keys, so tests never disturb each other.

Analogy

Think of a car maker crash-testing several versions of a car. Each test needs its own car. A cloned environment is a freshly built car for each test, identical to the production model on day one, ready to be bent and broken without harming the real fleet.

Style 1: Automated tests per code change

When a developer proposes a change, an automated pipeline builds the app, creates a clone from the template, hands the new key to the test run, runs the tests and deletes the clone. The result is a pass or a fail, linked to the change. If two developers propose changes at the same time, each gets their own clone and neither can disturb the other.

Style 2: Manual exploratory testing

Human testers like to wander through an app, trying odd things. A dedicated clone lets them switch features on and off as they explore, with no fear of leaking an unfinished feature to customers. After testing, they write notes and the clone is deleted or refreshed.

Style 3: End-to-end tests of important journeys

For journeys such as signing up, paying and cancelling, teams keep a longer-lived environment that mirrors production closely. It is cloned from production on a schedule, such as once a week, so the tests run against settings that match reality. When the tests fail, it is a signal that either the code or the settings have changed in a risky way.

Style 4: Load and performance tests

Before a big sale or launch, teams simulate heavy traffic. A clone of production lets them do this with the same flag settings real shoppers experience, without sending test traffic to the production environment’s counters and logs. Be careful that the test traffic uses the clone’s key, and that the test only sends fake users.

Style 5: Chaos and failure drills

Some teams practise what happens when a flag service is slow or unreachable. In a clone, they can deliberately remove defaults, change values to unusual numbers or switch off kill switches, and watch how the application copes. The point is to learn about weak spots in a safe place.

Style 6: Experiment design checks

Before running a real experiment, such as a three-way test of a new button, analysts test that the percentages add up, that the right segments are included, and that the app reports results correctly. A clone gives them a dry run of the experiment, using fake users.

Testing styleClone lifetimeClone sourceMain risk
Per code changeMinutesTemplateClones left behind after failures
ExploratoryDaysTemplate or stagingTesters confusing it with staging
End-to-end journeysWeeks, refreshedProductionSensitive values spread widely
Load testsHoursProductionTest traffic hitting the wrong key
Failure drillsHoursTemplateExperiments leaking into shared tools
Experiment dry runsDaysProductionReal users accidentally included
i
Clean-up on failure

The most common leak in automated testing is the clone that is never deleted because the test run crashed halfway. Make the delete step run even when earlier steps fail, and add a nightly sweep that removes any preview environment older than a day.

What a good test environment checklist looks like

  • It was created from a known source, and the source is written down.
  • It uses its own keys, stored safely.
  • It contains only fake users.
  • Its permissions are limited to the people doing the testing.
  • It has an expiry plan.
  • Someone owns it.

23Advanced Topics: Settings, Versioning and Multi-Project Strategy

Once the basics feel comfortable, a few deeper ideas decide how well cloning scales in a big organisation.

Environment-level settings

Besides flag states, each environment carries its own settings. Examples include whether sensitive data is hidden, whether client applications may store traits about users, how many approvals a change needs, and details of how identities are recognised. Which of these are carried across by a clone depends on the version, so after cloning, open the settings page of the new environment and compare it with the source, line by line. Doing this once and writing down the result gives you a trusted answer for your version.

Feature versioning

Some versions of Flagsmith offer a feature that keeps numbered versions of each flag’s settings in an environment, so you can see earlier states and prepare changes to go live at a chosen time. If this is turned on in the source, check how it behaves in the clone. A fresh clone usually starts its own history at its birth, so earlier versions from the source do not appear.

Scheduled changes

Planned changes, such as “turn this on at nine o’clock on Monday”, belong to the environment where they were set. A clone should not be expected to inherit planned changes. After cloning, check whether any schedule needs to be set again, and be careful not to leave two environments scheduled to do the same thing by accident.

Tags and organisation of features

Tags are labels on features, such as “team-payments” or “temporary”. They live at the project level, so every environment sees the same tags. Good tagging makes clean-up easier: you can list all features tagged “temporary” and ask the owners whether they are still needed. Cleaner projects make clones faster and easier to review.

One project or many?

Teams often wonder whether to put several products in a single project or give each its own. The answer affects cloning, because cloning works inside one project.

One shared project

  • One list of features and segments to maintain.
  • Clones carry everything for all products together.
  • Good when products share many flags.

Risks of a shared project

  • Large feature lists slow people down.
  • Permissions are harder to separate.
  • One team’s segment edit affects others.

One project per product

  • Clean boundaries and simple permissions.
  • Smaller, faster clones.
  • Teams work without stepping on each other.

Risks of many projects

  • Shared concepts must be kept in step by hand.
  • Clones cannot cross project borders.
  • More places to review and clean.

Promoting changes between environments

Cloning moves a whole environment’s configuration at once. Often what you really want is to move just one change from staging to production. That is a different task, called promotion. Promotion is usually done by applying the same small change in the next environment, by hand or through a script, often with an approval. Understanding this difference prevents a classic mistake: using a clone as a shortcut for deploying a single flag, which can quietly overwrite many other settings.

!
Do not clone onto production

Cloning creates a new environment. It is not a way to overwrite an existing one. Do not try to make production match staging by cloning, since that would mean a new environment with new keys. To bring production closer to staging, apply the specific changes you want, one at a time, with review.

Flag lifecycle

Flags are not meant to live forever. A healthy flag goes through stages: created, tested, rolled out, fully on, removed from code, deleted. Cloning copies flags at whatever stage they are in. If your template contains dead flags, every clone does too. Make flag removal a normal part of finishing a feature, and your clones stay light.

stateDiagram-v2
    [*] --> Created
    Created --> Testing: Switched on in Development
    Testing --> RollingOut: Enabled for small groups
    RollingOut --> FullyOn: Enabled for everyone
    FullyOn --> CodeRemoved: Old code deleted
    CodeRemoved --> Deleted: Flag removed from project
    Deleted --> [*]
    RollingOut --> Testing: Problem found
Figure 9: The life of a feature flag, and where clones carry it along

Measuring success

Teams that use cloning heavily like to track a few simple numbers: how many temporary environments exist, how old the oldest one is, how long a clone takes, and how often a clone-related mistake reaches production. Reviewing these once a month helps catch bad habits early.

24Real-World and Industry Examples

Cloning is one small feature of a larger way of working. Here is how the ideas around it show up at companies people know. The descriptions below are based on what these companies have discussed publicly, and they illustrate patterns, not details of any private setup.

Netflix: practising before the real show

Netflix has talked openly about canary releases, where a new version is first given to a tiny slice of traffic and compared with the old version before it reaches everyone. The thinking behind it is the same as a rehearsal clone: try the change somewhere safe, measure, and only then roll out widely. A cloned environment is the flag world’s version of that careful first step.

Facebook: gates for new features

Facebook has described how new features are released to employees first, then to small percentages of users, using an internal gating system. Each stage is a different audience with different settings. When you clone an environment and then change only a few values, you are following the same idea at a smaller scale: start from a known state and change the least you can.

Etsy: deploy often, reveal slowly

Etsy became known in the engineering community for deploying very frequently while hiding unfinished work behind configuration switches. For such teams, being able to set up a fresh, predictable test environment in moments makes frequent deployment less scary.

GitHub: staff first

GitHub has written about releasing features to its own staff before the public. A cloned “staff preview” environment, with a few extra features switched on, is a natural way to give staff a place to try things without disturbing real customers.

Google: change is the usual suspect

Google’s reliability practices emphasise that most outages follow some kind of change. That is why recording flag changes in an audit trail and rehearsing risky changes in a copy are such valuable habits. They shorten the time between “something broke” and “we know what changed”.

Uber-style regional operations

Companies that run in many cities and countries, as ride and delivery platforms do, need rules that differ by place: prices, features, legal requirements. A regional family of environments cloned from a well-tuned base keeps the shared parts consistent while letting each region adjust its own details.

i
Takeaway

None of these companies uses cloning as an end in itself. They use it as a quick way to get a safe, repeatable starting point, so that people can spend their effort on the actual change.

A small-team example from start to finish

A ten-person startup preparing a pricing change

The startup has a Development, a Staging and a Production environment. The team wants to test a new pricing page with a sample of customers. They clone Staging into “Pricing-Test” and give the new key to a test build. In “Pricing-Test” they switch on the new pricing flag for a segment called “Internal Testers”, and then they check that normal users still see the old page. After a week of feedback they apply the same, now proven, changes to Production using their approval process. They delete “Pricing-Test” and note the lessons in their team wiki.

4
environments touched in the story
1
temporary clone created and deleted
0
real customers exposed to untested settings

25Reusable Checklists for Every Stage of a Clone

Experienced pilots do not trust memory for routine steps, and neither should you. These checklists turn the lessons of this guide into short routines you can copy into your own team wiki.

Before you clone

  • Write one sentence describing why the clone is needed and who will use it.
  • Choose the source on purpose. Prefer the quiet template unless you must reproduce production.
  • Choose a clear name that shows purpose and, where useful, an owner or ticket number.
  • Confirm that your plan has room for another environment.
  • Decide the expiry date now, while you remember why the environment exists.
  • Check that no important change is half-finished in the source.

Right after you clone

  • Open the new environment and confirm the name and the project are what you expect.
  • Compare at least ten important flags, including one with a value and one with a segment override.
  • Compare environment settings: hidden values, approvals, trait handling.
  • Look at integrations and webhooks. Re-create the ones the clone needs. Remove or avoid any that would send noise to live channels.
  • Review the permission list. Remove access that is not needed.
  • Store the new keys in your secrets tool and give them only to the apps that need them.

While the clone is in use

  • Remind everyone using it that it is not production, and that changes in it will not affect the source.
  • Keep notes of any change you may want to repeat in the real environment.
  • Glance at the request counts now and then. Surprising traffic is a warning sign.
  • If the clone lives longer than planned, decide whether to refresh it or turn it into a proper long-lived environment with an owner.

Before you delete the clone

  • Check that no application still uses its keys.
  • Copy any useful findings into your notes, such as the final flag settings for a rehearsal.
  • Check the audit log for anything that should be shared with the team.
  • Confirm the name one more time. Deleting the wrong environment is the most painful mistake in this area.
  • Remove its keys from the secrets tool and from any test configuration.

Once a month

  • List all environments and compare them against your naming rules.
  • Delete or hand over any that have no owner or no recent traffic.
  • Review who can edit production and who can delete environments.
  • Refresh the template environment and note what changed.
  • Look for flags that have been fully on for a long time, and plan their removal.
Analogy

A tidy workshop does not rely on one person remembering where every tool is. Each tool has a hook, each hook has a label, and everything goes back after use. These checklists are the hooks and labels for your flag workshop.

i
Make it automatic

Wherever a checklist item can be done by a script, such as deleting old preview environments or listing environments without an owner in the name, let the script do it. People are best used for judgement, such as deciding whether an old environment is safe to delete.

26Frequently Asked Questions

Quick answers to the questions that come up most often.

Q1Does cloning change my source environment?
No. The source is only read. Nothing in it is modified, and applications using it keep working exactly as before.
Q2Is the clone linked to the source so that changes follow along?
No. A clone is a snapshot taken at one moment. After that, the two environments are independent and drift apart as people change them.
Q3Will my users’ data be copied into the clone?
Identities, traits and identity overrides are generally not copied, which protects personal information. Always confirm in your own version after the first clone.
Q4Do I get new environment keys?
Yes. Each environment has its own keys. You need to give the new keys to any application you want to use the clone.
Q5Are segment definitions copied?
Segments belong to the project and are shared by all its environments, so they are not duplicated. What is copied are the overrides that apply those segments to features in the environment.
Q6Can I clone an environment into a different project?
Cloning is designed to work within one project, because features and segments are defined per project. If you need to bring settings to another project, you would normally create the matching features first and then set their values there, using the API or a script.
Q7How long does a clone take?
For most projects, a few moments. It grows with the number of features and overrides, so very large projects take longer.
Q8Is there a limit on how many environments I can have?
Plans can set limits. Check your plan details, and delete clones you no longer need.
Q9Is a clone a proper backup of production?
Not really. It is a handy reference copy of the configuration at one time, but it does not include history, identities or keys, and it is not built for disaster recovery. Use proper backup features of your hosting set-up for that.
Q10What happens to apps when I delete a clone?
Anything still using the clone’s keys will lose access to its flags and may fall back to default values. Make sure nothing depends on it first.
Q11Should I clone production or staging?
Clone staging or a template for everyday work. Clone production when you need to reproduce something that only happens with production settings.
Q12Can I automate cloning?
Yes. Flagsmith provides an API, and teams commonly call it from build pipelines to create and remove temporary environments.
Q13Do cloned environments use the same approval rules?
Check this in your version after cloning. Approval and permission settings are among the details most worth reviewing by hand.
Q14Can two environments share one key to keep things simple?
No. A key identifies exactly one environment. Sharing keys defeats the purpose of having separate environments.

27Plain-English Glossary

A short reference for the words used in this guide. Keep it nearby when reading Flagsmith documentation.

Term

Feature flag

A switch outside the code that turns a behaviour on or off, so features can appear without a new release.

Term

Remote configuration

A value, such as a number or text, that an app reads from Flagsmith so it can be changed without a release.

Term

Organisation

The top layer in Flagsmith. Usually a company or a team.

Term

Project

A container for one product’s features, segments and environments.

Term

Environment

A separate set of flag settings for one stage, such as development or production.

Term

Feature state

The setting of one feature in one environment: on or off, plus its value.

Term

Segment

A group of users defined by rules, reusable across environments in a project.

Term

Segment override

A different setting of a feature for one segment inside one environment.

Term

Identity

A record for one user, which Flagsmith can use to give personal flag results.

Term

Trait

A fact stored about an identity, such as country or plan type.

Term

Identity override

A special setting of a feature for one specific identity.

Term

Multivariate flag

A flag with several possible values split by percentages, used for experiments.

Term

SDK

A software development kit: a small helper library that lets an app talk to Flagsmith.

Term

Remote evaluation

Flagsmith works out the flags for a user and sends the answer to the app.

Term

Local evaluation

A trusted server downloads the settings and works out answers by itself.

Term

Audit log

The record of who changed what and when in an environment.

Term

Webhook

A message sent automatically to a web address when something happens, such as a flag change.

Term

Transaction

A group of database writes that either all succeed or all fail.

Term

Cache

A nearby stored copy of popular answers, kept so they can be returned quickly.

Term

Runbook

A step-by-step checklist for a task that repeats, such as creating and deleting a clone.

i
One more word

The word drift appears often in this guide. It means the slow, unplanned growth of differences between two things that started out the same. Cloning begins with zero drift, and every change afterwards adds some.

28Summary and Key Takeaways

Let us pull the whole story together in a few lines you can remember.

Key Takeaways

  • Environments are separate rooms. Features and segments are shared across a project, but each environment keeps its own settings for them.
  • Cloning is a snapshot. It copies flag states, values, segment overrides and variation splits into a brand-new environment, then lets go.
  • Not everything travels. Keys, identities, traits, identity overrides, history and usage numbers stay behind, and integrations deserve a manual check.
  • Clone from calm sources. A well-kept template produces dependable copies; production should be cloned only when you truly need its exact state.
  • Protect the new keys and the values. Never store secrets in flag values, keep keys in a secrets manager, and set permissions on purpose.
  • Plan for drift and clean-up. Name clones clearly, delete them when finished, and re-clone when you need a fresh start.
  • Verify, always. Compare a few important flags after every clone, and confirm fine details in the documentation for your version of Flagsmith.