You can build your own decorator that encapsulates the common options:

def common_options(function):
    function = click.option('--unique-flag-1', is_flag=True)(function)
    function = click.option('--bar', is_flag=True)(function)
    function = click.option('--foo', is_flag=True)(function)
    return function

@click.command()
@common_options
def command():
    pass
Answer from Will Vousden on Stack Overflow
🌐
Click Documentation
click.palletsprojects.com › en › stable › advanced
Advanced Patterns — Click Documentation (8.5.x)
Note: an actual implementation of a --version parameter that is reusable is available in Click as click.version_option(). The code here is merely an example of how to implement such a flag.
Discussions

How to reuse options from groups to command in Python Click? - Stack Overflow
2 Using click.CommandCollection drops group options · 9 Get params sent to a subcommand of a click.group() ... 2 Python Click options - Avoid taking multiple times the same option if the parameter multiple is not passed More on stackoverflow.com
🌐 stackoverflow.com
Reusing options at different commands
Long ago I used click and I got frustrated how I can't reuse code. I then contrived a method where I could define options at a central place and then reuse it but it felt like a hack. I wonder ... More on github.com
🌐 github.com
1
1
June 17, 2025
python - Shared options and flags between commands - Stack Overflow
Error: No such option: --verbose · Don't forget that using @ for decorators in python is just a syntactic shortcut for an explicit call to the decorator, passing the function as the first parameter and returning another function. You can just assign that function to a variable, and click allows you to reuse ... More on stackoverflow.com
🌐 stackoverflow.com
How to define common python-click options for multiple commands? - Stack Overflow
I've added an example. 2023-01-28T20:39:19.22Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 1 Command line interface with multiple commands using click: add unspecified options for command as dictionary · 4 With python click, ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Readthedocs
pocoo-click.readthedocs.io › en › latest › options
Options - the Click Documentation
an optional clamping mode where a value that falls outside of the range will be clamped. This means that a range of 0-5 would return 5 for the value 10 or 0 for the value -1 (for example). ... @click.command() @click.option('--count', type=click.IntRange(0, 20, clamp=True)) @click.option('--digit', ...
🌐
ProgramCreek
programcreek.com › python › example › 88019 › click.Option
Python Examples of click.Option
def __init__(self, plugin, name, *args, **kwargs): import q2cli.util # the cli currently doesn't differentiate between methods # and visualizers, it treats them generically as Actions self._plugin = plugin self._action_lookup = {q2cli.util.to_cli_name(id): a for id, a in plugin['actions'].items()} support = 'Getting user support: %s' % plugin['user_support_text'] website = 'Plugin website: %s' % plugin['website'] description = 'Description: %s' % plugin['description'] help_ = '\n\n'.join([description, website, support]) params = [ click.Option(('--version',), is_flag=True, expose_value=False,
🌐
Click Documentation
click.palletsprojects.com › en › stable › options
Options — Click Documentation (8.5.x)
The substitution rule above resolves it to that option’s flag_value. Any other explicit default is passed through literally. The third row is the three-state pattern: the function receives None when no flag is passed, distinguishable from either explicit choice. When flag_value is True or False, the substitution rule does not apply: default=True is the literal Python True. To make one flag in an enable/disable pair the default, set its default=True explicitly: @click.option("--without-xyz", "enable_xyz", flag_value=False) @click.option("--with-xyz", "enable_xyz", flag_value=True, default=True)
🌐
Stack Overflow
stackoverflow.com › questions › 73594892 › python-click-reuse-click-options-from-group-in-command
How to reuse options from groups to command in Python Click? - Stack Overflow
@click.option("--option1") @click.option("--option2") @click.option("--option3") @click.group() def group(option1, option2, option3): pass @click.option("--option1") @click.option("--option2") @click.option("--option3") @group.command() def ...
🌐
Better Stack
betterstack.com › community › guides › scaling-python › click-explained
Creating composable CLIs with click in Python | Better Stack Community
Click provides two primary ways to take input: options and arguments. Options are named parameters that can be specified in any order. They're typically prefixed with one or two hyphens (e.g., -v or --verbose). ... The updated example introduces the --name option (with the short form -n), which accepts a string value and defaults to "World".
Find elsewhere
🌐
ZetCode
zetcode.com › python › click
Python click - creating command line interfaces
January 29, 2024 - In the example, we create an option with both short and long names. The name of the variable passed to the function is string, derived from the longer option name. $ ./option_names.py -s sky sky $ ./option_names.py --string cloud cloud · We run the program using both option names. We can ask a user to provide a value interactively. ... #!/usr/bin/python import click @click.command() @click.option("--name", prompt="Your name", help="Provide your name") def hello(name): click.echo(f"Hello, {name}") if __name__ == '__main__': hello()
🌐
GitHub
github.com › pallets › click › discussions › 2978
Reusing options at different commands · pallets/click · Discussion #2978
June 17, 2025 - name_opt = click.Option(["--name"], ...) @click.command(params=[name_opt]) @click.option("--other") def hello(...): ... Or, as you showed, write a decorator to apply decorators, which works for any Python code.
Author: pallets
🌐
Prodevsblog
prodevsblog.com › questions › 115737 › is-it-possible-to-reuse-python-click-option-decorators-for-multiple-commands
Q&A ProDevsBlog | Is it possible to reuse python @click.option decorators for multiple commands?
July 26, 2020 - def common_options(function): function = click.option('--unique-flag-1', is_flag=True)(function) function = click.option('--bar', is_flag=True)(function) function = click.option('--foo', is_flag=True)(function) return function @click.command() @common_options def command(): pass
🌐
Devnet-academy
docs.devnet-academy.com › docs › click_v7.1.2 › options.html
Options — Click Documentation (7.x)
# How to make an option required @click.command() @click.option('--n', required=True, type=int) def dots(n): click.echo('.' * n) # How to use a Python reserved word such as `from` as a parameter @click.command() @click.option('--from', '-f', 'from_') @click.option('--to', '-t') def ...
🌐
Jeff Triplett
jefftriplett.com › 2016 › reusable-click-options
Reusable Click Options | Jeff Triplett
February 17, 2016 - While researching ways to extend Click plug-ins, I stumbled on this amazing tip. Click options are reusable. I’m not sure why I never thought of this before but it’s handy if you are writing dozens of click commands and you reuse the same options over and over.
🌐
AssemblyAI
assemblyai.com › blog › the-definitive-guide-to-python-click
The Definitive Guide to Python Click | AssemblyAI
July 28, 2021 - What can Python Click do for you? At the end of this guide, you’ll be able to create your own command line interfaces that can pass context, with commands that can take mandatory or optional arguments, and nested commands. This example Python project will show you how to interact with different click commands from the building blocks such as click.command to the more advanced commands such as click.make_pass_decorator.
🌐
CSDN
devpress.csdn.net › python › 630455a0c67703293080b588.html
Is it possible to reuse python @click.option decorators for multiple commands?_python_Mangs-Python
def common_options(function): function = click.option('--unique-flag-1', is_flag=True)(function) function = click.option('--bar', is_flag=True)(function) function = click.option('--foo', is_flag=True)(function) return function @click.command() @common_options def command(): pass
🌐
Readthedocs
pymbook.readthedocs.io › en › latest › click.html
Building command line applications with Click — Python for you and me 0.5.beta1 documentation
In click.option() decorator, first we passed the flag using –verbose, then marked this option as a boolean flag, and then finally added the help text. $ myhello --help Usage: myhello [OPTIONS] Options: --verbose Will print verbose messages. --help Show this message and exit. $ myhello --verbose We are in the verbose mode. Hello World · By default, any boolean flag is treated as false. We can now add more options to our tool. For example, we will have a –name option which will take a string as input.
Top answer
1 of 1
16

The way you currently defined it it will work, but the --verbose option belongs to the main command group, so you'd need to call it as python script.py --verbose list (and my_find_command and my_list_command won't receive it as an argument, only cli).

