跳转到内容
搜索文档

Wrangler 命令

最后更新 查看 MarkdownAgent 设置

使用 wrangler flagship 从命令行管理 Flagship 应用和功能标志。每个 wrangler flagship flags 命令都将应用 ID 作为第一个参数。大多数子命令然后采用标志键,例如 wrangler flagship flags get <APP_ID> <KEY>。列表样式命令,例如 wrangler flagship flags list <APP_ID>,仅采用应用 ID。

开始之前

验证 Wrangler

wrangler flagship 调用 Cloudflare API。在运行命令之前对 Wrangler 进行身份验证:

wrangler login

对于自动化,将 CLOUDFLARE_API_TOKEN 设置为具有适当 Flagship 权限的 API 令牌

权限 用途
flagship:read 列出应用、获取应用、列出标志、检查标志、评估标志和读取变更日志。
flagship:write 创建应用、更新应用、删除应用、创建标志、更新标志、更改默认值、推出、拆分、启用/禁用和删除标志。

大多数修改现有标志的命令会首先读取当前标志,然后将更新后的定义写回。对于这些工作流,请同时授予 flagship:readflagship:write

将 Flagship 绑定到您的 Worker

向您的 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 lsapps list 的别名。wrangler flagship apps rmapps delete 的别名。

wrangler flagship apps list 自动跟随分页,并显示账户中的所有应用。

创建应用将返回应用 ID,并显示要添加到您的 Wrangler 配置中的绑定片段:

wrangler flagship apps create checkout-service

要将新应用作为 Worker 绑定添加到您的 wrangler.jsonwrangler.jsonc 文件中,请传递 --binding

wrangler flagship apps create checkout-service --binding FLAGS

Wrangler 还支持使用 --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-checkoutpricing-page-layoutupload-limit

布尔标志

如果省略变体,Wrangler 将创建一个具有 on=trueoff=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

支持的值类型包括 booleanstringnumberjson。如果省略 --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"

使用 ANDOR 来组合条件。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"

ANDOR 出现在带引号的值或列表之外时,将被保留为逻辑运算符。如果值包含保留字或分隔符,如 ANDOR;,,请用单引号或双引号将它们包裹起来:

--rule 'serve=on; when=title equals "WAR AND PEACE" OR title equals "tom; jerry"'
--rule 'serve=on; when=country in ["US","CA"]'

对于 innot_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-checkout

wrangler flagship flags lsflags list 的别名。wrangler flagship flags inspectflags 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=500

Wrangler 会验证生成的变体集是否仍然具有单一的值类型,以及默认变体和目标定位规则是否仍然引用已知的变体。

您也可以通过 flags update 启用或禁用标志,不过 flags enableflags disable 对于终止开关工作流来说更简短:

wrangler flagship flags update <APP_ID> new-checkout --disable
wrangler flagship flags update <APP_ID> new-checkout --enable

更改默认变体

wrangler 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-banner

重新排序规则

Flagship 按升序 priority 评估规则;第一个匹配的规则获胜。使用 rules reorder 重新排序现有规则,而无需重写每个条件。

按照新顺序传递现有的优先级。Wrangler 会按照该顺序将它们重新编号为 1..n

wrangler flagship flags rules reorder <APP_ID> rate-limit-tier --order 2,1

如果现有的优先级是 1=strict2=relaxed,这会使 relaxed 的优先级为 1strict 的优先级为 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 onon 变体提供给 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 会变成 5080100 的累积阈值。权重为零的变体将被跳过。

--defaultsplit 配合使用,以在分桶无法运行时选择回退变体:

wrangler flagship flags split <APP_ID> checkout-flow \
	--weight v1=80 \
	--weight v2=20 \
	--default v1 \
	--by user_id
wrangler 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 evalflags 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_MATCHDEFAULTDISABLEDSPLIT

审计更改

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 --all

wrangler flagship flags historyflags changelog 的别名。

删除标志

wrangler flagship flags delete <APP_ID> coming-soon

使用 --force-y 跳过确认提示。如果您还使用 --json,则必须传递 --force 以确保确认提示不会出现在 JSON 输出中。

wrangler flagship flags delete <APP_ID> coming-soon --force

wrangler flagship flags rmflags delete 的别名。

通过传递应用 ID 及其后的多个键,来删除多个标志:

wrangler flagship flags delete <APP_ID> coming-soon old-checkout temporary-banner --force

通过 JSON 输出实现自动化

所有 wrangler flagship 命令都支持 --json。JSON 输出可隐藏 Wrangler 横幅,专供脚本使用。

使用 --json 时,删除命令需要提供 --force,以保证标准输出是有效的 JSON 格式。如果 rolloutsplit 要替换现有的包含条件的目标规则,使用 --json 时也同样需要 --force

批量命令,例如 flags deleteflags enableflags disable,如果某个标志失败,它们会继续处理剩余标志。在 JSON 模式下,部分失败会返回一个 JSON 错误对象,其中包含成功的 results 和逐标志的 failures

可以更新 wrangler.jsonwrangler.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]
  • [NAME]string required

    The name of the app

  • --jsonboolean default: false

    Return output as JSON

  • --use-remoteboolean

    Use a remote binding when adding the newly created resource to your config

  • --update-configboolean

    Automatically update your config file with the newly added resource

  • --bindingstring

    The binding name of this resource in your Worker

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship apps list

List Flagship apps

npx wrangler flagship apps list
  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship apps get

Get a Flagship app

npx wrangler flagship apps get [APP-ID]
  • [APP-ID]string required

    The ID of the app

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship apps update

Update a Flagship app

