Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 27, 2026·3 min de lecture

Clack — Beautiful CLI Prompts for Node.js

A set of prompt components for building interactive command-line interfaces with a polished look. Includes text inputs, select menus, confirmations, spinners, and multi-step flows with minimal API surface.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 29/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
CLI Tool
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Clack
Commande de staging sûr
npx -y tokrepo@latest install 2bfa972f-897b-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

Clack is a library for building beautiful, interactive command-line prompts in Node.js. Created by Nate Moore (co-creator of Astro), it provides a set of composable prompt components with a polished terminal UI out of the box. Clack focuses on developer experience: prompts look professional, the API is minimal, and multi-step flows feel cohesive. Tools like the Astro CLI, SvelteKit, and Drizzle ORM use Clack for their interactive setup wizards.

What Clack Does

  • Provides styled prompt components: text, password, select, multiselect, confirm, and group
  • Renders spinners, progress indicators, and log messages with consistent styling
  • Chains prompts into multi-step wizards with intro/outro framing
  • Handles cancellation gracefully with SIGINT detection and cleanup
  • Offers a core layer for building custom prompt components with full rendering control

Architecture Overview

Clack is split into two packages: @clack/prompts (high-level components) and @clack/core (low-level primitives). The core package manages terminal state, cursor movement, input handling, and ANSI rendering. Prompt components are state machines that transition between idle, active, and submitted states. The rendering engine uses a double-buffered approach to minimize flicker, redrawing only changed lines on each keystroke.

Self-Hosting & Configuration

  • Install via npm: npm install @clack/prompts
  • Import prompt functions individually for tree-shaking
  • No configuration files needed; styling is built into the components
  • Works in Node.js 16+ and Bun
  • Use @clack/core to build custom prompt components with full terminal control

Key Features

  • Consistent visual design across all prompt types with Unicode box-drawing characters
  • Group prompts into logical sections with group() for multi-step wizards
  • Spinner component for long-running operations with start/stop/update methods
  • Cancellation handling with isCancel() check after each prompt
  • Minimal API surface: each prompt is a single async function call

Comparison with Similar Tools

  • Inquirer.js — The established choice with many prompt types and plugins; Clack offers a more modern look and smaller API
  • Enquirer — Feature-rich with custom prompt types; Clack prioritizes visual consistency and simplicity
  • Prompts — Lightweight alternative; Clack adds polished styling and multi-step flow support
  • Commander.js — Argument parser, not a prompt library; Commander handles flags while Clack handles interactive input
  • Ink — React-based terminal UI framework; Clack is simpler for standard prompt flows without React overhead

FAQ

Q: Can I customize the look of Clack prompts? A: The high-level @clack/prompts package has a fixed visual style. For custom rendering, use @clack/core to build prompt components with your own ANSI styling.

Q: Does Clack work with TypeScript? A: Yes. Clack is written in TypeScript and all prompt functions have full type definitions, including generic types for select options.

Q: How does Clack handle user cancellation (Ctrl+C)? A: Each prompt returns a special cancel symbol when the user presses Ctrl+C. Use the isCancel() helper to detect this and exit gracefully.

Q: Which projects use Clack? A: Astro CLI, SvelteKit, Drizzle ORM, and several other developer tools use Clack for their interactive setup and configuration wizards.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires