使用 wrangler flagship 从命令行管理 Flagship 应用和功能标志。每个 wrangler flagship flags 命令都将应用 ID 作为第一个参数。大多数子命令然后采用标志键,例如 wrangler flagship flags get <APP_ID> <KEY>。列表样式命令,例如 wrangler flagship flags list <APP_ID>,仅采用应用 ID。
wrangler flagship 调用 Cloudflare API。在运行命令之前对 Wrangler 进行身份验证:
wrangler login对于自动化,将 CLOUDFLARE_API_TOKEN 设置为具有适当 Flagship 权限的 API 令牌。
| 权限 | 用途 |
|---|---|
flagship:read |
列出应用、获取应用、列出标志、检查标志、评估标志和读取变更日志。 |
flagship:write |
创建应用、更新应用、删除应用、创建标志、更新标志、更改默认值、推出、拆分、启用/禁用和删除标志。 |
大多数修改现有标志的命令会首先读取当前标志,然后将更新后的定义写回。对于这些工作流,请同时授予 flagship:read 和 flagship:write。
向您的 Worker 项目添加 Flagship 绑定,以便您的 Worker 代码可以在运行时以低延迟评估标志:
{
"$schema": "./node_modules/wrangler/config-schema.json",
"flagship": [
{
"binding": "FLAGS",
"app_id": "<APP_ID>"
}
]
}[[flagship]]
binding = "FLAGS"
app_id = "<APP_ID>"创建一个布尔标志,为用户评估它,并将其作为终止开关禁用:
# 没有提供变体时,Wrangler 会创建 on=true, off=false,
# 并且默认提供 off。
wrangler flagship flags create <APP_ID> new-checkout
# 为用户评估标志。
wrangler flagship flags evaluate <APP_ID> new-checkout --targeting-key user-42
# 立即禁用标志。被禁用的标志总是提供其默认变体。
wrangler flagship flags disable <APP_ID> new-checkout应用对相关的标志进行分组。一种常见的模式是每个服务、Worker 或产品表面一个应用。
| 任务 | 命令 |
|---|---|
| 创建应用 | wrangler flagship apps create <NAME> |
| 列出应用 | wrangler flagship apps list |
| 获取应用 | wrangler flagship apps get <APP_ID> |
| 重命名应用 | wrangler flagship apps update <APP_ID> --name <NAME> |
| 删除应用 | wrangler flagship apps delete <APP_ID> |
wrangler flagship apps ls 是 apps list 的别名。wrangler flagship apps rm 是 apps delete 的别名。
wrangler flagship apps list 自动跟随分页,并显示账户中的所有应用。
创建应用将返回应用 ID,并显示要添加到您的 Wrangler 配置中的绑定片段:
wrangler flagship apps create checkout-service要将新应用作为 Worker 绑定添加到您的 wrangler.json 或 wrangler.jsonc 文件中,请传递 --binding:
wrangler flagship apps create checkout-service --binding FLAGSWrangler 还支持使用 --update-config,在提示输入绑定名称后更新您的 JSON 或 JSONC 配置。
对于非 JSON 配置文件,Wrangler 会打印绑定片段,但不会自动编辑文件。
当使用 --json 时,apps create 会以 JSON 格式打印已创建的应用,并且不会提示或更新配置。
对于脚本,从 JSON 输出中捕获应用 ID:
APP_ID=$(wrangler flagship apps create checkout-service --json | jq -r '.id')删除应用将删除其所有标志和变更日志历史记录。如果某个 Worker 仍通过 Flagship 绑定引用该应用,API 会拒绝删除应用。
使用 --force 或 -y 跳过删除确认提示。如果您还使用 --json,则必须传递 --force 以确保确认提示不会出现在 JSON 输出中。
wrangler flagship apps delete <APP_ID> --force通过传递多个应用 ID 删除多个应用:
wrangler flagship apps delete <APP_ID_1> <APP_ID_2> <APP_ID_3> --force标志键在应用内是唯一的。请使用描述受控行为的稳定键,例如 new-checkout、pricing-page-layout 或 upload-limit。
如果省略变体,Wrangler 将创建一个具有 on=true、off=false 且默认变体为 off 的布尔标志。
wrangler flagship flags create <APP_ID> new-checkout使用 --variation (-V) 以 name=value 的形式添加每个变体。使用 --default 选择后备变体。
# 字符串标志。
wrangler flagship flags create <APP_ID> checkout-flow \
-V v1=old-checkout \
-V v2=new-checkout \
--default v1 \
--type string
# 数字标志。
wrangler flagship flags create <APP_ID> upload-limit \
-V free=10 \
-V pro=100 \
-V enterprise=1000 \
--default free \
--type number
# JSON 标志。
wrangler flagship flags create <APP_ID> theme-config \
-V 'light={"bg":"#ffffff","fg":"#111111"}' \
-V 'dark={"bg":"#111111","fg":"#ffffff"}' \
--default light \
--type json支持的值类型包括 boolean、string、number 和 json。如果省略 --type,Wrangler 将独立推断每个值的标量类型。
标志上的所有变体必须使用相同的值类型。Wrangler 在发送请求之前将拒绝解析为混合类型的标志(例如一个布尔值和一个数字)。显式传递 --type 可强制每个变体转换为相同的类型。
使用 --description (-d) 记录标志的用途:
wrangler flagship flags create <APP_ID> checkout-flow \
-V v1=old-checkout \
-V v2=new-checkout \
--default v1 \
--type string \
--description "Controls which checkout experience is served"标志键和变体名称可以包含字母、数字、连字符和下划线。保持键的稳定,因为应用程序代码是通过键来评估标志的。
使用 --disabled 创建一个标志,该标志在其被启用之前将始终提供默认变体。
wrangler flagship flags create <APP_ID> coming-soon \
-V on=true \
-V off=false \
--default off \
--disabled目标定位规则决定为给定评估上下文提供哪种变体。使用 --rule 或 --rule-json 传递规则。
紧凑的 --rule 语法使用分号分隔的段:
serve=<VARIATION>; when=<CONDITIONS>; rollout=<PERCENT>%@<ATTRIBUTE>; priority=<NUMBER>| 段 | 是否必填 | 描述 |
|---|---|---|
serve |
是 | 当规则匹配时提供的变体。必须引用现有的变体。 |
when |
否 | 与评估上下文匹配的条件。如果省略,该规则匹配所有上下文。 |
rollout |
否 | 接收变体的匹配流量的百分比。该属性控制粘性分桶。 |
priority |
否 | 评估顺序。较小的数字先运行。如果省略,Wrangler 将按顺序分配优先级。 |
wrangler flagship flags create <APP_ID> premium-banner \
-V on=true \
-V off=false \
--default off \
--rule "serve=on; when=plan equals enterprise AND country in [US,CA]; rollout=25%@user_id"条件将评估上下文中的属性与规则值进行比较。紧凑语法支持所有 Flagship 运算符:
--rule "serve=on; when=plan equals pro"
--rule "serve=on; when=country in [US,CA,UK]"
--rule "serve=off; when=email ends_with @example.com"
--rule "serve=strict; when=score less_than 20"使用 AND 和 OR 来组合条件。AND 的优先级高于 OR。
# 两个条件都必须匹配。
--rule "serve=on; when=plan equals pro AND country equals US"
# 任意一个条件匹配即可。
--rule "serve=on; when=plan equals enterprise OR plan equals team"
# 等同于: (plan=pro AND country=US) OR plan=enterprise。
--rule "serve=on; when=plan equals pro AND country equals US OR plan equals enterprise"当 AND 和 OR 出现在带引号的值或列表之外时,将被保留为逻辑运算符。如果值包含保留字或分隔符,如 AND、OR、; 或 ,,请用单引号或双引号将它们包裹起来:
--rule 'serve=on; when=title equals "WAR AND PEACE" OR title equals "tom; jerry"'
--rule 'serve=on; when=country in ["US","CA"]'对于 in 和 not_in,请传递用方括号括起来的列表。Wrangler 会在发送请求前拒绝格式错误的列表、空列表项、未闭合的引号和未匹配的方括号。
对于深度嵌套的逻辑组,或者如果您更倾向于直接传递 API 规则形状,请使用 --rule-json。Wrangler 会根据 Flagship 规则模式验证 --rule-json,并拒绝未知的或冲突的字段。
wrangler flagship flags create <APP_ID> beta-features \
-V on=true \
-V off=false \
--default off \
--rule-json '{"serve_variation":"on","conditions":[{"logical_operator":"OR","clauses":[{"attribute":"beta","operator":"equals","value":true},{"attribute":"plan","operator":"equals","value":"enterprise"}]}]}'重复使用 --rule 或 --rule-json 来声明多条规则。规则将按优先级顺序进行评估。第一个匹配的规则获胜。
wrangler flagship flags create <APP_ID> rate-limit-tier \
-V strict=50 \
-V normal=200 \
-V relaxed=1000 \
--default normal \
--type number \
--rule "serve=strict; when=score less_than 20" \
--rule "serve=relaxed; when=score greater_than_or_equals 90"Wrangler 会在发送请求之前验证重复的规则优先级、重复的变体名称、格式错误的列表、非有限数值(如 Infinity)以及未知的变体名称。
列出应用中的标志:
wrangler flagship flags list <APP_ID>列表命令已分页。使用 --limit 和 --cursor 进行手动分页,或使用 --all 获取所有页面。
wrangler flagship flags list <APP_ID> --limit 50
wrangler flagship flags list <APP_ID> --cursor <CURSOR>
wrangler flagship flags list <APP_ID> --all检查完整的标志定义:
wrangler flagship flags get <APP_ID> new-checkoutwrangler flagship flags ls 是 flags list 的别名。wrangler flagship flags inspect 是 flags get 的别名。
wrangler flagship flags update 读取当前标志,应用您的更改,并将完整的标志定义写回 API。
wrangler flagship flags update <APP_ID> new-checkout \
--description "Redesigned checkout experience"
wrangler flagship flags update <APP_ID> upload-limit \
--set-variation team=500
wrangler flagship flags update <APP_ID> upload-limit \
--remove-variation team要向现有标志添加变体,请设置新的变体名称和值:
wrangler flagship flags update <APP_ID> checkout-flow \
--set-variation experiment=new-checkout-v2传递一个空描述以清除它:
wrangler flagship flags update <APP_ID> new-checkout --description ""当您在现有标志上添加或替换变体时,如果 Wrangler 应该将新值强制转换为特定类型,请使用 --type:
wrangler flagship flags update <APP_ID> upload-limit \
--type number \
--set-variation team=500Wrangler 会验证生成的变体集是否仍然具有单一的值类型,以及默认变体和目标定位规则是否仍然引用已知的变体。
您也可以通过 flags update 启用或禁用标志,不过 flags enable 和 flags disable 对于终止开关工作流来说更简短:
wrangler flagship flags update <APP_ID> new-checkout --disable
wrangler flagship flags update <APP_ID> new-checkout --enablewrangler flagship flags set <APP_ID> checkout-flow --variation v2如果应该向所有人提供新默认值,请使用 --clear-rules。
wrangler flagship flags set <APP_ID> checkout-flow --variation v2 --clear-rules使用 --rule 或 --rule-json 替换整个规则集:
wrangler flagship flags update <APP_ID> premium-banner \
--rule "serve=on; when=plan equals pro AND country not_in [CN,RU]"使用 --add-rule 或 --add-rule-json 附加规则而不更改现有规则:
wrangler flagship flags update <APP_ID> premium-banner \
--add-rule "serve=off; when=account_age less_than 7"
wrangler flagship flags update <APP_ID> premium-banner \
--add-rule-json '{"serve_variation":"off","conditions":[{"attribute":"country","operator":"in","value":["CN","RU"]}]}'清除所有规则:
wrangler flagship flags update <APP_ID> premium-banner --clear-rules使用 rules list 查看您可以使用特定于规则的命令定位的优先级:
wrangler flagship flags rules list <APP_ID> premium-bannerFlagship 按升序 priority 评估规则;第一个匹配的规则获胜。使用 rules reorder 重新排序现有规则,而无需重写每个条件。
按照新顺序传递现有的优先级。Wrangler 会按照该顺序将它们重新编号为 1..n:
wrangler flagship flags rules reorder <APP_ID> rate-limit-tier --order 2,1如果现有的优先级是 1=strict 和 2=relaxed,这会使 relaxed 的优先级为 1,strict 的优先级为 2。
使用 rules update 按优先级编辑一个规则,同时保留规则集的其余部分。
仅更改推出百分比:
wrangler flagship flags rules update <APP_ID> premium-banner \
--priority 1 \
--rollout 50%@user_id更改由规则提供的变体:
wrangler flagship flags rules update <APP_ID> premium-banner \
--priority 1 \
--serve off更改规则的条件:
wrangler flagship flags rules update <APP_ID> premium-banner \
--priority 1 \
--when "plan equals enterprise OR plan equals team"从规则中删除条件,使其匹配每个评估上下文:
wrangler flagship flags rules update <APP_ID> premium-banner \
--priority 1 \
--clear-conditions从规则中删除推出:
wrangler flagship flags rules update <APP_ID> premium-banner \
--priority 1 \
--clear-rollout使用 rules delete 按优先级删除一条规则:
wrangler flagship flags rules delete <APP_ID> premium-banner --priority 2删除规则后,Wrangler 会重新编号剩余规则,以使优先级保持连续。
禁用标志是一个即时的终止开关。禁用的标志会忽略目标定位规则并提供其默认变体。
wrangler flagship flags disable <APP_ID> new-checkout
wrangler flagship flags enable <APP_ID> new-checkout通过传递应用 ID 后跟多个键来启用或禁用应用中的多个标志:
wrangler flagship flags disable <APP_ID> new-checkout dark-mode premium-banner
wrangler flagship flags enable <APP_ID> new-checkout dark-mode premium-banner使用 rollout 为一定比例的流量提供一个变体。
wrangler flagship flags rollout <APP_ID> new-checkout \
--to on \
--percentage 25 \
--by user_id使用 --from-variation (别名 --from) 为剩余流量选择后备变体。推出百分比 0 将移除推出规则,并保持标志当前默认变体不变。
rollout 将您提供的百分比直接发送给 Flagship。例如,--percentage 25 --to on 将 on 变体提供给 25% 的分桶流量。剩余的流量会回退到标志的默认变体。
使用 split 进行 A/B 测试或多路流量分配。Wrangler 将权重转换为累计的推出阈值。
wrangler flagship flags split <APP_ID> checkout-flow \
--weight v1=80 \
--weight v2=20 \
--by user_id-w 是 --weight 的别名。每个变体只能被加权一次,并且权重必须是有限的非负数。
权重是相对的。Wrangler 会合计这些权重,将每个权重转换为总数的百分比,并向 Flagship 发送累积阈值。例如,--weight v1=80 --weight v2=20 会发送两条生成的规则:一条针对 v1 的推出百分比为 80,另一条针对 v2 的推出百分比为 100。这会为 v1 创建 0-80 的桶范围,为 v2 创建 80-100 的桶范围。
如果有三个权重,--weight a=50 --weight b=30 --weight c=20 会变成 50、80 和 100 的累积阈值。权重为零的变体将被跳过。
将 --default 与 split 配合使用,以在分桶无法运行时选择回退变体:
wrangler flagship flags split <APP_ID> checkout-flow \
--weight v1=80 \
--weight v2=20 \
--default v1 \
--by user_idwrangler flagship flags rollout <APP_ID> new-checkout --to on --percentage 100 --force在 CLI 中评估一个标志,以验证特定上下文将收到什么。
wrangler flagship flags evaluate <APP_ID> new-checkout
wrangler flagship flags evaluate <APP_ID> new-checkout \
--targeting-key user-42
wrangler flagship flags evaluate <APP_ID> premium-banner \
--context plan=enterprise \
--context country=US \
--targeting-key user-99使用 --targeting-key 获得稳定的百分比推出分桶。通过 --context name=value 传递每个上下文属性。wrangler flagship flags eval 是 flags evaluate 的别名。
--context 可以重复使用。--ctx 和 -C 是别名:
wrangler flagship flags evaluate <APP_ID> premium-banner \
-C plan=enterprise \
-C country=US \
--targeting-key user-99上下文值作为字符串被发送至评估端点。使用与您的定位规则预期相同的属性名称。
评估输出包括:
| 字段 | 描述 |
|---|---|
value |
返回该上下文的标志值。 |
variant |
为该上下文选择的变体。 |
reason |
为什么返回该值:TARGETING_MATCH、DEFAULT、DISABLED 或 SPLIT。 |
Flagship 记录每个标志的创建、更新和删除事件。查看变更日志历史记录,最新优先:
wrangler flagship flags changelog <APP_ID> new-checkout将分页控件用于较长的历史记录:
wrangler flagship flags changelog <APP_ID> new-checkout --limit 10
wrangler flagship flags changelog <APP_ID> new-checkout --cursor <CURSOR>
wrangler flagship flags changelog <APP_ID> new-checkout --allwrangler flagship flags history 是 flags changelog 的别名。
wrangler flagship flags delete <APP_ID> coming-soon使用 --force 或 -y 跳过确认提示。如果您还使用 --json,则必须传递 --force 以确保确认提示不会出现在 JSON 输出中。
wrangler flagship flags delete <APP_ID> coming-soon --forcewrangler flagship flags rm 是 flags delete 的别名。
通过传递应用 ID 及其后的多个键,来删除多个标志:
wrangler flagship flags delete <APP_ID> coming-soon old-checkout temporary-banner --force所有 wrangler flagship 命令都支持 --json。JSON 输出可隐藏 Wrangler 横幅,专供脚本使用。
使用 --json 时,删除命令需要提供 --force,以保证标准输出是有效的 JSON 格式。如果 rollout 和 split 要替换现有的包含条件的目标规则,使用 --json 时也同样需要 --force。
批量命令,例如 flags delete、flags enable 和 flags disable,如果某个标志失败,它们会继续处理剩余标志。在 JSON 模式下,部分失败会返回一个 JSON 错误对象,其中包含成功的 results 和逐标志的 failures。
可以更新 wrangler.json 或 wrangler.jsonc 的命令(例如 apps create --binding),在使用 --json 时不会提示或更新配置。
创建一个应用,获取其 ID,然后创建一个标志:
APP_ID=$(wrangler flagship apps create checkout-service --json | jq -r '.id')
wrangler flagship flags create "$APP_ID" new-checkout --json在循环中删除多个应用:
for app_id in <APP_ID_1> <APP_ID_2> <APP_ID_3>; do
wrangler flagship apps delete "$app_id" --force
done或直接传递应用 ID:
wrangler flagship apps delete <APP_ID_1> <APP_ID_2> <APP_ID_3> --force以下参考由 Wrangler 的 flagship 命令定义生成。
flagship apps create
Create a Flagship app
npx wrangler flagship apps create [NAME]yarn wrangler flagship apps create [NAME]pnpm wrangler flagship apps create [NAME][NAME]stringrequiredThe name of the app
--jsonbooleandefault: falseReturn output as JSON
--use-remotebooleanUse a remote binding when adding the newly created resource to your config
--update-configbooleanAutomatically update your config file with the newly added resource
--bindingstringThe binding name of this resource in your Worker
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship apps list
List Flagship apps
npx wrangler flagship apps listyarn wrangler flagship apps listpnpm wrangler flagship apps list--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship apps get
Get a Flagship app
npx wrangler flagship apps get [APP-ID]yarn wrangler flagship apps get [APP-ID]pnpm wrangler flagship apps get [APP-ID][APP-ID]stringrequiredThe ID of the app
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship apps update
Update a Flagship app
npx wrangler flagship apps update [APP-ID]yarn wrangler flagship apps update [APP-ID]pnpm wrangler flagship apps update [APP-ID][APP-ID]stringrequiredThe ID of the app
--namestringrequiredThe new name of the app
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship apps delete
Delete a Flagship app
npx wrangler flagship apps delete [APP-ID]yarn wrangler flagship apps delete [APP-ID]pnpm wrangler flagship apps delete [APP-ID][APP-ID]stringrequiredOne or more app IDs to delete
--forcebooleanalias: --ydefault: falseSkip the confirmation prompt
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags create
Create a feature flag in a Flagship app
npx wrangler flagship flags create [APP-ID] [KEY]yarn wrangler flagship flags create [APP-ID] [KEY]pnpm wrangler flagship flags create [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--variationstringalias: --VA flag variation, in the form "name=value" (repeatable)
--default-variationstringalias: --defaultThe name of the variation to serve by default (defaults to off for boolean flags, otherwise the first variation)
--typestringalias: --tThe variation value type (inferred when omitted)
--descriptionstringalias: --dA description of the flag
--disabledbooleandefault: falseCreate the flag in a disabled state
--rulestringA targeting rule, e.g. "serve=on; when=plan equals pro AND region in [US,CA]; rollout=30%@user_id". Conditions support AND/OR; priority is optional and defaults to declaration order (repeatable)
--rule-jsonstringA targeting rule as a JSON object (repeatable)
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags list
List feature flags in a Flagship app
npx wrangler flagship flags list [APP-ID]yarn wrangler flagship flags list [APP-ID]pnpm wrangler flagship flags list [APP-ID][APP-ID]stringrequiredThe ID of the app
--limitnumberThe maximum number of flags to return (1-200)
--cursorstringThe pagination cursor from a previous list call
--allbooleandefault: falseFetch every flag, following pagination automatically
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags get
Get a feature flag from a Flagship app
npx wrangler flagship flags get [APP-ID] [KEY]yarn wrangler flagship flags get [APP-ID] [KEY]pnpm wrangler flagship flags get [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags update
Update a feature flag in a Flagship app
npx wrangler flagship flags update [APP-ID] [KEY]yarn wrangler flagship flags update [APP-ID] [KEY]pnpm wrangler flagship flags update [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--enablebooleanEnable the flag
--disablebooleanDisable the flag
--descriptionstringalias: --dA new description for the flag (pass "" to clear it)
--default-variationstringalias: --defaultThe name of the variation to serve by default
--typestringalias: --tThe value type used to coerce --set-variation values
--set-variationstringAdd or replace a variation, in the form "name=value"
--remove-variationstringRemove a variation by name
--rulestringReplace the flag's targeting rules (repeatable)
--rule-jsonstringReplace the flag's targeting rules using JSON (repeatable)
--add-rulestringAppend a targeting rule, keeping the existing rules (repeatable)
--add-rule-jsonstringAppend a targeting rule using JSON, keeping the existing rules (repeatable)
--clear-rulesbooleandefault: falseRemove all targeting rules
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags set
Set the default variation served by a feature flag
npx wrangler flagship flags set [APP-ID] [KEY]yarn wrangler flagship flags set [APP-ID] [KEY]pnpm wrangler flagship flags set [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--variationstringaliases: --variant, --VrequiredThe variation to serve by default
--clear-rulesbooleandefault: falseClear targeting rules so this variation is always served
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags rules list
List targeting rules for a feature flag
npx wrangler flagship flags rules list [APP-ID] [KEY]yarn wrangler flagship flags rules list [APP-ID] [KEY]pnpm wrangler flagship flags rules list [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags rules update
Update one targeting rule for a feature flag
npx wrangler flagship flags rules update [APP-ID] [KEY]yarn wrangler flagship flags rules update [APP-ID] [KEY]pnpm wrangler flagship flags rules update [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--prioritynumberrequiredThe priority of the rule to update
--servestringThe variation to serve when this rule matches
--whenstringThe rule conditions, using the same syntax as --rule when=...
--clear-conditionsbooleandefault: falseRemove conditions so the rule matches all contexts
--rolloutstringThe rollout, in the form "percentage" or "percentage%@attribute"
--clear-rolloutbooleandefault: falseRemove the rollout from this rule
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags rules delete
Delete one targeting rule from a feature flag
npx wrangler flagship flags rules delete [APP-ID] [KEY]yarn wrangler flagship flags rules delete [APP-ID] [KEY]pnpm wrangler flagship flags rules delete [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--prioritynumberrequiredThe priority of the rule to delete
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags rules reorder
Reorder targeting rules for a feature flag
npx wrangler flagship flags rules reorder [APP-ID] [KEY]yarn wrangler flagship flags rules reorder [APP-ID] [KEY]pnpm wrangler flagship flags rules reorder [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--orderstringrequiredComma-separated existing rule priorities in their new order, for example 2,1,3
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags split
Split traffic across variations by percentage
npx wrangler flagship flags split [APP-ID] [KEY]yarn wrangler flagship flags split [APP-ID] [KEY]pnpm wrangler flagship flags split [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--weightstringalias: --wA variation weight, in the form "variation=weight" (repeatable)
--bystringContext attribute used for sticky bucketing
--default-variationstringalias: --defaultFallback variation when bucketing cannot run
--forcebooleanalias: --ydefault: falseSkip the confirmation prompt when this split replaces existing targeting rules
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags rollout
Roll out one variation to a percentage of traffic
npx wrangler flagship flags rollout [APP-ID] [KEY]yarn wrangler flagship flags rollout [APP-ID] [KEY]pnpm wrangler flagship flags rollout [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--tostringrequiredVariation to roll out
--percentagenumberrequiredPercentage of traffic to serve the rollout variation (0-100)
--bystringContext attribute used for sticky bucketing
--from-variationstringalias: --fromFallback variation for the remaining traffic
--forcebooleanalias: --ydefault: falseSkip the confirmation prompt when this rollout replaces existing targeting rules
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags enable
Enable a feature flag
npx wrangler flagship flags enable [APP-ID] [KEY]yarn wrangler flagship flags enable [APP-ID] [KEY]pnpm wrangler flagship flags enable [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredOne or more flag keys to enable
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags disable
Disable a feature flag
npx wrangler flagship flags disable [APP-ID] [KEY]yarn wrangler flagship flags disable [APP-ID] [KEY]pnpm wrangler flagship flags disable [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredOne or more flag keys to disable
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags evaluate
Evaluate a feature flag with optional context
npx wrangler flagship flags evaluate [APP-ID] [KEY]yarn wrangler flagship flags evaluate [APP-ID] [KEY]pnpm wrangler flagship flags evaluate [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--contextstringaliases: --ctx, --CEvaluation context, in the form "name=value" (repeatable)
--targeting-keystringStable bucketing key for percentage rollouts
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags delete
Delete a feature flag from a Flagship app
npx wrangler flagship flags delete [APP-ID] [KEY]yarn wrangler flagship flags delete [APP-ID] [KEY]pnpm wrangler flagship flags delete [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredOne or more flag keys to delete
--forcebooleanalias: --ydefault: falseSkip the confirmation prompt
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
flagship flags changelog
Show the changelog for a feature flag
npx wrangler flagship flags changelog [APP-ID] [KEY]yarn wrangler flagship flags changelog [APP-ID] [KEY]pnpm wrangler flagship flags changelog [APP-ID] [KEY][APP-ID]stringrequiredThe ID of the app
[KEY]stringrequiredThe key of the flag
--limitnumberThe maximum number of entries to return (1-200)
--cursorstringThe pagination cursor from a previous changelog call
--allbooleandefault: falseFetch every entry, following pagination automatically
--jsonbooleandefault: falseReturn output as JSON
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile