Write Python Click CLI Tools with Claude
Click is Python's go-to library for building command-line tools, but getting the arguments, types, validation, and help text all right takes longer than it should. Claude can write a complete, production-ready CLI in one prompt.
Describe what you need:
Write a Python Click CLI tool that:
- Has a main command group called "db"
- Has a subcommand "export" that takes --format (csv or json), --output path, and --table name
- Has a subcommand "import" that takes a file path and --dry-run flag
- Validates that the output path's parent directory exists
- Shows a progress bar using Click's progressbar utility
- Has full --help output with examples
Claude will scaffold the full module with a proper if __name__ == "__main__" guard, type annotations, error handling with click.ClickException, and a pyproject.toml [project.scripts] entry so you can install it as a real CLI command.
For adding new subcommands to an existing CLI:
Add a "stats" subcommand to @cli/main.py that accepts an optional --since date
argument (default: 7 days ago) and outputs a summary table using Click's echo formatting.
A Click CLI is only two dozen lines to get wrong and two hundred to get right — describing what you want is faster than reading the docs.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.