Prompts
Lightweight, beautiful and user-friendly interactive CLI prompts for Node.js.
Repository Health
Technical Analysis
Prompts is a small, dependency-light Node.js library for building interactive command-line interfaces that ask users for input. It ships twelve unified prompt types — text, password, number, confirm, select, multiselect, autocomplete, date, and more — behind a single promise-based API that plays naturally with async/await.
Designed for CLIs, scaffolding tools, and setup wizards, it favors a clean layout with colored output, per-question validation, dynamic prompt chaining, and a testable inject mechanism for scripting answers. With no heavy dependencies and a consistent experience across every prompt, it has become one of the most widely used prompt libraries in the npm ecosystem.
What You Get
- Twelve unified prompt types (text, password, invisible, number, confirm, list, toggle, select, multiselect, autocomplete, autocompleteMultiselect, date) with a consistent look and feel.
- A promise-based API built around async/await, so prompt chains read as ordinary asynchronous code with no callback nesting.
- Per-question validation, formatting, and dynamic prompts whose type, message, or initial value can be computed from previous answers.
- An inject() testing hook and an override() helper for supplying answers programmatically from CLI arguments or test fixtures.
- A tiny dependency footprint (only kleur and sisteransi) and bundled TypeScript definitions.
Common Use Cases
- Building setup wizards and project scaffolding CLIs that gather configuration interactively.
- Prompting for confirmations, credentials, or selections inside developer tooling and build scripts.
- Collecting structured multi-step input where later questions depend on earlier answers.
Under The Hood
Architecture
The entry point index.js re-exports lib/index.js, whose prompt() function is the whole orchestration layer: it normalizes a single question or array into a list, resolves any function-valued properties against the answers collected so far, evaluates the type (skipping falsy types), and dispatches to the matching prompter in lib/prompts.js. Each prompter in lib/prompts.js constructs a corresponding element class from lib/elements/ (TextPrompt, NumberPrompt, SelectPrompt, etc.) and wraps its submit/abort/exit events in a promise. Every element extends a base Prompt (lib/elements/prompt.js) that owns the readline interface, raw-mode keypress handling, and cursor control via sisteransi, while shared rendering helpers live in lib/util/.
Tech Stack
Pure JavaScript (CommonJS) targeting Node 14+, with only two runtime dependencies: kleur for terminal colors and sisteransi for ANSI cursor/erase sequences. Terminal input is handled with Node’s built-in readline and EventEmitter. Hand-written TypeScript definitions ship in index.d.ts. Tooling is minimal — tape with tap-spec for tests and tsc for type-declaration checks.
Code Quality
The codebase is compact and well-factored, splitting responsibilities cleanly across an orchestrator, per-type element classes, and utility modules, with JSDoc annotations on the public surface. A test suite exists (test/prompts.js, test/text.js, test/util.js, plus test/type-declarations.ts) covering the core prompter and text element, though coverage is focused rather than exhaustive. Error handling is explicit for missing messages and undefined prompt types, and cancellation is modeled through the abort/exit event paths.
API Design
The public API is deliberately tiny — a single callable that takes declarative question objects and returns a keyed answers object — which keeps the mental model small and the getting-started boilerplate near zero. Consistent property names (type, name, message, initial, format, validate) across every prompt type, first-class async support, and the function-valued property convention make dynamic flows expressive. The README is thorough with per-type documentation and runnable examples, and inject()/override() give a clean testing story.
Used by 26 apps in this directory
Abby
Developer Tools · Product Management
Statically typed feature flags, remote config, and A/B testing with framework-native SDKs for TypeScript teams.
Actual
Invoicing Finance
Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
Botpress
AI Assistants · AI Development · Customer Support
The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.
Bubble Lab
Automation · AI Development
Open-core workflow engine for building AI-powered automations in TypeScript that run natively inside Slack — no context switching required.
Bun
Developer Tools
An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.
Dub
Marketing · Analytics
The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.
Jitsu
Data Engineering
Open-source, fully-scriptable data ingestion engine that streams events from web, apps, and APIs to any data warehouse in real time.
Joplin
Note Taking
The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.