Inject an llm command into Click CLIs for command discovery
Project description
click-llm
A tiny package that makes Click CLIs self-describing for LLMs.
click-llm adds an llm command to your CLI so models (and humans) can
discover commands, options, arguments, and command structure.
The command supports one flag:
--json: output machine-readable catalog JSON- default output: concise text catalog
Install
pip install click-llm
After install, llm is auto-enabled for Click CLIs in that Python environment.
Usage
mycli llm
mycli llm --json
Example CLI
import click
@click.group(help="Acme operations CLI.")
def acme() -> None:
pass
@acme.group(help="Deployment workflows.")
def deploy() -> None:
pass
@deploy.command(help="Roll out a service release.")
@click.argument("service")
@click.option(
"--env",
type=click.Choice(["staging", "prod"]),
default="staging",
show_default=True,
)
@click.option("--dry-run", is_flag=True, help="Plan only; do not execute.")
def release(service: str, env: str, dry_run: bool) -> None:
click.echo(f"release {service} to {env} (dry_run={dry_run})")
@acme.command(help="Show system health.")
@click.option("--json", "as_json", is_flag=True, help="Machine-readable health.")
def health(as_json: bool) -> None:
click.echo("ok")
if __name__ == "__main__":
acme()
Example output:
$ acme llm
catalog_version: 1
root_command: acme
commands: 4
### acme deploy release
kind: command
summary: Roll out a service release.
usage: acme deploy release [OPTIONS] SERVICE
params:
- option `--env`, type=choice, required=False, default="staging"
- option `--dry-run`, type=boolean, required=False, default=false, is_flag=True
- argument `service`, type=text, required=True, nargs=1, default=null
$ acme llm --json
The JSON output includes the full command tree and a flattened commands list,
which is useful for prompt context, tool routing, and command planning.
Explicit integration
If you prefer explicit wiring in the host CLI:
import click
from click_llm import attach
@click.group()
def cli():
pass
attach(cli)
Notes
Auto mode uses Python's sitecustomize startup hook plus a Click monkeypatch
(click.Group.get_command and click.Group.list_commands).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file click_llm-0.1.1.dev5.tar.gz.
File metadata
- Download URL: click_llm-0.1.1.dev5.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e88ef5620dfe1941ba373b332a05787415cbc1da077fef03324ba896d868351b
|
|
| MD5 |
870007c80697bb7745ee6975dff08803
|
|
| BLAKE2b-256 |
56e5dd92c59708faf07404e7f8decea23afac22281cc23be51cd3559f72a6949
|
File details
Details for the file click_llm-0.1.1.dev5-py3-none-any.whl.
File metadata
- Download URL: click_llm-0.1.1.dev5-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
950f3a34dda00fdd7f37fb041a5a707a3889b76c4d45c6006784d3a1bbe0125f
|
|
| MD5 |
e22f8bc37315b6f30f5665ad4bea9736
|
|
| BLAKE2b-256 |
73d9fccc1b0186edc4ef6cb6474205ba781e213a15aa0553a51279ec7d890664
|