跳到正文
Skillpedia
通用编程7.4k · #13230

create-cli

它能做什么

这个技能帮助在构建命令行工具之前规划它的行为,包括命令、选项、输出和错误代码。适合正在开发新终端工具的开发者。

适用场景

  • ✓你正在设计一个新的命令行工具的时候。
  • ✓你想在可读输出、JSON 输出和退出代码之间做选择的时候。
  • ✓某个命令需要安全选项,例如试运行或确认提示的时候。

技能链接

https://github.com/steipete/agent-scripts/blob/main/skills/create-cli/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/steipete/agent-scripts/blob/main/skills/create-cli/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想做一个导出笔记的命令行工具。请帮我设计它的命令和参数。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体只会问必要的问题以确定界面,然后编写一份紧凑的规格,包括命令树、选项、输出规则、错误代码和安全选项,并遵循公共命令行指南。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Create CLI

Design CLI surface area (syntax + behavior), human-first, script-friendly.

Do This First

Clarify (fast)

Ask, then proceed with best-guess defaults if user is unsure:

  • Command name + one-sentence purpose.
  • Primary user: humans, scripts, or both.
  • Input sources: args vs stdin; files vs URLs; secrets (never via flags).
  • Output contract: human text, --json, --plain, exit codes.
  • Interactivity: prompts allowed? need --no-input? confirmations for destructive ops?
  • Config model: flags/env/config-file; precedence; XDG vs repo-local.
  • Platform/runtime constraints: macOS/Linux/Windows; single binary vs runtime.

Deliverables (what to output)

When designing a CLI, produce a compact spec the user can implement:

  • Command tree + USAGE synopsis.
  • Args/flags table (types, defaults, required/optional, examples).
  • Subcommand semantics (what each does; idempotence; state changes).
  • Output rules: stdout vs stderr; TTY detection; --json/--plain; --quiet/--verbose.
  • Error + exit code map (top failure modes).
  • Safety rules: --dry-run, confirmations, --force, --no-input.
  • Config/env rules + precedence (flags > env > project config > user config > system).
  • Shell completion story (if relevant): install/discoverability; generation command or bundled scripts.
  • 5–10 example invocations (common flows; include piped/stdin examples).

Default Conventions (unless user says otherwise)

  • -h/--help always shows help and ignores other args.
  • --version prints version to stdout.
  • Primary data to stdout; diagnostics/errors to stderr.
  • Add --json for machine output; consider --plain for stable line-based text.
  • Prompts only when stdin is a TTY; --no-input disables prompts.
  • Destructive operations: interactive confirmation + non-interactive requires --force or explicit --confirm=....
  • Respect NO_COLOR, TERM=dumb; provide --no-color.
  • Handle Ctrl-C: exit fast; bounded cleanup; be crash-only when possible.

Templates (copy into your answer)

CLI spec skeleton

Fill these sections, drop anything irrelevant:

  1. Name: mycmd
  2. One-liner: ...
  3. USAGE:
    • mycmd [global flags] <subcommand> [args]
  4. Subcommands:
    • mycmd init ...
    • mycmd run ...
  5. Global flags:
    • -h, --help
    • --version
    • -q, --quiet / -v, --verbose (define exactly)
    • --json / --plain (if applicable)
  6. I/O contract:
    • stdout:
    • stderr:
  7. Exit codes:
    • 0 success
    • 1 generic failure
    • 2 invalid usage (parse/validation)
    • (add command-specific codes only when actually useful)
  8. Env/config:
    • env vars:
    • config file path + precedence:
  9. Examples:
    • …

Notes

  • Prefer recommending a parsing library (language-specific) only when asked; otherwise keep this skill language-agnostic.
  • If the request is “design parameters”, do not drift into implementation.
常见问题

它会直接写出完成的工具吗?

不会。它只生成一份紧凑的规格,供你或开发者去实现。

密钥应该通过参数传递吗?

不应该。技能规定,密钥永远不能通过参数传递。

它遵循哪些指南?

随附的参考资料,基于 clig.dev 上公开的命令行指南。

详情

作者的原始描述

CLI UX/spec: args, flags, help, output, errors, config, dry-run.

repo: steipete/agent-scripts

热度

GitHub 星标
7.4k
排名
#13230
许可证
MIT
更新时间
2026/10/30

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能