To use the same option across multiple commands without repeating yourself too much, you can just assign it to a variable and then use it twice:

verbose_option = click.option(
    "-v",
    "--verbose",
    count=True,
    default=0,
    help="-v for DEBUG",
)

...

@click.command()
@verbose_option
def foo(verbose):
    ...

@click.command()
@verbose_option
def bar(verbose):
    ...

Unrelated, but while we're at it: There's a simpler way of grouping commands, without having to do cli.add_command(my_find_command): Just use @cli.command() instead of @click.command():

import click

option_verbose = click.option(
    "-v",
    "--verbose",
    count=True,
    default=0,
    help="-v for DEBUG",
)

@click.group()
def cli():
    pass


@cli.command("list")
@option_verbose
@click.option(
    "--list-option",
    help="Special option for list command.",
)
def my_list_command(verbose, list_option):
    print(verbose, list_option)

@cli.command("find")
@option_verbose
@click.option(
    "--find-option",
    help="Special option for find command.",
)
def my_find_command(verbose, list_option):
    print(verbose, list_option)

if __name__ == '__main__':
    cli()

If there's several options you want to apply, you can define your own decorator that calls all those options on the argument:

def common_options(fn):
    return click.option(
        "-v",
        "--verbose",
    )(
        click.option(
            "-n",
            "--dry-run",
        )(fn)
    )
🌐
Digitalk
digitalk.tech › blog › python-click-or-how-to-write-professional-cli-applications
Mndwrk Blog - Python click or how to write professional CLI applications
June 17, 2022 - Take the following example: $ python3 myscript.py --option opt1 -s opt2 arg1 arg2 arg3 · In this case --option opt1 and -s opt2 are the options and are defined by the previously demonstrated @click.option decorators, while arg1, arg2, and arg3 are arguments that are defined with @click.argument.
🌐
Click Documentation
click.palletsprojects.com › en › stable › documentation
Help Pages — Click Documentation (8.5.x)
Click resolves conflicts automatically: an option reusing one of the help option names takes it over, and the default help parameter is dropped once all its names are taken. A parameter merely named help, like click.argument("help"), does not disable it: both keep working independently. This example changes the default parameters to -h and --help instead of just --help:
🌐
GitHub
github.com › pallets › click › issues › 330
How can I reuse the function that iv made as a command? · Issue #330 · pallets/click
April 22, 2015 - i have the following code: pass_config = click.make_pass_decorator(Config, ensure=True) @click.group() init(config): pass @init.group() @pass_config def a(config): pass @a.command('print') @pass_config def print_a(config): print "yes" @i...
Author: pallets