skillfed

cmd2

cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python

cmd2 v4.2.0 2.4M downloads/30d#3,099 on PyPI
Permissive license MIT Active released

What it is and what it does

cmd2 extends Python's built-in cmd module to simplify building feature-rich interactive command-line applications. It provides automatic tab completion for commands, subcommands, file paths, and argparse-defined flags; rich help text generation; and scripting capabilities through text files and Python scripts. The framework is designed to bridge the gap between easy command discovery (via completion and help) and workflow automation (via aliases, macros, and scripting), making it suitable for both exploratory CLI tools and production automation systems.

The package depends on prompt-toolkit for terminal interaction, rich for colored output and formatting, rich-argparse for integrated argument help, and pyperclip for clipboard support. It has been actively maintained since 2008 and currently targets Python 3.11 and later, including free-threaded Python variants. With no known security vulnerabilities and a permissive MIT license, it is production-ready for developers building admin tools, interactive shells, or complex CLI workflows.

Use it for:

  • Build system administration tools with discoverable commands and tab completion for file paths and options.
  • Create interactive debugging or diagnostic shells that support scripting and command history.
  • Develop workflow automation CLIs that transition smoothly from interactive exploration to batch scripting.
  • Implement interactive REPL-style applications for data analysis or configuration management.
  • Build security or penetration testing frameworks with command aliasing and macro support.

Worth the install?

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

cmd2 is a Python framework for building interactive command-line applications with built-in tab completion, help text generation, scripting, and automation features.

Yes. cmd2 is actively maintained, has low install friction, carries no security vulnerabilities, and uses a permissive MIT license. It is well-suited for any Python developer building interactive CLI applications that need tab completion, help generation, and scripting support. The framework is production-stable (Development Status 5) and supports current Python versions.

Install

cmd2 on PyPI

pip

pip install cmd2

uv

uv add cmd2

poetry

poetry add cmd2

Installing cmd2

Before you install

Low install friction with only 4 runtime dependencies (prompt-toolkit, pyperclip, rich, rich-argparse). Actively maintained with a release 8 days ago. Supports current Python versions (3.11+) including free-threaded variants.

License in practice

MIT license permits commercial and private use with minimal restrictions—suitable for most projects without licensing concerns.

Quickstart

pip install cmd2

import cmd2

class MyApp(cmd2.Cmd):
    def do_hello(self, _: cmd2.Statement):
        self.poutput('Hello')

if __name__ == '__main__':
    MyApp().cmdloop()

Requires Python 3.11 or later.

Verify before relying

  • Whether the framework supports subcommand hierarchies beyond what argparse provides.
  • Performance characteristics when handling large command sets or high-frequency tab completion.
  • Compatibility with async/await patterns in user-defined commands.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 4 — prompt-toolkit, pyperclip, rich, rich-argparse
Maintenance actively maintained — 8 days since the last release
First released
Downloads 2,372,794/month — #3,099 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cmd2-4.2.0-py3-none-any.whl

Keywords: CLI, cmd, command, interactive, prompt, Python

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: Free Threading :: 3 - StableTopic :: Software Development :: Libraries :: Python Modules

Tags

interactive command line frameworkCLI application buildertab completion for CLIcommand-line REPLPython cmd module extensioninteractive shell frameworkcommand scripting automation
cli-frameworkinteractive-shellrepl

More Python Modules packages