command-flag-change

A procedure for changing options accepted by an existing CLI command. It covers option definitions, required values, examples, validation, authentication-related options, and generated documentation.

In plain words
What is it for?
Use it when adding, removing, renaming, or changing the default or required status of a command flag.
Why use it?
It reduces the chance that a changed option is parsed differently from how it is documented or configured.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/modelstudioai/cli/command-flag-change
Clone the repo
git clone --depth 1 https://github.com/modelstudioai/cli
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 859 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00859
Opus 5 $0.00000 $0.00430
Sonnet 5 $0.00000 $0.00172
Haiku 4.5 $0.00000 $0.00086

Measured yesterday against content hash 5e14a3a7184e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

command-flag-change scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/command-flag-change.md · 58 lines

What it actually says

命令选项变更

触发条件

  • 给已有命令新增 --flag <value>
  • 改 flag 默认值
  • 删除 / 重命名已有 flag
  • 把 flag 从可选变成必填(或反向)

必查清单

A. 命令文件本身

  • packages/commands/src/commands/<group>/<action>.ts:
    • defineCommand({ flags: { ... } }) 里增删/改 camelCase flag key 与 { type, valueHint, description, required }
    • usageArgs 字段只写参数片段(如 "--message <text> [flags]"),不写 bl <path>
    • exampleArgs 数组覆盖新 flag 至少一个示例,同样不写 bin/path 前缀
    • run() 里只从 ctx.flags 读取本命令 flag,从 ctx.settings 读取全局/config 解析结果
    • 类型由 ParsedFlags<typeof FLAGS> 推导;避免手写 flags.x as number 这类断言
    • 单 flag 必填用 required: true;跨 flag / 值相关校验放 validate
    • 默认值 fallback 写在命令实现或 Settings 解析层,不要重复解析 env/config

B. 鉴权 / 全局选项

  • 如果是全局 flag(所有命令通用),改 packages/core/src/types/command.tsGLOBAL_FLAGS
  • 如果是凭证域 flag,优先确认是否属于 MODEL_AUTH_FLAGSCONSOLE_AUTH_FLAGS;不要在单个命令里重复声明
  • 如果新 flag 影响有效配置面,改 packages/core/src/config/schema.tsSettings 接口
  • 如果对应 env var 或 config 文件字段,改 packages/core/src/config/loader.tsbuildSettings

C. 文档层

  • README.md / README.zh.md 如果在示例里展示了相关命令,补充新 flag
  • pnpm --filter bailian-cli run generate:reference,让各 skills/<skill>/reference/ 与命令一致(勿手改;改完提交)

D. 测试层

  • cli-e2e-tests.mdpackages/cli/tests/e2e/<command>.e2e.test.ts 增加新 flag 的断言(含缺参、--help、dry-run 若适用)
  • 删除 flag 时,清掉相关测试用例

E. 重命名特殊处理

  • 全仓 grep 旧 flag 名(包括 --old-nameoldNameold_name 三种形态,因为 args.ts 会做 kebab→camel 转换)
  • 必要时保留deprecated alias(老 flag 仍可用,但 stderr 警告 → 下版本删)

完成后自查

pnpm -F bailian-cli exec tsx src/main.ts <command> --help          # 看新 flag 出现在 Flags
pnpm -F bailian-cli exec tsx src/main.ts <command> --new-flag x   # 实测一遍

常见漏点

  • ✗ 加了 array 型 flag 但没考虑用户可能传多次
  • ✗ 改默认值忘记更新 description 里的 "(default: xxx)" 文案
  • ✗ 在 usageArgs / exampleArgs 里写死 bl <path>,导致其它产品入口复用时 help 错
  • ✗ required flag 缺失又在 run() 里重复手写校验,与 parser/validate 的错误文案不一致
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 58 lines · 0 tokens per session scan A 5e14a3a7184e

Subscribe to this mod's changes

command-flag-change is an agent published in the GitHub repository modelstudioai/cli (320 stars, last pushed 4d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 859 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.