prompt_toolkit

A pure-Python library for building powerful interactive command-line applications

Library
PyPI
v3.0.53
10,589 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
63 /100 Good
Development Activity 40
Maintenance 36
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 84
Code Quality 82
Innovation 80
Learning Curve 62

prompt_toolkit is a pure-Python library for constructing rich, interactive command-line interfaces. It goes far beyond a GNU readline replacement: it supports syntax highlighting via Pygments lexers, advanced code completion, multi-line editing, both Emacs and Vi key bindings (including named registers and digraphs), mouse support, and auto-suggestions in the style of the fish shell. It powers well-known interactive tools including ptpython, the IPython shell, and pgcli, and its only runtime dependency is wcwidth, making it lightweight enough to embed in any CLI project.

What You Get

  • A full-screen and prompt-based application layer (prompt_toolkit.application, prompt_toolkit.shortcuts) for building anything from a single-line prompt to a full terminal UI
  • Pygments-backed syntax highlighting of input while typing, plus a styling system for themable terminal output
  • An extensible completion framework (prompt_toolkit.completion) supporting fuzzy, nested, and async completers for building rich autocomplete experiences
  • Both Emacs and Vi key-binding emulations, including advanced Vi features like named registers and digraphs
  • A widget toolkit (prompt_toolkit.widgets) with buttons, dialogs, text areas, and progress bars for building full-screen terminal UIs
  • Cross-platform input/output backends (prompt_toolkit.input, prompt_toolkit.output) abstracting terminal differences on Windows, Linux, and macOS

Common Use Cases

  • Building a REPL or interactive shell with syntax highlighting and history-aware autocompletion, as ptpython and IPython do
  • Adding a rich readline-style prompt with auto-suggestions and multi-line editing to a CLI tool, database client, or shell
  • Building a full-screen terminal dashboard or wizard using the widget toolkit and layout engine
  • Implementing Vi or Emacs-style modal editing inside a custom command-line tool

Under The Hood

Architecture The library is layered around an Application object (src/prompt_toolkit/application) that owns the event loop and ties together three concerns: a Layout tree (src/prompt_toolkit/layout) of Window/Container objects describing what’s on screen, a KeyBindings registry (src/prompt_toolkit/key_binding) mapping key sequences (Emacs- or Vi-mode) to handler functions, and an Output/Input pair (src/prompt_toolkit/output, src/prompt_toolkit/input) abstracting the actual terminal (VT100 escape codes on Unix, Win32 console API on Windows). Higher-level conveniences like prompt() in src/prompt_toolkit/shortcuts and the widgets package are built entirely on top of this same Application/Layout/KeyBindings core, so a single-line prompt and a full-screen TUI share one rendering pipeline. Tech Stack Pure Python 3.10+ with exactly one runtime dependency (wcwidth, for correct terminal-width computation of Unicode/CJK characters); Pygments is an optional integration for syntax highlighting rather than a hard dependency. Packaging uses a standard pyproject.toml/hatchling-style build with dependency groups for docs (Sphinx) and dev tooling. Code Quality tests/ contains 21 test files exercising the layout engine, key-binding dispatch, completion, regex-based lexers, and clipboard/history behavior; the project has a long single-maintainer commit history (Jonathan Slenders holds the vast majority of commits) with a broader contributor base handling incremental fixes, and CI runs via AppVeyor plus Codecov coverage tracking. Code is organized into clearly bounded subpackages (filters, lexers, completion, styles, formatted_text, eventloop) each with a narrow, well-documented responsibility. API Design The library explicitly advertises ‘no global state,’ and its top-level API mirrors that: sessions, applications, and key-binding registries are all explicit objects you construct and pass around rather than mutate implicitly, which makes the library composable but means newcomers must learn the Application/Layout/KeyBindings vocabulary before building anything beyond a basic prompt() call. Extensive docs and a gallery of real projects (ptpython, ipython, pgcli) built on the library offset that initial learning curve.

Used by 12 apps in this directory

Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,125

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
61
Dependency
Built with
Python 59%
Jupyter Notebook 21%
Updated 1 weeks ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 4 days ago
Go
84%
AGPL 3.0

Beta9

AI Development · Automation · Data Engineering

1,794

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
66
Dependency
Built with
Go 84%
Python 15%
Updated 5 days ago
Python
99%
MIT

deepagents

AI Agents · AI Development

29,818

The batteries-included Python agent harness — planning, sub-agents, filesystem, shell, memory, and skills bundled in, built on LangGraph.

View details
88
Repo Health
83
Technical
70
Dependency
Built with
Python 99%
Updated 4 days ago
Python
86%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,541

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
82
Repo Health
75
Technical
66
Dependency
Built with
Python 86%
HTML 14%
Updated 1 weeks ago
Python
100%
Other

OpenBB

Analytics · Databases · Invoicing Finance

73,553

The AI Workspace for Finance: Connect Data, Run AI Agents, Build Analytics

View details
77
Repo Health
80
Technical
67
Dependency
Built with
Python 100%
Updated 4 days ago
TypeScript
95%
Other

OpenHands

AI Code Assistants · AI Development

89,328

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 95%
Updated 5 days ago
Python
74%
Apache 2.0

OpenKB

Knowledge Management

4,579

An open-source CLI that compiles raw documents into a structured, interlinked wiki-style knowledge base using LLMs — powered by vectorless, reasoning-based retrieval (PageIndex) instead of a vector database.

View details
68
Repo Health
72
Technical
77
Dependency
Built with
Python 74%
TypeScript 23%
Updated 2 months ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers