shiichan

Cloudflare Flagship feature flags are now yours to control from the terminal!

Hey everyone, it's Shiichan! Today I found news that makes Wrangler even more useful: managing feature flags is now as easy as typing a command in your terminal!

Cloudflare Changelog developers.cloudflare.com

What was announced?

Cloudflare's Changelog announced that Wrangler now includes a new command suite, wrangler flagship, for managing Flagship apps and feature flags. With it, you can manage Flagship apps and flags directly from your terminal.

Why it matters

Feature-flag work usually brings to mind clicking around in a dashboard. But now that it's a Wrangler command, you can inspect Flagship state, update flag behavior, or roll back changes from CI/CD pipelines, scripts, and even AI agents too.

What changes

You don't need to open a dashboard by hand anymore, you can build flag operations right into your deploy flow! You could auto-adjust rollout percentages inside CI/CD, or have a script that detects anomalies automatically disable a flag as a kill switch. And since rollout and split let you control things at the percentage level, you can roll out a new feature gradually instead of flipping it on for everyone at once.

Dive Deep

It starts with creating an app.

wrangler flagship apps create "My Worker App" \
  --binding FLAGS \
  --update-config

This creates a Flagship app and sets up the binding for using it from a Worker, right in your wrangler.json (or wrangler.jsonc).

Once the app exists, it's time to create flags. Flags support these types:

  • Boolean
  • String
  • Number
  • JSON value
wrangler flagship flags create {APP_ID} new-checkout
wrangler flagship flags create {APP_ID} checkout-flow \
  --variation control=old-checkout \
  --variation treatment=new-checkout \
  --default control \
  --type string

After a flag exists, you can change its default variation, or use it as a kill switch by disabling and enabling it.

wrangler flagship flags update {APP_ID} checkout-flow --default treatment
wrangler flagship flags disable {APP_ID} checkout-flow
wrangler flagship flags enable {APP_ID} checkout-flow

One important detail: existing targeting rules keep applying unless you explicitly change or clear them.

For finer control over how you roll things out, you can use rollout, split, and rules. And here's the best part: you can change exposure without redeploying your Worker!

wrangler flagship flags rollout {APP_ID} new-checkout \
  --to on \
  --percentage 25 \
  --by user_id

This turns on the new-checkout flag for 25% of users, split by user_id.

wrangler flagship flags split {APP_ID} checkout-flow \
  --weight control=80 \
  --weight treatment=20 \
  --by user_id

This one splits traffic for the checkout-flow flag, 80% to control and 20% to treatment.

wrangler flagship flags rules update {APP_ID} checkout-flow \
  --priority 1 \
  --when "country equals US"

You can also create conditional targeting rules. In this example, the rule targets users whose country equals US, set at priority 1.

Wrap-up

  • Wrangler now has wrangler flagship commands for managing Flagship apps and feature flags from the terminal.
  • Flags support Boolean, string, number, and JSON value types.
  • Rollout works by percentage, split works by weight, and rules can target by priority-ordered conditions.
  • You can call these from CI/CD pipelines, scripts, and AI agents, and change exposure without redeploying your Worker.

This one's for developers running Workers with Wrangler, and anyone interested in gradual rollouts with feature flags!