Add progress bars and spinners to CLI
✓Works with OpenClaudeYou are a CLI UX developer. The user wants to add visual progress indicators (progress bars and spinners) to terminal applications.
What to check first
- Verify Node.js version supports your chosen library (check
node --version— most progress libraries need Node 12+) - Confirm terminal supports ANSI escape sequences with
echo $TERM(most modern terminals do)
Steps
- Install a progress library like
cli-progressororausingnpm install cli-progress ora - Import the library at the top of your script:
const cliProgress = require('cli-progress'); - Create a progress bar instance with
new cliProgress.SingleBar()and pass configuration object withformat,barCompleteChar,barIncompleteChar - Start the progress bar with
.start(totalValue, startValue)where totalValue is the max count - Update progress in your loop with
.update(currentValue)after each iteration - Call
.stop()when the operation completes - For spinners, use
oralibrary: create spinner withora('Loading text')and call.start(), then.succeed()or.fail()when done - Chain multiple progress operations by stopping one bar and starting another in sequence
Code
const cliProgress = require('cli-progress');
const ora = require('ora');
// Example 1: Progress Bar
async function downloadFiles() {
const progressBar = new cliProgress.SingleBar({
format: 'Download Progress |{bar}| {percentage}% || {value}/{total} files',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true,
stopOnComplete: true
});
const totalFiles = 50;
progressBar.start(totalFiles, 0);
for (let i = 1; i <= totalFiles; i++) {
// Simulate file download
await new Promise(resolve => setTimeout(resolve, 100));
progressBar.update(i);
}
progressBar.stop();
console.log('✓ Download complete!');
}
// Example 2: Spinner
async function processData() {
const spinner = ora('Processing data...').start();
try {
// Simulate async work
await new Promise(resolve => setTimeout(resolve, 2000));
spinner.succeed('Data processed successfully');
} catch (error) {
spinner.fail('Processing failed: ' + error.message);
}
}
// Example 3: Multi-bar with spinners
async function complexOperation() {
const bars = new cliProgress.MultiBar({
clearOnComplete: false,
format: '{name} |{bar}| {percentage}% || {value}/{total}',
barCompleteChar: '█',
barIncompleteChar: '░',
hideCursor: true
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related CLI Tools Skills
Other Claude Code skills in the same category — free to download.
CLI App Builder
Build CLI applications with Commander.js
Interactive CLI
Create interactive CLI prompts (Inquirer.js)
CLI Config Manager
Build CLI configuration management
CLI Help Generator
Generate help text and man pages
CLI Testing
Test CLI applications
CLI Packaging
Package CLI for npm/brew distribution
CLI Autocomplete
Add shell autocompletion to CLI tools
CLI Color Output
Add colored and formatted CLI output
Want a CLI Tools skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.