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.
Provides Gluegun CLI toolkit patterns for building TypeScript-powered command-line apps with parameters, templates, filesystem operations, HTTP utilities, prompts, and plugin architectures. Use when creating CLI tools with command structures, file generation, or interactive user interfaces.
/plugin marketplace add vanman2024/cli-builder/plugin install cli-builder@cli-builderThis skill is limited to using the following tools:
README.mdexamples/basic-cli/README.mdexamples/basic-cli/src/cli.tsexamples/basic-cli/src/commands/generate.tsexamples/basic-cli/src/commands/hello.tsexamples/basic-cli/templates/component.ts.ejsexamples/plugin-system/README.mdexamples/template-generator/README.mdscripts/template-helpers.tsscripts/test-cli-build.shscripts/validate-cli-structure.shscripts/validate-commands.shscripts/validate-templates.shtemplates/commands/api-command.ts.ejstemplates/commands/basic-command.ts.ejstemplates/commands/generator-command.ts.ejstemplates/extensions/custom-toolbox.ts.ejstemplates/extensions/helper-functions.ts.ejstemplates/plugins/plugin-template.ts.ejstemplates/plugins/plugin-with-commands.ts.ejsProvides 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
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.