flag-add
Add a CLI flag to shipctl end-to-end — argument parser definition, help text, shell completion scripts, documentation, and tests. Use when adding a new option or flag, when extending an existing subcommand, or when asked to "add a --flag-name option".
- License 许可
- MIT
- 最近更新
- 2026-11-06
- Stars
- ★ 18
- Forks
- 1
01 前言 Front Matter
- name
- flag-add
- metadata
- { "forged-by": "cursor-agent", "last-used": "2026-06-01", "forged-from": "session-2026-04-02", "usage-count": "22", "forged-reason": "Added --output, --format, and --timeout flags in three consecutive tasks with identical boilerplate — parser, help, completion, docs, test" }
- description
- Add a CLI flag to shipctl end-to-end — argument parser definition, help text, shell completion scripts, documentation, and tests. Use when adding a new option or flag, when extending an existing subcommand, or when asked to "add a --flag-name option".
02 资源文件 2
- 参考文档Workflows/Audit.md1.7 KB
- 参考文档Workflows/QuickCheck.md854 B
03 SKILL.md 正文
Flag Add
Add a new CLI flag to a shipctl command end-to-end.
Inputs
- Command path (e.g.,
release,build cross,config set) - Flag name (long form, e.g.,
--output-dir) - Short alias (optional, e.g.,
-o) - Type (string, bool, integer, path)
- Default value (or
requiredif mandatory) - Description (one-line, used in help text and docs)
Steps
-
Define the flag in the parser
For Rust +
clap:// In the relevant Args struct (src/cmd/{command}.rs) #[arg(long, short = '{alias}', default_value = "{default}", help = "{description}")] pub {flag_name}: {type},For Go +
cobra:// In the relevant command file (cmd/{command}.go) cmd.Flags().{TypeVar}(&opts.{FlagName}, "{flag-name}", {default}, "{description}") -
Wire the value into the command logic Pass the flag value through to whatever downstream call needs it. Verify the happy path compiles:
cargo check/go build ./.... -
Update the help text Run
shipctl {command} --helpand confirm the flag appears with the correct description and default. -
Add shell completions Regenerate completions (invoke
manpage-syncskill, or manually):shipctl completions bash > completions/shipctl.bash shipctl completions zsh > completions/_shipctl shipctl completions fish > completions/shipctl.fishCommit the updated completion files.
-
Update documentation Edit
docs/reference/{command}.md:- Add a row to the Flags table:
| --{flag-name} | {type} | {default} | {description} | - Add an Examples entry if the flag has a non-obvious use
- Add a row to the Flags table:
-
Write or extend a test
// tests/cmd_{command}.rs #[test] fn test_{flag_name}_flag() { let output = Command::cargo_bin("shipctl").unwrap() .arg("{command}") .arg("--{flag-name}").arg("{test-value}") .assert().success(); // assert output contains expected value } -
Verify the full suite passes
cargo test --workspace
Conventions
- Long flags are kebab-case (
--output-dir, not--outputDir) - Boolean flags use
--flag/--no-flagpair when toggling a default-on behavior - Flags that accept file paths validate existence (return error with
ENOENTmessage) - Help text: imperative mood, no trailing period, max 72 chars
- Short aliases: only for the top 10 most-used flags; don't add new ones without team sign-off
Edge Cases
- Conflicting short alias: Run
shipctl --helpon the parent command to audit existing aliases; pick a different letter or omit the alias. - Required flag without a default: Add a clear error message with the flag name and an example invocation.
- Flag affects multiple subcommands: Define it at the parent command level with
PersistentFlags()(cobra) orArgsflattening (clap). - Boolean flag default is
true: Document this prominently; many users expect flags to be opt-in.
04 同仓库更多 Skills
skillforge
Create or update a reusable agent skill. Use when you notice a repeated pattern, when a workflow should be persisted for future sessions, or when asked to forge/create/scaffold a new skill.
skillforge
Create or update a reusable agent skill. Use when you notice a repeated pattern, when a workflow should be persisted for future sessions, or when asked to forge/create/scaffold a new skill.
deploy-preview
Deploy a preview branch to the staging environment for review. Use when a feature branch is ready for visual review, when someone asks to "deploy this for review", or before opening a PR.
component-scaffold
Create a new React component with co-located test, story, and styles. Use when creating new UI components, when asked to scaffold/generate a component, or when building new pages.
bug-triage
Triage a bug report into an actionable GitHub issue with severity, reproduction steps, and assignment. Use when a bug is reported, when error logs need investigation, or when asked to file/triage an issue.
api-endpoint
Scaffold a REST API endpoint with route, controller, validation, and tests. Use when creating new API endpoints, adding resources, or when asked to build a new backend route.