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
Pake
Developer Tools
Turn any webpage into a lightweight native desktop app with one command — built on Rust/Tauri instead of Electron, producing installers nearly 20x smaller (typically under 10MB) for macOS, Windows, and Linux.
Payload CMS
Blogging · CMS · Developer Tools
The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.
PeerTube
Social Media
A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.
strapi
CMS
Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.
Tianji
Analytics · Monitoring
Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.
TinaCMS
CMS
An open-source, Git-backed headless CMS that gives editors a live visual editing UI over Markdown, MDX, JSON, and YAML content while developers keep everything in version control.
Typebot
AI Assistants · AI Development · Developer Tools
Build sophisticated chatbots visually, embed them anywhere without iframes, and own your data — fully self-hostable with a modular block system and 30+ integrations.
Umami
Analytics
Privacy-first web analytics that respects your users — self-hosted, cookieless, and GDPR compliant out of the box.