Interactive prompt patterns for CLI tools with text, list, checkbox, password, autocomplete, and conditional questions. Use when building CLIs with user input, creating interactive prompts, implementing questionnaires, or when user mentions inquirer, prompts, interactive input, CLI questions, user prompts.
/plugin marketplace add vanman2024/cli-builder/plugin install cli-builder@cli-builderThis skill is limited to using the following tools:
README.mdexamples/nodejs/project-init-wizard.jsexamples/python/project_init_wizard.pyscripts/generate-prompt.shscripts/install-nodejs-deps.shscripts/install-python-deps.shscripts/validate-prompts.shtemplates/nodejs/autocomplete-prompt.jstemplates/nodejs/checkbox-prompt.jstemplates/nodejs/comprehensive-example.jstemplates/nodejs/conditional-prompt.jstemplates/nodejs/list-prompt.jstemplates/nodejs/password-prompt.jstemplates/nodejs/text-prompt.jstemplates/python/autocomplete_prompt.pytemplates/python/checkbox_prompt.pytemplates/python/conditional_prompt.pytemplates/python/list_prompt.pytemplates/python/password_prompt.pytemplates/python/text_prompt.pyComprehensive interactive prompt patterns for building CLI tools with rich user input capabilities. Provides templates for text, list, checkbox, password, autocomplete, and conditional questions in both Node.js and Python.
Identify prompt type needed:
Choose language:
templates/nodejs/templates/python/Select appropriate template:
text-prompt.js/py - Basic text inputlist-prompt.js/py - Single selection listcheckbox-prompt.js/py - Multiple selectionspassword-prompt.js/py - Secure password inputautocomplete-prompt.js/py - Type-ahead suggestionsconditional-prompt.js/py - Dynamic questions based on answerscomprehensive-example.js/py - All patterns combinedInstall required dependencies:
scripts/install-nodejs-deps.shscripts/install-python-deps.shTest prompts:
examples/nodejs/ or examples/python/scripts/validate-prompts.shCustomize for your CLI:
Library: inquirer (v9.x)
Installation:
npm install inquirer
Basic Usage:
import inquirer from 'inquirer';
const answers = await inquirer.prompt([
{
type: 'input',
name: 'username',
message: 'Enter your username:',
validate: (input) => input.length > 0 || 'Username required'
}
]);
console.log(`Hello, ${answers.username}!`);
Library: questionary (v2.x)
Installation:
pip install questionary
Basic Usage:
import questionary
username = questionary.text(
"Enter your username:",
validate=lambda text: len(text) > 0 or "Username required"
).ask()
print(f"Hello, {username}!")
templates/nodejs/)templates/python/){ type: 'input' }questionary.text(){ type: 'list' }questionary.select(){ type: 'checkbox' }questionary.checkbox(){ type: 'password' }questionary.password()inquirer-autocomplete-prompt pluginquestionary.autocomplete()when property in question config// Node.js
validate: (input) => {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(input) || 'Invalid email address';
}
# Python
def validate_email(text):
import re
regex = r'^[^\s@]+@[^\s@]+\.[^\s@]+$'
return bool(re.match(regex, text)) or "Invalid email address"
questionary.text("Email:", validate=validate_email).ask()
// Node.js
validate: (input) => input.length > 0 || 'This field is required'
# Python
questionary.text("Name:", validate=lambda t: len(t) > 0 or "Required").ask()
// Node.js
validate: (input) => {
const num = parseInt(input);
return (num >= 1 && num <= 100) || 'Enter number between 1-100';
}
# Python
def validate_range(text):
try:
num = int(text)
return 1 <= num <= 100 or "Enter number between 1-100"
except ValueError:
return "Invalid number"
questionary.text("Number:", validate=validate_range).ask()
Use case: Interactive CLI for scaffolding new projects
// Node.js - See examples/nodejs/project-init.js
const answers = await inquirer.prompt([
{
type: 'input',
name: 'projectName',
message: 'Project name:',
validate: (input) => /^[a-z0-9-]+$/.test(input) || 'Invalid project name'
},
{
type: 'list',
name: 'framework',
message: 'Choose framework:',
choices: ['React', 'Vue', 'Angular', 'Svelte']
},
{
type: 'checkbox',
name: 'features',
message: 'Select features:',
choices: ['TypeScript', 'ESLint', 'Prettier', 'Testing']
}
]);
# Python - See examples/python/project_init.py
import questionary
project_name = questionary.text(
"Project name:",
validate=lambda t: bool(re.match(r'^[a-z0-9-]+$', t)) or "Invalid name"
).ask()
framework = questionary.select(
"Choose framework:",
choices=['React', 'Vue', 'Angular', 'Svelte']
).ask()
features = questionary.checkbox(
"Select features:",
choices=['TypeScript', 'ESLint', 'Prettier', 'Testing']
).ask()
Use case: Dynamic questions based on previous answers
// Node.js - See examples/nodejs/conditional-flow.js
const questions = [
{
type: 'confirm',
name: 'useDatabase',
message: 'Use database?',
default: true
},
{
type: 'list',
name: 'dbType',
message: 'Database type:',
choices: ['PostgreSQL', 'MySQL', 'MongoDB', 'SQLite'],
when: (answers) => answers.useDatabase
},
{
type: 'input',
name: 'dbHost',
message: 'Database host:',
default: 'localhost',
when: (answers) => answers.useDatabase && answers.dbType !== 'SQLite'
}
];
# Python - See examples/python/conditional_flow.py
use_database = questionary.confirm("Use database?", default=True).ask()
if use_database:
db_type = questionary.select(
"Database type:",
choices=['PostgreSQL', 'MySQL', 'MongoDB', 'SQLite']
).ask()
if db_type != 'SQLite':
db_host = questionary.text(
"Database host:",
default="localhost"
).ask()
Use case: Secure password input with validation and confirmation
// Node.js - See examples/nodejs/password-confirm.js
const answers = await inquirer.prompt([
{
type: 'password',
name: 'password',
message: 'Enter password:',
validate: (input) => input.length >= 8 || 'Password must be 8+ characters'
},
{
type: 'password',
name: 'confirmPassword',
message: 'Confirm password:',
validate: (input, answers) => {
return input === answers.password || 'Passwords do not match';
}
}
]);
# Python - See examples/python/password_confirm.py
password = questionary.password(
"Enter password:",
validate=lambda t: len(t) >= 8 or "Password must be 8+ characters"
).ask()
confirm = questionary.password(
"Confirm password:",
validate=lambda t: t == password or "Passwords do not match"
).ask()
Node.js:
./scripts/install-nodejs-deps.sh
# Installs: inquirer, inquirer-autocomplete-prompt
Python:
./scripts/install-python-deps.sh
# Installs: questionary, prompt_toolkit
./scripts/validate-prompts.sh [nodejs|python]
# Tests all templates and examples
./scripts/generate-prompt.sh --type [text|list|checkbox|password] --lang [js|py]
# Generates boilerplate prompt code
const config = await inquirer.prompt([
{ type: 'input', name: 'appName', message: 'App name:' },
{ type: 'input', name: 'version', message: 'Version:', default: '1.0.0' },
{ type: 'list', name: 'env', message: 'Environment:', choices: ['dev', 'prod'] },
{ type: 'confirm', name: 'debug', message: 'Enable debug?', default: false }
]);
# Step 1: Choose components
components = questionary.checkbox(
"Select components:",
choices=['Core', 'CLI', 'Web UI', 'API']
).ask()
# Step 2: Configure each component
for component in components:
print(f"\nConfiguring {component}...")
# Component-specific questions
try {
const answers = await inquirer.prompt(questions);
// Process answers
} catch (error) {
if (error.isTtyError) {
console.error('Prompt could not be rendered in this environment');
} else {
console.error('User interrupted prompt');
}
process.exit(1);
}
inquirer@^9.0.0, inquirer-autocomplete-prompt@^3.0.0questionary@^2.0.0, prompt_toolkit@^3.0.0Problem: Error [ERR_REQUIRE_ESM]
Solution: Use import instead of require, or add "type": "module" to package.json
Problem: Autocomplete not working
Solution: Install inquirer-autocomplete-prompt plugin
Problem: No module named 'questionary'
Solution: Run pip install questionary
Problem: Prompt rendering issues Solution: Ensure terminal supports ANSI escape codes
Purpose: Provide reusable interactive prompt patterns for CLI development Load when: Building CLIs with user input, creating interactive questionnaires, implementing wizards
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.