click

GitHub

提供基于 Click 库构建 CLI 应用的最佳实践,涵盖命令、组、选项配置、类型安全及测试方法。

.claude/skills/click/SKILL.md microsoft/debugpy

触发场景

使用 Click 构建命令行工具 CLI 应用单元测试

安装

npx skills add microsoft/debugpy --skill click -g -y
更多选项

非标准路径

npx skills add https://github.com/microsoft/debugpy/tree/main/.claude/skills/click -g -y

不安装直接使用

npx skills use microsoft/debugpy@click

指定 Agent (Claude Code)

npx skills add microsoft/debugpy --skill click -a claude-code -g -y

安装 repo 全部 skill

npx skills add microsoft/debugpy --all -g -y

预览 repo 内 skill

npx skills add microsoft/debugpy --list

SKILL.md

Frontmatter
{
    "name": "click",
    "description": "Best practices for building CLI applications with Click including commands, groups, options, and testing."
}

Skill: Click

Best practices for building CLI applications with Click including commands, groups, options, and testing.

When to Use

Apply this skill when building command-line interfaces with Click — commands, groups, options, arguments, and prompts.

Commands

  • Use @click.command() for single commands, @click.group() for multi-command CLIs.
  • Declare options with @click.option() and positional args with @click.argument().
  • Use help= on every option and command for auto-generated help text.
  • Use envvar= to allow environment variable fallback for sensitive options.

Groups

  • Organize subcommands with @click.group() and group.add_command().
  • Use @click.pass_context to share state between group and subcommands.

Type Safety

  • Use Click's built-in types (click.Path(exists=True), click.Choice([...]), click.IntRange()).
  • Use callbacks for custom validation.

Testing

  • Use click.testing.CliRunner() for testing commands without subprocess overhead.
  • Assert on result.exit_code and result.output.
  • Use mix_stderr=False to test stderr separately.

Pitfalls

  • Don't use sys.exit() — use click.exceptions.Exit or return from the command.
  • Don't use print() — use click.echo() for proper encoding handling.
  • Always handle KeyboardInterrupt / abort prompts gracefully.

版本历史

  • e5743d3 当前 2026-08-20 17:01

同 Skill 集合

.claude/skills/django/SKILL.md
.claude/skills/flask/SKILL.md
.claude/skills/jinja2/SKILL.md
.claude/skills/numpy/SKILL.md
.claude/skills/pytest/SKILL.md
.claude/skills/requests/SKILL.md

元信息

文件数
0
版本
e5743d3
Hash
87e9c513
收录时间
2026-08-20 17:01

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 23:45
浙ICP备14020137号-1 $访客地图$