click

Other Community

Skill notes

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.

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
Other
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
94 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@microsoft · NOASSERTION
Token usage
Lean
Setup complexity
Guided setup
External API key
Not required
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Shell exec
  • Env read
Network behavior
Local-only
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

Author source file SKILL.md

# 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.

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.