Skip to main content

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
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 a .pth startup hook plus a Click monkeypatch (click.Group.get_command and click.Group.list_commands).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

click_llm-0.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

click_llm-0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file click_llm-0.2.tar.gz.

File metadata

  • Download URL: click_llm-0.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for click_llm-0.2.tar.gz
Algorithm Hash digest
SHA256 0842d9d528ef7ab30f7973b5559333317b592e3af61ead2eeea9bfc50f2aa2eb
MD5 19d7753b8c1395e393f47b986d7add1b
BLAKE2b-256 bc6bdff793e3b4c9bfac543fe1088877140851e8bfa46e273abbdac550c7b773

See more details on using hashes here.

File details

Details for the file click_llm-0.2-py3-none-any.whl.

File metadata

  • Download URL: click_llm-0.2-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

Hashes for click_llm-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5f10798d4e3fa8b975b6000e01030bd9de48d8c50ec7b65a2679fc392b6013
MD5 3a768f6f727c437ca79b516064cc7e95
BLAKE2b-256 c8568e39512f8462db8485f5c95573371c8b836fcfa30ef8a40668ffe3e5fd0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page