Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

inquirer

БесплатноБез исполняемых скриптовНе проверен

Build interactive CLI prompts with Inquirer.js. Use when creating interactive terminal UIs, multi-step wizards, form-like CLI inputs, or configuration…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Inquirer.js

Overview

Inquirer provides interactive prompts for CLIs — text input, confirmations, lists, checkboxes, passwords, and editors. The current API is the modular @inquirer/prompts package (8.x in October 2026): import only the prompts you use, and each supports themes and validation. Besides the ones below there are search (async autocomplete), number, expand, rawlist and editor. Prompts are async functions that resolve to the answer.

Instructions

Install with npm install @inquirer/prompts. It is ESM-only and needs Node.js ^20.17, ^22.13 or >=23.5 (the package's engines field), so use import, not require.

Step 1: Prompts

import { input, select, confirm, checkbox, password, search } from '@inquirer/prompts'

// Text input with validation
const name = await input({
  message: 'Project name:',
  default: 'my-app',
  validate: (v) => v.length >= 2 || 'Name must be at least 2 characters',
})

// Single select
const framework = await select({
  message: 'Choose a framework:',
  choices: [
    { name: 'Next.js', value: 'nextjs', description: 'Full-stack React' },
    { name: 'Remix', value: 'remix', description: 'Web standards focused' },
    { name: 'Astro', value: 'astro', description: 'Content-first' },
    { name: 'Angular', value: 'angular', disabled: '(not available yet)' },
  ],
})

// Multi-select
const features = await checkbox({
  message: 'Select features:',
  choices: [
    { name: 'TypeScript', value: 'typescript', checked: true },
    { name: 'ESLint', value: 'eslint', checked: true },
    { name: 'Tailwind CSS', value: 'tailwind' },
    { name: 'Database (Prisma)', value: 'prisma' },
    { name: 'Auth (NextAuth)', value: 'auth' },
  ],
})

// Confirmation
const proceed = await confirm({ message: 'Create project?', default: true })

// Password (masked)
const apiKey = await password({ message: 'Enter API key:', mask: '*' })

// Async autocomplete: `source` is called on every keystroke, `signal` aborts stale requests
const pkg = await search({
  message: 'Pick an npm package:',
  source: async (term, { signal }) => {
    if (!term) return []
    const res = await fetch(
      `https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(term)}&size=10`,
      { signal },
    )
    const { objects } = await res.json()
    return objects.map((o) => ({ name: o.package.name, value: o.package.name, description: o.package.description }))
  },
})

Step 2: Multi-Step Wizard

async function setupWizard() {
  console.log('🚀 Project Setup Wizard\n')

  const projectName = await input({ message: 'Project name:' })
  const template = await select({
    message: 'Template:',
    choices: [
      { name: 'SaaS Starter', value: 'saas' },
      { name: 'Blog', value: 'blog' },
      { name: 'E-commerce', value: 'ecommerce' },
    ],
  })

  const features = await checkbox({
    message: 'Features:',
    choices: getFeatureChoices(template),    // dynamic based on template, same { name, value } shape
  })

  const useDocker = await confirm({ message: 'Add Docker?', default: false })

  console.log('\n📋 Summary:')
  console.log(`  Name: ${projectName}`)
  console.log(`  Template: ${template}`)
  console.log(`  Features: ${features.join(', ')}`)

  const ok = await confirm({ message: '\nProceed?', default: true })
  if (!ok) { console.log('Cancelled.'); process.exit(0) }

  return { projectName, template, features, useDocker }
}

Step 3: Ctrl+C, timeouts and non-interactive runs

When the user presses Ctrl+C, the prompt promise rejects with an error named ExitPromptError. Catch it, otherwise a stack trace is printed. A second argument (the context) takes an AbortSignal; when it fires, the promise rejects with an error named AbortPromptError, which needs its own check.

import { confirm } from '@inquirer/prompts'

try {
  const deploy = await confirm(
    { message: 'Deploy to production?', default: false },
    { signal: AbortSignal.timeout(30_000) },   // rejects with AbortPromptError after 30 s
  )
  console.log(deploy ? 'Deploying...' : 'Skipped.')
} catch (err) {
  if (err instanceof Error && err.name === 'AbortPromptError') {
    console.log('No answer in 30 s, skipping deploy.')
    process.exit(1)
  }
  if (err instanceof Error && err.name === 'ExitPromptError') {
    console.log('Cancelled.')
    process.exit(130)
  }
  throw err
}

Examples

Example 1: Ask for a project name and stack

Request: "Make create-shop ask for a project name and a framework."

Run the Step 1 input and select calls in a script. Terminal result: ? Project name: (my-app) accepts Enter for the default, then ? Choose a framework: shows a list with the description of the highlighted option below it; the disabled Angular row is greyed out with its reason and cannot be selected. The script then holds name = 'my-app' and framework = 'nextjs'.

Example 2: Wizard that also works in CI

Request: "T

Полный SKILL.md на GitHub

Установить inquirer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл inquirer?

Build interactive CLI prompts with Inquirer.js. Use when creating interactive terminal UIs, multi-step wizards, form-like CLI inputs, or configuration generators with user input.

Как установить скилл inquirer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл inquirer запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить inquirer с