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
Kaneo
Product Management · Productivity · Project Management
Lightweight self-hosted project management that gives you kanban boards, GitHub sync, and full team collaboration without the enterprise bloat.
KeystoneJS
CMS · Developer Tools
The superpowered headless CMS for developers built with GraphQL and React
Laudspeaker
Automation · Marketing
Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.
likec4
Developer Tools · Devops
Define your software architecture as code and get always up-to-date, interactive C4 diagrams generated automatically from a DSL.
medusa
Ecommerce
The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.
n8n
Automation · No Code Platforms
Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Onlook
AI Design Tools · Design Tools
An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.
OpenPanel
Devops · Hosting Control Panel
Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.