skillfed

knack

A Command-Line Interface framework

knack v0.14.0 7.4M downloads/30d#1,738 on PyPI358
Permissive license MIT Active released

What it is and what it does

Knack is a framework for building structured command-line interfaces in Python. It handles command registration, argument parsing, help text generation, and output formatting so you can focus on implementing command logic rather than CLI plumbing. The framework uses a loader pattern where you define command groups and arguments declaratively, then invoke the CLI with user input to execute the appropriate command.

The package depends on argcomplete for shell completion, jmespath for output filtering, packaging for version handling, pygments for syntax highlighting, pyyaml for configuration, and tabulate for formatted output. It's designed to scale from simple single-command tools to complex multi-command CLIs like the Azure CLI and VSTS CLI, which use knack in production. The project is in active development and maintained, though the authors recommend pinning to a specific minor version rather than using loose version constraints.

Use it for:

  • Build a multi-command CLI tool with subcommands, argument validation, and automatic help text generation.
  • Create a wrapper around Azure or cloud service APIs that exposes functionality through a structured command interface.
  • Develop an internal DevOps or automation tool with consistent argument parsing and formatted output across many commands.
  • Add shell completion and formatted table output to an existing command-line application.
  • Implement a CLI that reads YAML or JSON configuration and applies it through structured commands.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Knack is a Python framework for building command-line interfaces with argument parsing, command organization, and output formatting built in.

Yes, if you are building a command-line tool in Python and want to avoid writing boilerplate argument parsing and command dispatch logic. The framework is actively maintained, has low install friction, and is proven in production by major projects like Azure CLI. Pin to a specific minor version as the authors recommend, since the project is still in initial development phase.

Install

knack on PyPI

pip

pip install knack

uv

uv add knack

poetry

poetry add knack

Installing knack

Before you install

Low install friction with six common runtime dependencies. The project is actively maintained with a recent release, though the maintainers note it remains in initial development phase and recommend pinning to a specific minor version when used as a dependency.

License in practice

MIT license is permissive; you can use, modify, and distribute knack with minimal restrictions, though you must include the license notice.

Quickstart

pip install knack

from knack import CLI, CLICommandsLoader
from knack.commands import CommandGroup

class MyCommandsLoader(CLICommandsLoader):
    def load_command_table(self, args):
        with CommandGroup(self, 'mygroup', '__main__#{}') as g:
            g.command('mycommand', 'my_function')
        return self.command_table

mycli = CLI(cli_name='mycli', commands_loader_cls=MyCommandsLoader)
exit_code = mycli.invoke(['mygroup', 'mycommand'])

Verify before relying

  • Whether the framework supports subcommands, aliases, or command hierarchies beyond the basic group structure shown in examples.
  • What testing or validation utilities knack provides for CLI applications built with it.
  • Performance characteristics or scalability limits for CLIs with many commands or complex argument trees.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 6 — argcomplete, jmespath, packaging, pygments, pyyaml, tabulate
Maintenance actively maintained — 92 days since the last release
Last repo commit
First released
Downloads 7,443,659/month — #1,738 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: knack-0.14.0-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

cli framework pythoncommand line interface builderargument parsing frameworkcli development librarycommand-line tool frameworkpython cli toolkitstructured command parser
cli-frameworkcommand-dispatchargument-parsing

More Application Frameworks packages