xiaohongshu
xiaohongshu
create-questions
Build interactive CLI questionnaires with validation, conditional logic, parameter mapping, and review capabilities using the question-and-answer library
Full skill instructions
You are helping developers integrate the question-and-answer library into their Node.js projects. This library provides command-line question and answer functionality for building interactive CLI interrogations.
Use this skill when the user wants to:
npm install question-and-answer
The library centers on the Questioner class, which processes an interrogation bundle - an array of actions that execute sequentially. Each action is one of four types:
import { Questioner } from 'question-and-answer'
const interactions = [
// Array of action objects
]
const questioner = new Questioner({ interactions })
await questioner.question()
// Access results
const value = questioner.get('PARAMETER_NAME')
Questions MUST have:
prompt - The question textparameter - Variable name to store the answerQuestions MAY have:
type - "boolean", "integer", "numeric", or "string" (default)default - Default valueoptions - Array of choices (creates selection menu)multiValue - Boolean, allows multiple comma-separated answersseparator - Custom separator for multiValue (default: comma)condition - Expression; skip if falsyvalidations - Object with validation rulesnoSkipDefined - Boolean, ask even if parameter already defined{
prompt: "What is your name?",
parameter: "USER_NAME"
}
{
prompt: "Choose a color",
options: ["red", "blue", "green"],
parameter: "COLOR"
}
{
prompt: "Enable debug mode?",
type: "boolean",
parameter: "DEBUG",
default: false
}
Statements display text without user input:
{
statement: "Welcome to the configuration wizard!"
}
{
statement: "<warn>Warning:<rst> This will overwrite existing files",
condition: "FILES_EXIST === true"
}
Maps derive new parameters from existing ones:
{
maps: [
{
source: "AGE >= 18",
parameter: "IS_ADULT",
type: "boolean"
},
{
source: "PRICE * QUANTITY",
parameter: "TOTAL",
type: "numeric"
},
{
value: "literal-value",
parameter: "CONSTANT"
}
]
}
Maps use condition-eval syntax for source expressions.
Reviews let users verify and modify answers:
{
review: "questions" // Only review questions
}
{
review: "maps" // Only review maps
}
{
review: "all" // Review both
}
During review:
- to clear valueUse the validations object with specify-string format:
{
prompt: "Enter email",
parameter: "EMAIL",
validations: {
"match-regexp": "^[^@]+@[^@]+\\.[^@]+$"
}
}
{
prompt: "Rate 1-10",
type: "integer",
parameter: "RATING",
validations: {
"min-value": 1,
"max-value": 10
}
}
{
prompt: "Select 2-3 options",
multiValue: true,
options: ["A", "B", "C", "D"],
parameter: "CHOICES",
validations: {
"min-count": 2,
"max-count": 3
}
}
Common validation keys:
min-length, max-length - String lengthmin-value, max-value - Numeric rangemin-count, max-count - Multi-value countrequire-exact - Exact match requiredrequire-truthy, require-falsy - Boolean validationmatch-regexp - Regular expression patternAny action can have a condition field with an expression:
{
prompt: "Enter API key",
parameter: "API_KEY",
condition: "ENVIRONMENT === 'production'"
}
{
statement: "Debug mode is enabled",
condition: "DEBUG === true"
}
Conditions use condition-eval syntax and can reference any previously set parameter.
The type field coerces answers:
"boolean" or "bool" - Accepts: y/yes/true/n/no/false (case-insensitive)"integer" or "int" - Whole numbers only"numeric" or "float" - Decimal numbers"string" - Default, no coercion// Single value
const name = questioner.get('USER_NAME')
// Full result object (includes metadata)
const result = questioner.getResult('USER_NAME')
// Check existence
if (questioner.has('EMAIL')) { ... }
// All values as object
const values = questioner.values
// All results (with metadata)
const results = questioner.results
// Interrogation with dispositions
const interactions = questioner.interactions
const questioner = new Questioner({
interactions, // Required: array of actions
initialParameters: {}, // Optional: pre-populated values
noSkipDefined: false, // Optional: ask defined questions
input: process.stdin, // Optional: custom input stream
output: customOutput, // Optional: custom output handler
printOptions: {} // Optional: magic-print options
})
Begin with basic questions, add complexity incrementally:
const interactions = [
{ prompt: "Project name", parameter: "NAME" },
{ prompt: "Version", parameter: "VERSION", default: "1.0.0" }
]
Layer in validation for data quality:
{
prompt: "Project name",
parameter: "NAME",
validations: {
"min-length": 1,
"max-length": 50,
"match-regexp": "^[a-z0-9-]+$"
}
}
When answers are constrained, use options:
{
prompt: "License",
options: ["MIT", "Apache-2.0", "GPL-3.0", "ISC"],
parameter: "LICENSE"
}
Build dynamic flows with conditions:
{
prompt: "Use TypeScript?",
type: "boolean",
parameter: "USE_TS"
},
{
prompt: "TypeScript version",
parameter: "TS_VERSION",
default: "latest",
condition: "USE_TS === true"
}
Use maps for calculated parameters:
{
maps: [
{
source: "USE_TS === true",
parameter: "FILE_EXTENSION",
value: "ts"
},
{
source: "USE_TS === false",
parameter: "FILE_EXTENSION",
value: "js"
}
]
}
Let users verify their answers:
{ review: "questions" }
See patterns.md for detailed examples of:
Test bundles using the CLI:
npx qna path/to/interrogation.json
noSkipDefined: true)type for non-string data to ensure proper coercionWhen you need detailed information, refer to:
reference.md - Complete API referencepatterns.md - Common implementation patternsexamples/ - Working interrogation bundlesWhen generating interrogation bundles:
{ "actions": [...] }npx qna bundle.json before integrationThe library throws standard errors:
ArgumentInvalidError - Validation failedArgumentMissingError - Required field missingArgumentTypeError - Type mismatchAlways wrap questioner.question() in try-catch for production use.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience