Stage 3 · Build
Building CLI Tools
Interactive CLIs
promptui, survey, and bubbletea for building delightful terminal user interfaces.
Interactive Patterns
Interactive CLIs guide users through workflows with prompts, selections, confirmations, and progress indicators. They are common in setup wizards, deployment tools, and developer utilities.
- Simple prompts — Ask for a single value (name, token, path)
- Selection menus — Choose from a list of options
- Confirmations — Yes/no decisions before destructive actions
- Multi-step wizards — Guide through complex workflows
- TUIs — Full terminal interfaces with navigation and state
promptui for Simple Prompts
promptui provides simple, single-question prompts. It is lightweight and works well for straightforward input collection.
survey for Multi-Step Forms
survey provides a collection of prompt types that can be chained into multi-step forms. It supports input, select, confirm, multi-select, and password prompts.
Bubbletea for TUIs
Bubbletea is a framework for building terminal user interfaces. It uses the Elm architecture: a model, update loop, and view function. This makes complex TUIs manageable and testable.
Spinners and Progress
Spinners and progress indicators show that work is happening. For long-running operations, they prevent users from thinking the tool has hung.
Best Practices
- Always provide a non-interactive mode for scripts and CI
- Use sensible defaults so users can press Enter to accept
- Validate input before accepting — reject bad values immediately
- Show progress for operations longer than 2 seconds
- Use color sparingly — it helps distinguish information but can be overwhelming
- Test with GOFLAGS=-mod=mod to handle new dependencies
Every interactive prompt should have a corresponding flag or env var for non-interactive use. Automation and CI cannot handle TUIs. Provide --name, --region, etc. as alternatives to prompts.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.