xiaohongshu
xiaohongshu
gluegun-patterns
Gluegun CLI toolkit patterns for TypeScript-powered command-line apps. Use when building CLI tools, creating command structures, implementing template systems, filesystem operations, HTTP utilities, prompts, or plugin architectures with Gluegun.
Full skill instructions
Provides comprehensive patterns and templates for building TypeScript-powered CLI applications using the Gluegun toolkit. Gluegun offers parameters, templates, filesystem operations, HTTP utilities, prompts, and extensible plugin architecture.
Gluegun provides these essential toolbox features:
Initialize Gluegun CLI structure:
import { build } from 'gluegun'
const cli = build()
.brand('mycli')
.src(__dirname)
.plugins('./node_modules', { matching: 'mycli-*', hidden: true })
.help()
.version()
.create()
Create command structure:
src/commands/ directoryGluegunCommand objecttemplates/ directorytemplates/commands/basic-command.ts.ejsImplement command with toolbox:
module.exports = {
name: 'generate',
run: async (toolbox) => {
const { template, print, parameters } = toolbox
const name = parameters.first
await template.generate({
template: 'model.ts.ejs',
target: `src/models/${name}.ts`,
props: { name }
})
print.success(`Generated ${name} model`)
}
}
Template file structure:
templates/ directory<%= variable %>, <%- unescaped %>templates/toolbox/template-examples.ejsGenerate files from templates:
await template.generate({
template: 'component.tsx.ejs',
target: `src/components/${name}.tsx`,
props: { name, style: 'functional' }
})
Helper functions:
props.camelCase - camelCase conversionprops.pascalCase - PascalCase conversionprops.kebabCase - kebab-case conversionscripts/template-helpers.tsCommon operations (fs-jetpack):
// Read/write files
const config = await filesystem.read('config.json', 'json')
await filesystem.write('output.txt', data)
// Directory operations
await filesystem.dir('src/components')
const files = filesystem.find('src', { matching: '*.ts' })
// Copy/move/remove
await filesystem.copy('template', 'output')
await filesystem.move('old.txt', 'new.txt')
await filesystem.remove('temp')
Path utilities:
filesystem.path('src', 'commands') // Join paths
filesystem.cwd() // Current directory
filesystem.separator // OS-specific separator
API interactions:
const api = http.create({
baseURL: 'https://api.example.com',
headers: { 'Authorization': 'Bearer token' }
})
const response = await api.get('/users')
const result = await api.post('/users', { name: 'John' })
Error handling:
if (!response.ok) {
print.error(response.problem)
return
}
User input patterns:
// Ask question
const result = await prompt.ask({
type: 'input',
name: 'name',
message: 'What is your name?'
})
// Confirm action
const proceed = await prompt.confirm('Continue?')
// Select from list
const choice = await prompt.ask({
type: 'select',
name: 'framework',
message: 'Choose framework:',
choices: ['React', 'Vue', 'Angular']
})
Multi-select and complex forms:
examples/prompts/multi-select.tstemplates/toolbox/prompt-examples.ts.ejsCreate extensible plugins:
// Plugin structure
export default (toolbox) => {
const { filesystem, template } = toolbox
// Add custom extension
toolbox.myFeature = {
doSomething: () => { /* ... */ }
}
}
Load plugins:
cli.plugins('./node_modules', { matching: 'mycli-*' })
cli.plugins('./plugins', { matching: '*.js' })
Plugin examples:
examples/plugin-system/custom-plugin.tstemplates/plugins/plugin-template.ts.ejsColorful output:
print.info('Information message')
print.success('Success message')
print.warning('Warning message')
print.error('Error message')
print.highlight('Highlighted text')
print.muted('Muted text')
Spinners and progress:
const spinner = print.spin('Loading...')
await doWork()
spinner.succeed('Done!')
// Or fail
spinner.fail('Something went wrong')
Tables and formatting:
print.table([
['Name', 'Age'],
['John', '30'],
['Jane', '25']
])
Execute external commands:
const output = await system.run('npm install')
const result = await system.exec('git status')
// Spawn with options
await system.spawn('npm run build', { stdio: 'inherit' })
Check command availability:
const hasGit = await system.which('git')
// Add line after pattern
await patching.update('package.json', (content) => {
const pkg = JSON.parse(content)
pkg.scripts.build = 'tsc'
return JSON.stringify(pkg, null, 2)
})
// Insert import statement
await patching.insert('src/index.ts', 'import { Router } from "express"')
Use these scripts to validate Gluegun CLI implementations:
scripts/validate-cli-structure.sh - Check directory structurescripts/validate-commands.sh - Verify command formatscripts/validate-templates.sh - Check template syntaxscripts/test-cli-build.sh - Run full CLI build testtemplates/commands/basic-command.ts.ejs - Simple commandtemplates/commands/generator-command.ts.ejs - File generatortemplates/commands/api-command.ts.ejs - HTTP interactiontemplates/extensions/custom-toolbox.ts.ejs - Toolbox extensiontemplates/extensions/helper-functions.ts.ejs - Utility functionstemplates/plugins/plugin-template.ts.ejs - Plugin structuretemplates/plugins/plugin-with-commands.ts.ejs - Plugin with commandstemplates/toolbox/template-examples.ejs - Template patternstemplates/toolbox/prompt-examples.ts.ejs - Prompt patternstemplates/toolbox/filesystem-examples.ts.ejs - Filesystem patternsSee examples/basic-cli/ for complete working CLI:
See examples/plugin-system/ for extensible architecture:
See examples/template-generator/ for advanced patterns:
Command Organization
Template Design
Error Handling
Plugin Architecture
Testing
npm install gluegunPurpose: Enable rapid CLI development with Gluegun patterns and best practices Load when: Building CLI tools, command structures, template systems, or plugin architectures
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