Click framework examples and templates - decorators, nested commands, parameter validation. Use when building Python CLI with Click, implementing command groups, adding CLI options/arguments, validating CLI parameters, creating nested subcommands, or when user mentions Click framework, @click decorators, command-line interface.
View on GitHubvanman2024/cli-builder
cli-builder
plugins/cli-builder/skills/click-patterns/SKILL.md
January 22, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/cli-builder/blob/main/plugins/cli-builder/skills/click-patterns/SKILL.md -a claude-code --skill click-patternsInstallation paths:
.claude/skills/click-patterns/# Click Framework Patterns
This skill provides comprehensive Click framework patterns, templates, and examples for building production-ready Python CLIs.
## Instructions
### When Building a Click CLI
1. Read the appropriate template based on complexity:
- Simple CLI: `templates/basic-cli.py`
- Nested commands: `templates/nested-commands.py`
- Custom validators: `templates/validators.py`
2. Generate new Click project:
```bash
bash scripts/generate-click-cli.sh <project-name> <cli-type>
```
Where cli-type is: basic, nested, or advanced
3. Study complete examples:
- `examples/complete-example.md` - Full-featured CLI
- `examples/patterns.md` - Common patterns and best practices
4. Validate your Click setup:
```bash
bash scripts/validate-click.sh <cli-file.py>
```
### Core Click Patterns
**Command Groups:**
```python
@click.group()
def cli():
"""Main CLI entry point"""
pass
@cli.command()
def subcommand():
"""A subcommand"""
pass
```
**Options and Arguments:**
```python
@click.option('--template', '-t', default='basic', help='Template name')
@click.argument('environment')
def deploy(template, environment):
pass
```
**Nested Groups:**
```python
@cli.group()
def config():
"""Configuration management"""
pass
@config.command()
def get():
"""Get config value"""
pass
```
**Parameter Validation:**
```python
@click.option('--mode', type=click.Choice(['fast', 'safe', 'rollback']))
@click.option('--count', type=click.IntRange(1, 100))
def command(mode, count):
pass
```
### Available Templates
1. **basic-cli.py** - Simple single-command CLI
2. **nested-commands.py** - Command groups and subcommands
3. **validators.py** - Custom parameter validators
4. **advanced-cli.py** - Advanced patterns with plugins and chaining
### Available Scripts
1. **generate-click-cli.sh** - Creates Click project structure
2. **validate-click.sh** - Validates Click CLI implementation
3. **setup-click-project.sh**