npx wrangler flagship apps update [APP-ID]
  • [APP-ID]string required

    The ID of the app

  • --namestring required

    The new name of the app

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship apps delete

Delete a Flagship app

npx wrangler flagship apps delete [APP-ID]
  • [APP-ID]string required

    One or more app IDs to delete

  • --forceboolean alias: --ydefault: false

    Skip the confirmation prompt

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags create

Create a feature flag in a Flagship app

npx wrangler flagship flags create [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --variationstring alias: --V

    A flag variation, in the form "name=value" (repeatable)

  • --default-variationstring alias: --default

    The name of the variation to serve by default (defaults to off for boolean flags, otherwise the first variation)

  • --typestring alias: --t

    The variation value type (inferred when omitted)

  • --descriptionstring alias: --d

    A description of the flag

  • --disabledboolean default: false

    Create the flag in a disabled state

  • --rulestring

    A 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-jsonstring

    A targeting rule as a JSON object (repeatable)

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags list

List feature flags in a Flagship app

npx wrangler flagship flags list [APP-ID]
  • [APP-ID]string required

    The ID of the app

  • --limitnumber

    The maximum number of flags to return (1-200)

  • --cursorstring

    The pagination cursor from a previous list call

  • --allboolean default: false

    Fetch every flag, following pagination automatically

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags get

Get a feature flag from a Flagship app

npx wrangler flagship flags get [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags update

Update a feature flag in a Flagship app

npx wrangler flagship flags update [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --enableboolean

    Enable the flag

  • --disableboolean

    Disable the flag

  • --descriptionstring alias: --d

    A new description for the flag (pass "" to clear it)

  • --default-variationstring alias: --default

    The name of the variation to serve by default

  • --typestring alias: --t

    The value type used to coerce --set-variation values

  • --set-variationstring

    Add or replace a variation, in the form "name=value"

  • --remove-variationstring

    Remove a variation by name

  • --rulestring

    Replace the flag's targeting rules (repeatable)

  • --rule-jsonstring

    Replace the flag's targeting rules using JSON (repeatable)

  • --add-rulestring

    Append a targeting rule, keeping the existing rules (repeatable)

  • --add-rule-jsonstring

    Append a targeting rule using JSON, keeping the existing rules (repeatable)

  • --clear-rulesboolean default: false

    Remove all targeting rules

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags set

Set the default variation served by a feature flag

npx wrangler flagship flags set [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --variationstring aliases: --variant, --Vrequired

    The variation to serve by default

  • --clear-rulesboolean default: false

    Clear targeting rules so this variation is always served

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags rules list

List targeting rules for a feature flag

npx wrangler flagship flags rules list [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use 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]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --prioritynumber required

    The priority of the rule to update

  • --servestring

    The variation to serve when this rule matches

  • --whenstring

    The rule conditions, using the same syntax as --rule when=...

  • --clear-conditionsboolean default: false

    Remove conditions so the rule matches all contexts

  • --rolloutstring

    The rollout, in the form "percentage" or "percentage%@attribute"

  • --clear-rolloutboolean default: false

    Remove the rollout from this rule

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use 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]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --prioritynumber required

    The priority of the rule to delete

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags rules reorder

Reorder targeting rules for a feature flag

npx wrangler flagship flags rules reorder [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --orderstring required

    Comma-separated existing rule priorities in their new order, for example 2,1,3

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags split

Split traffic across variations by percentage

npx wrangler flagship flags split [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --weightstring alias: --w

    A variation weight, in the form "variation=weight" (repeatable)

  • --bystring

    Context attribute used for sticky bucketing

  • --default-variationstring alias: --default

    Fallback variation when bucketing cannot run

  • --forceboolean alias: --ydefault: false

    Skip the confirmation prompt when this split replaces existing targeting rules

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags rollout

Roll out one variation to a percentage of traffic

npx wrangler flagship flags rollout [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --tostring required

    Variation to roll out

  • --percentagenumber required

    Percentage of traffic to serve the rollout variation (0-100)

  • --bystring

    Context attribute used for sticky bucketing

  • --from-variationstring alias: --from

    Fallback variation for the remaining traffic

  • --forceboolean alias: --ydefault: false

    Skip the confirmation prompt when this rollout replaces existing targeting rules

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags enable

Enable a feature flag

npx wrangler flagship flags enable [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    One or more flag keys to enable

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags disable

Disable a feature flag

npx wrangler flagship flags disable [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    One or more flag keys to disable

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags evaluate

Evaluate a feature flag with optional context

npx wrangler flagship flags evaluate [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --contextstring aliases: --ctx, --C

    Evaluation context, in the form "name=value" (repeatable)

  • --targeting-keystring

    Stable bucketing key for percentage rollouts

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags delete

Delete a feature flag from a Flagship app

npx wrangler flagship flags delete [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    One or more flag keys to delete

  • --forceboolean alias: --ydefault: false

    Skip the confirmation prompt

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

flagship flags changelog

Show the changelog for a feature flag

npx wrangler flagship flags changelog [APP-ID] [KEY]
  • [APP-ID]string required

    The ID of the app

  • [KEY]string required

    The key of the flag

  • --limitnumber

    The maximum number of entries to return (1-200)

  • --cursorstring

    The pagination cursor from a previous changelog call

  • --allboolean default: false

    Fetch every entry, following pagination automatically

  • --jsonboolean default: false

    Return output as JSON

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --experimental-provisionboolean aliases: --x-provisiondefault: true

    Experimental: Enable automatic resource provisioning

  • --experimental-auto-createboolean alias: --x-auto-createdefault: true

    Automatically provision draft bindings with new resources

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

这篇文档对您有帮助吗?