Best practices for building CLI applications with Click including commands, groups, options, and testing.
Scanned 8/31/2026
Install to Claude Code
npx -y skills add microsoft/debugpy --skill click --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Click?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/microsoft-click)More formats (shields.io, HTML) on the badges page.
---
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.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!
Practical guide to testing web applications with screen readers for comprehensive accessibility validation.
Plan a weekly editorial calendar by mapping company goals to publishable topics, owners, status, and verification notes.
Run, verify, reseed, and repair Paperclip isolated dev workspace services. Use when asked to start or fix a managed project/worktree service and prove health, login readiness, cloned data, runtime visibility, and correct port ownership.
Prepare a Paperclip branch for PR with commits, template body, and checks.
Produce QA acceptance criteria and a manual validation plan for a feature change — golden path, edge cases, error states, performance limits, and explicit pass/fail evidence.