| name | PAI CreateCLI Skill | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| pack-id | danielmiessler-createcli-skill-v2.3.0 | ||||||||||
| version | 2.3.0 | ||||||||||
| author | danielmiessler | ||||||||||
| description | Automated CLI generation system - create production-ready TypeScript CLIs with comprehensive documentation, type safety, and error handling | ||||||||||
| type | skill | ||||||||||
| purpose-type |
|
||||||||||
| platform | claude-code | ||||||||||
| dependencies | |||||||||||
| keywords |
|
Generate production-ready TypeScript CLIs in minutes following the battle-tested llcli pattern
You are receiving a PAI Pack - a modular upgrade for AI agent systems.
What is PAI? See: PAI Project Overview
What is a Pack? See: Pack System
This pack adds the CreateCLI skill - an automated CLI generation system that produces production-quality TypeScript command-line interfaces. Instead of writing CLIs from scratch every time, you get complete, immediately usable tools with:
- Full type safety and comprehensive error handling
- Documentation (README + QUICKSTART) following CLI-First Architecture
- Three-tier template system (manual parsing, Commander.js, oclif reference)
- Quality validation gates ensuring production readiness
Core principle: "I need a CLI for X" becomes a production tool in minutes.
The skill follows the proven llcli pattern - a 327-line TypeScript CLI that demonstrates the optimal balance of simplicity, completeness, and maintainability.
Please follow the installation instructions in INSTALL.md to integrate this pack into your infrastructure.
| Component | File | Purpose |
|---|---|---|
| Main Skill Definition | skills/CreateCLI/SKILL.md |
Routing, activation triggers, capabilities overview |
| Framework Comparison | skills/CreateCLI/FrameworkComparison.md |
Manual vs Commander vs oclif decision guide |
| CLI Patterns | skills/CreateCLI/Patterns.md |
Reusable patterns from production CLIs |
| TypeScript Patterns | skills/CreateCLI/TypescriptPatterns.md |
Type safety patterns from tsx, vite, bun |
| Create Workflow | skills/CreateCLI/Workflows/CreateCli.md |
10-step CLI generation process |
| Add Command Workflow | skills/CreateCLI/Workflows/AddCommand.md |
Extend existing CLIs |
| Upgrade Tier Workflow | skills/CreateCLI/Workflows/UpgradeTier.md |
Migrate from Tier 1 to Tier 2 |
Summary:
- Files created: 7
- Workflows: 3
- Dependencies: None (Bun runtime required)
Developers repeatedly face the same CLI creation pattern:
- Start with a bash script
- Realize it needs error handling
- Realize it needs help text
- Realize it needs type safety
- Rewrite in TypeScript
- Add comprehensive documentation
- Now have a production-ready CLI
This cycle takes hours or days. Every API wrapper, data transformer, and automation tool follows the same journey. And each time:
- Architecture decisions are reinvented
- Help text formats vary wildly
- Error handling patterns differ
- Documentation quality is inconsistent
- Type safety is often an afterthought
The deeper problem: There's no standardized way to create CLIs that are:
- Deterministic (same input produces same output)
- Composable (JSON output pipes to jq, grep, other tools)
- Documented (users understand not just "how" but "why")
- Tested (predictable, verifiable behavior)
Without a system, every CLI is an island - different patterns, different quality, different maintainability.
The CreateCLI skill automates steps 1-7 with a systematic approach:
Three-Tier Template System:
| Tier | Framework | Use Case | % of CLIs |
|---|---|---|---|
| Tier 1 | Manual parsing (llcli pattern) | API clients, file processors, simple automation | 80% |
| Tier 2 | Commander.js | 10+ commands with subgroups, plugins | 15% |
| Tier 3 | oclif (reference only) | Enterprise-scale (Heroku CLI) | 5% |
Decision Tree: The skill uses deterministic criteria to select the right tier:
- Does it need 10+ commands with grouping? -> Tier 2
- Does it need plugin architecture? -> Tier 2
- Does it need git-style subcommands? -> Tier 2
- Otherwise -> Tier 1 (default)
What Every Generated CLI Includes:
- Complete TypeScript implementation with strict mode
- Comprehensive documentation (README + QUICKSTART)
- Error handling with proper exit codes
- Configuration management from ${PAI_DIR}/.env
- Help text following CLI-First Architecture principles
User Request: "Create a CLI for the GitHub API"
|
v
+---------------+---------------+
| CreateCLI Skill Decision |
| Tree Routing |
+---------------+---------------+
|
+---------------+---------------+
| Tier Selection (1/2/3) |
| Based on command complexity |
+---------------+---------------+
|
+---------------+---------------+
| 10-Step Generation Flow |
+---------------+---------------+
|
+----+----+----+----+----+----+----+----+----+----+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
+----+----+----+----+----+----+----+----+----+----+
|Req |Tier|Int |Cfg |Cmd |Hlp |Main|Doc |Sup |Val |
| | |Def | | |Txt | | |File| |
+----+----+----+----+----+----+----+----+----+----+
|
v
+---------------+---------------+
| Production CLI |
| ~/.claude/Bin/ghcli/ |
| ghcli.ts (350 lines) |
| README.md, QUICKSTART.md |
| package.json, tsconfig.json |
+-------------------------------+
Architecture Layers:
- SKILL.md - Activation triggers and routing (loaded first)
- Reference Docs - Framework comparison, patterns (loaded on-demand)
- Workflows/ - Step-by-step procedures for each operation
- Quality Gates - Validation before declaring success
Why This Architecture Matters:
The skill encodes expert knowledge about CLI development:
- When manual parsing beats frameworks (80% of cases)
- TypeScript patterns from tsx, vite, turbo, bun
- Error handling from pnpm, Shopify CLI
- Documentation patterns from llcli
A naive approach would just generate code. This approach:
- Routes to the right tier automatically
- Uses proven patterns from production CLIs
- Validates output before declaring success
- Produces consistent, maintainable results
This sounds similar to Yeoman generators which also scaffold CLI tools. What makes this approach different?
Yeoman creates project scaffolding - directories, config files, basic structure. This skill creates COMPLETE, WORKING CLIs. You don't scaffold and then implement; you describe what you need and receive production-ready code with documentation, error handling, type safety, and configuration management already done.
- Complete implementation, not just project skeleton structure
- Intelligent tier selection based on actual requirements
- Documentation explains "why" not just "how" to use
- Quality gates validate output before declaring success
See INSTALL.md for complete installation instructions.
The skill activates on these patterns:
| Trigger | Example | Workflow |
|---|---|---|
| Create CLI | "Create a CLI for the Notion API" | CreateCli.md |
| Build CLI | "Build a command-line tool for CSV processing" | CreateCli.md |
| Add command | "Add search command to ghcli" | AddCommand.md |
| Extend CLI | "Extend notioncli with export feature" | AddCommand.md |
| Upgrade tier | "Upgrade ghcli to use Commander" | UpgradeTier.md |
Context-based activation:
- User describes repetitive API calls -> Suggest CLI
- User mentions "I keep typing this command" -> Suggest CLI wrapper
- User has bash script doing complex work -> Suggest TypeScript CLI replacement
Request: "Create a CLI for the GitHub API that can list repos, create issues, and search code"
Generated:
~/.claude/Bin/ghcli/
ghcli.ts # 350 lines, complete implementation
package.json # Bun + TypeScript configuration
tsconfig.json # Strict mode enabled
.env.example # GITHUB_TOKEN=your_token
README.md # Full documentation with philosophy
QUICKSTART.md # Common use cases
Usage:
ghcli repos --user exampleuser
ghcli issues create --repo pai --title "Bug fix"
ghcli search "typescript CLI"
ghcli --helpRequest: "Build a CLI to convert markdown files to HTML with frontmatter extraction"
Generated:
md2html convert input.md output.html
md2html batch *.md output/
md2html extract-frontmatter post.mdRequest: "Create a CLI for data transformation with multiple formats, validation, and analysis"
Generated:
data-cli convert json csv input.json --output data.csv
data-cli validate schema data.json --strict
data-cli analyze stats data.csv
data-cli transform filter --column=status --value=activeNo global configuration required.
Each generated CLI configures itself:
- API keys:
${PAI_DIR}/.env(per PAI convention) - Output directory:
${PAI_DIR}/Bin/[cli-name]/(default) - Project CLIs:
~/Projects/[project-name]/(when specified)
Bun runtime required:
curl -fsSL https://bun.sh/install | bashWhat to Customize: Add organization-specific patterns to Patterns.md
Why: If your team has specific CLI conventions (error codes, logging format, configuration paths), codifying them ensures all generated CLIs follow the same standards.
Process:
- Identify your team's CLI patterns
- Add them to
skills/CreateCLI/Patterns.md - Reference them in the CreateCli workflow
Expected Outcome: All generated CLIs follow your organization's standards automatically.
| Customization | File | Impact |
|---|---|---|
| Default output directory | SKILL.md | Changes where CLIs are created |
| Additional tier templates | Workflows/CreateCli.md | New generation patterns |
| Framework preferences | FrameworkComparison.md | Different tier recommendations |
- Original concept: Daniel Miessler - developed as part of PAI infrastructure
- Reference implementation: llcli (Limitless.ai CLI) - 327 lines, zero dependencies, production-ready
- Research sources: tsx, vite, turbo, bun, pnpm, Shopify CLI
- Commander.js - Framework used for Tier 2 CLIs
- oclif - Reference for enterprise-scale Tier 3 patterns
- cleye - Alternative type-safe CLI library (mentioned in patterns)
- pai-development-skill - For complex feature development
- pai-core-install - Core PAI infrastructure
- Bun runtime - Required for generated CLIs
- jq - For parsing CLI JSON output
None
None
- Development Skill - For non-CLI development work
- PAI Development Tools - Development productivity packs
- Initial PAI pack release
- Three-tier template system (manual, Commander.js, oclif reference)
- Configuration flags standard (mode, output, resource flags)
- Quality gates for validation
- Comprehensive documentation patterns
- Developed as internal skill in PAI system
- Based on llcli production implementation
- Refined through dozens of CLI generations