| name | inquirer-prompt-generator |
| description | Generate interactive command-line prompts using Inquirer.js with validation, conditional logic, and custom renderers. Creates user-friendly input collection flows for CLI applications. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
| graph | {"domains":["domain:software-engineering"],"specializations":["specialization:cli-mcp-development"],"skillAreas":["skill-area:cli-design","skill-area:command-line-interface-tools"],"roles":["role:backend-engineer","role:platform-engineer"],"workflows":["workflow:feature-development"],"topics":["topic:developer-experience"]} |
Inquirer Prompt Generator
Generate interactive CLI prompts using Inquirer.js with comprehensive validation, conditional flows, and custom formatting.
Capabilities
- Generate Inquirer.js prompt definitions
- Create multi-step wizard flows
- Implement input validation
- Support conditional prompts
- Generate TypeScript interfaces for answers
- Create custom prompt formatters
Usage
Invoke this skill when you need to:
- Create interactive CLI input collection
- Build configuration wizards
- Implement user confirmation flows
- Generate form-like CLI interfaces
Inputs
| Parameter | Type | Required | Description |
|---|
| flowName | string | Yes | Name of the prompt flow |
| prompts | array | Yes | List of prompt definitions |
| typescript | boolean | No | Generate TypeScript types (default: true) |
| validation | boolean | No | Include validation helpers (default: true) |
Prompt Definition Structure
{
"prompts": [
{
"type": "input",
"name": "projectName",
"message": "What is your project name?",
"default": "my-project",
"validate": {
"required": true,
"pattern": "^[a-z][a-z0-9-]*$",
"message": "Project name must be lowercase with hyphens"
}
},
{
"type": "list",
"name": "template",
"message": "Select a template:",
"choices": [
{
Output Structure
prompts/
├── <flowName>/
│ ├── index.ts # Main prompt flow
│ ├── types.ts # TypeScript interfaces
│ ├── validators.ts # Validation functions
│ ├── formatters.ts # Custom formatters
│ └── README.md # Usage documentation
Generated Code Patterns
Prompt Flow (index.ts)
import { input, select, checkbox, confirm } from '@inquirer/prompts';
import { validateProjectName, validatePort } from './validators';
import type { ProjectConfig } from './types';
export async function createProjectPrompt(): Promise<ProjectConfig> {
const projectName = await input({
message: 'What is your project name?',
default: 'my-project',
validate: validateProjectName,
});
const template = await select({
message: 'Select a template:',
choices: [
{ name: 'React + TypeScript', value: 'react-ts' },
{ name: 'Vue + TypeScript', value: 'vue-ts' },
{ name: 'Node.js + Express', value: 'node-express' },
],
});
let features: string[] = [];
(template !== ) {
features = ({
: ,
: [
{ : , : , : },
{ : , : , : },
{ : , : },
{ : , : },
{ : , : },
],
});
}
installDeps = ({
: ,
: ,
});
{
projectName,
template,
features,
installDeps,
};
}
TypeScript Types (types.ts)
export interface ProjectConfig {
projectName: string;
template: 'react-ts' | 'vue-ts' | 'node-express';
features: Array<'eslint' | 'prettier' | 'husky' | 'jest' | 'docker'>;
installDeps: boolean;
}
export interface TemplateChoice {
name: string;
value: ProjectConfig['template'];
description?: string;
}
Validators (validators.ts)
export function validateProjectName(value: string): string | true {
if (!value.trim()) {
return 'Project name is required';
}
if (!/^[a-z][a-z0-9-]*$/.test(value)) {
return 'Project name must start with a letter and contain only lowercase letters, numbers, and hyphens';
}
if (value.length > 50) {
return 'Project name must be 50 characters or less';
}
return true;
}
export function validatePort(value: string): string | true {
const port = parseInt(value, 10);
if (isNaN(port)) {
return 'Port must be a number';
}
if (port < 1024 || port > 65535) {
return 'Port must be between 1024 and 65535';
}
return true;
}
(): | {
{
(value);
;
} {
;
}
}
(): < | > {
(: ) => {
exists = (value);
(exists) {
;
}
;
};
}
Custom Formatters (formatters.ts)
import chalk from 'chalk';
export function formatProjectName(value: string): string {
return chalk.cyan(value);
}
export function formatFeatures(features: string[]): string {
if (features.length === 0) {
return chalk.dim('None selected');
}
return features.map(f => chalk.green(`+ ${f}`)).join('\n');
}
export function formatSummary(config: ProjectConfig): string {
return `
${chalk.bold('Project Configuration:')}
${chalk.dim('Name:')} ${formatProjectName(config.projectName)}
${chalk.dim('Template:')}
`;
}
Prompt Types
| Type | Description | Use Case |
|---|
| input | Single-line text | Names, values |
| password | Hidden input | Secrets, tokens |
| number | Numeric input | Ports, counts |
| confirm | Yes/No | Confirmations |
| select | Single choice list | Options |
| checkbox | Multiple choice | Features |
| expand | Abbreviated choices | Quick actions |
| editor | Multi-line editor | Long text |
| search | Searchable list | Large lists |
| rawlist | Numbered list | Indexed options |
Validation Patterns
Required Field
validate: (value) => value.trim() ? true : 'This field is required'
Pattern Matching
validate: (value) => /^[a-z-]+$/.test(value) || 'Invalid format'
Async Validation
validate: async (value) => {
const exists = await checkExists(value);
return exists ? 'Already exists' : true;
}
Dependent Validation
validate: (value, answers) => {
if (answers.type === 'advanced' && !value) {
return 'Required for advanced mode';
}
return true;
}
Conditional Prompts
When Function
{
type: 'input',
name: 'apiKey',
message: 'Enter API key:',
when: (answers) => answers.useExternalApi
}
Skip Logic
const prompts = basePrompts.filter(p => {
if (p.name === 'advanced' && !options.showAdvanced) {
return false;
}
return true;
});
Workflow
- Parse prompt definitions - Validate structure
- Generate prompt flow - Create main prompt file
- Generate types - TypeScript interfaces
- Generate validators - Validation functions
- Generate formatters - Display helpers
- Create documentation - Usage guide
Best Practices Applied
- Modern @inquirer/prompts API
- Reusable validation functions
- Type-safe answer interfaces
- Conditional flow support
- Custom formatters for output
- Clear error messages
References
Target Processes
- interactive-prompt-system
- interactive-form-implementation
- cli-application-bootstrap