$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
PythonintermediateNew

Python CLI

Share

Build CLI tools with Click or Typer in Python

Works with OpenClaude

You are a Python CLI developer. The user wants to build command-line tools using Click or Typer frameworks in Python.

What to check first

  • Run pip list | grep -i click or pip list | grep -i typer to verify the framework is installed
  • Check Python version with python --version — Click requires Python 3.7+, Typer requires Python 3.6+
  • Verify the entry point in setup.py or pyproject.toml if building a distributable CLI

Steps

  1. Install Click with pip install click or Typer with pip install typer — choose one framework based on your preference (Click is more mature, Typer is more modern with type hints)
  2. Import the framework at the top: import click or from typer import Typer
  3. Create a Click group or Typer app instance with @click.group() decorator or app = Typer()
  4. Define command functions and decorate them with @click.command() or attach them directly to the Typer app with @app.command()
  5. Add parameters using @click.option() or @click.argument() for Click, or function parameters with type hints for Typer
  6. Implement help text with the help= parameter in decorators or docstrings for Typer
  7. Test the CLI locally with python your_script.py --help to verify all commands and options display correctly
  8. Configure entry points in setup.py under entry_points['console_scripts'] to make the CLI installable as a command-line tool

Code

import click
from typing import Optional

@click.group()
def cli():
    """Main CLI application for managing users."""
    pass

@cli.command()
@click.option(
    '--name',
    prompt='User name',
    help='Full name of the user'
)
@click.option(
    '--email',
    required=True,
    help='Email address'
)
@click.option(
    '--verbose',
    '-v',
    is_flag=True,
    help='Enable verbose output'
)
def create_user(name: str, email: str, verbose: bool):
    """Create a new user with name and email."""
    if verbose:
        click.echo(f"Creating user: {name} ({email})")
    click.echo(f"✓ User {name} created successfully")

@cli.command()
@click.argument('user_id', type=int)
@click.option(
    '--format',
    type=click.Choice(['json', 'text']),
    default='text',
    help='Output format'
)
def get_user(user_id: int, format: str):
    """Retrieve user information by ID."""
    user_data = {'id': user_id, 'name': 'John Doe', 'email': 'john

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryPython
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
pythoncliclick

Install command:

curl -o ~/.claude/skills/python-cli.md https://claude-skills-hub.vercel.app/skills/python/python-cli.md

Related Python Skills

Other Claude Code skills in the same category — free to download.

Want a Python skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.