click

作成者: microsoft

Clickを使用したCLIアプリケーション構築のベストプラクティス(コマンド、グループ、オプション、テストを含む)

npx skills add https://github.com/microsoft/debugpy --skill click

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.

microsoftのその他のスキル

oss-growth
microsoft
OSS成長ハッカーのペルソナ
official
winapp-ui-automation
microsoft
コマンドラインからUI Automation(UIA)を使用して、実行中のWindowsアプリのUIを検査および操作します。AIエージェントや開発者がUIを検査する必要がある場合に使用します…
official
accessibility-aria-expert
microsoft
React/Fluent UIのWebビューにおけるアクセシビリティ問題を検出・修正します。スクリーンリーダー互換性のコードレビュー時、ARIAラベルの修正時、および…の確認時に使用します。
official
generate-canvas-app
microsoft
[DEPRECATED — 代わりに canvas-app を使用してください] 完全なPower Appsキャンバスアプリを生成します。
official
django
microsoft
Djangoウェブ開発のベストプラクティス(モデル、ビュー、テンプレート、テストを含む)
official
github-issue-creator
microsoft
生のメモ、エラーログ、音声入力、スクリーンショットを、簡潔なGitHub Flavored MarkdownのIssueレポートに変換します。ユーザーがバグ情報やエラーを貼り付けた際に使用します。
official
python-package-management
microsoft
依存関係管理にuvを使用し、タスク自動化にpoethepoetを使用します。
official
runtime-validation
microsoft
移行アプリケーションのランタイム検証 — テスト戦略(計画フェーズ)とテスト実行(検証フェーズ)をカバー:起動検証、…
official