home / skills / danielmiessler / personal_ai_infrastructure / createcli

This skill helps you generate production-ready TypeScript CLIs quickly with full documentation, type safety, and robust CLI-first architecture.

npx playbooks add skill danielmiessler/personal_ai_infrastructure --skill createcli

Review the files below or copy the command above to add this skill to your agents.

Files (7)
SKILL.md
9.9 KB
---
name: CreateCLI
description: Generate TypeScript CLIs. USE WHEN create CLI, build CLI, command-line tool. SkillSearch('createcli') for docs.
---

## Customization

**Before executing, check for user customizations at:**
`~/.claude/skills/CORE/USER/SKILLCUSTOMIZATIONS/CreateCLI/`

If this directory exists, load and apply any PREFERENCES.md, configurations, or resources found there. These override default behavior. If the directory does not exist, proceed with skill defaults.

# CreateCLI

**Automated CLI Generation System**

Generate production-ready TypeScript CLIs with comprehensive documentation, type safety, error handling, and CLI-First Architecture principles.

---


## Voice Notification

**When executing a workflow, do BOTH:**

1. **Send voice notification**:
   ```bash
   curl -s -X POST http://localhost:8888/notify \
     -H "Content-Type: application/json" \
     -d '{"message": "Running the WORKFLOWNAME workflow from the CreateCLI skill"}' \
     > /dev/null 2>&1 &
   ```

2. **Output text notification**:
   ```
   Running the **WorkflowName** workflow from the **CreateCLI** skill...
   ```

**Full documentation:** `~/.claude/skills/CORE/SkillNotifications.md`

## Workflow Routing

Route to the appropriate workflow based on the request.

**When executing a workflow, output this notification directly:**

```
Running the **WorkflowName** workflow from the **CreateCLI** skill...
```

  - Create a new CLI tool from scratch → `Workflows/CreateCli.md`
  - Add a new command to existing CLI → `Workflows/AddCommand.md`
  - Upgrade CLI to higher tier → `Workflows/UpgradeTier.md`

---

## šŸš€ WHEN TO ACTIVATE THIS SKILL

Activate when you see these patterns:

### Direct Requests
- "Create a CLI for [API/service/tool]"
- "Build a command-line interface for X"
- "Make a CLI that does Y"
- "Generate a TypeScript CLI"
- "I need a CLI tool for Z"

### Context Clues
- 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
- User working with API that lacks official CLI → Suggest creating one

### Examples
- āœ… "Create a CLI for the GitHub API"
- āœ… "Build a command-line tool to process CSV files"
- āœ… "Make a CLI for my database migrations"
- āœ… "Generate a CLI that wraps this API"
- āœ… "I need a tool like llcli but for Notion API"

---

## šŸ’” CORE CAPABILITIES

### Three-Tier Template System

**Tier 1: llcli-Style (DEFAULT - 80% of use cases)**
- Manual argument parsing (process.argv)
- Zero framework dependencies
- Bun + TypeScript
- Type-safe interfaces
- ~300-400 lines total
- **Perfect for:** API clients, data transformers, simple automation

**When to use Tier 1:**
- āœ… 2-10 commands
- āœ… Simple arguments (flags, values)
- āœ… JSON output
- āœ… No subcommands
- āœ… Fast development

**Tier 2: Commander.js (ESCALATION - 15% of use cases)**
- Framework-based parsing
- Subcommands + nested options
- Auto-generated help
- Plugin-ready
- **Perfect for:** Complex multi-command tools

**When to use Tier 2:**
- āŒ 10+ commands needing grouping
- āŒ Complex nested options
- āŒ Plugin architecture
- āŒ Multiple output formats

**Tier 3: oclif (REFERENCE ONLY - 5% of use cases)**
- Documentation only (no templates)
- Enterprise-grade plugin systems
- **Perfect for:** Heroku CLI, Salesforce CLI scale (rare)

### What Every Generated CLI Includes

**1. Complete Implementation**
- TypeScript source with full type safety
- All commands functional and tested
- Error handling with proper exit codes
- Configuration management

**2. Comprehensive Documentation**
- README.md with philosophy, usage, examples
- QUICKSTART.md for common patterns
- Inline help text (--help)
- API response documentation

**3. Development Setup**
- package.json (Bun configuration)
- tsconfig.json (strict mode)
- .env.example (configuration template)
- File permissions configured

**4. Quality Standards**
- Type-safe throughout
- Deterministic output (JSON)
- Composable (pipes to jq, grep)
- Error messages with context
- Exit code compliance

---

## šŸ—ļø INTEGRATION WITH PAI

### Technology Stack Alignment

Generated CLIs follow PAI standards:
- āœ… **Runtime:** Bun (NOT Node.js)
- āœ… **Language:** TypeScript (NOT JavaScript or Python)
- āœ… **Package Manager:** Bun (NOT npm/yarn/pnpm)
- āœ… **Testing:** Vitest (when tests added)
- āœ… **Output:** Deterministic JSON (composable)
- āœ… **Documentation:** README + QUICKSTART (llcli pattern)

### Repository Placement

Generated CLIs go to:
- `~/.claude/Bin/[cli-name]/` - Personal CLIs (like llcli)
- `~/Projects/[project-name]/` - Project-specific CLIs
- `~/Projects/PAI/Examples/clis/` - Example CLIs (PUBLIC repo)

**SAFETY:** Always verify repository location before git operations

### CLI-First Architecture Principles

Every generated CLI follows:
1. **Deterministic** - Same input → Same output
2. **Clean** - Single responsibility
3. **Composable** - JSON output pipes to other tools
4. **Documented** - Comprehensive help and examples
5. **Testable** - Predictable behavior

---

## šŸ“š EXTENDED CONTEXT

**For detailed information, read these files:**

### Workflow Documentation
- `Workflows/Create-cli.md` - Main CLI generation workflow (decision tree, 10-step process)
- `Workflows/Add-command.md` - Add commands to existing CLIs
- `Workflows/Upgrade-tier.md` - Migrate simple → complex
- `Workflows/Add-testing.md` - Test suite generation
- `Workflows/Setup-distribution.md` - Publishing configuration

### Reference Documentation
- `framework-comparison.md` - Manual vs Commander vs oclif (with research)
- `patterns.md` - Common CLI patterns (from llcli analysis)
- `testing-strategies.md` - CLI testing approaches (Jest, Vitest, Playwright)
- `distribution.md` - Publishing strategies (npm, standalone binaries)
- `typescript-patterns.md` - Type safety patterns (from tsx, vite, bun research)

### Tools & Templates
- `Tools/templates/tier1/` - llcli-style templates (default)
- `Tools/templates/tier2/` - Commander.js templates (escalation)
- `Tools/generators/` - Generation scripts (TypeScript)
- `Tools/validators/` - Quality gates (validation)

### Examples
- `examples/api-cli/` - API client (reference: llcli)
- `examples/file-processor/` - File operations
- `examples/data-transform/` - Complex CLI (Commander.js)

---

## šŸ“– EXAMPLES

### Example 1: API Client CLI (Tier 1)

**User Request:**
"Create a CLI for the GitHub API that can list repos, create issues, and search code"

**Generated Structure:**
```
~/.claude/Bin/ghcli/
ā”œā”€ā”€ ghcli.ts              # 350 lines, complete implementation
ā”œā”€ā”€ package.json          # Bun + TypeScript
ā”œā”€ā”€ tsconfig.json         # Strict mode
ā”œā”€ā”€ .env.example          # GITHUB_TOKEN=your_token
ā”œā”€ā”€ README.md             # Full documentation
└── QUICKSTART.md         # Common use cases
```

**Usage:**
```bash
ghcli repos --user exampleuser
ghcli issues create --repo pai --title "Bug fix"
ghcli search "typescript CLI"
ghcli --help
```

---

### Example 2: File Processor (Tier 1)

**User Request:**
"Build a CLI to convert markdown files to HTML with frontmatter extraction"

**Generated Structure:**
```
~/.claude/Bin/md2html/
ā”œā”€ā”€ md2html.ts
ā”œā”€ā”€ package.json
ā”œā”€ā”€ README.md
└── QUICKSTART.md
```

**Usage:**
```bash
md2html convert input.md output.html
md2html batch *.md output/
md2html extract-frontmatter post.md
```

---

### Example 3: Data Pipeline (Tier 2)

**User Request:**
"Create a CLI for data transformation with multiple formats, validation, and analysis commands"

**Generated Structure:**
```
~/.claude/Bin/data-cli/
ā”œā”€ā”€ data-cli.ts           # Commander.js with subcommands
ā”œā”€ā”€ package.json
ā”œā”€ā”€ README.md
└── QUICKSTART.md
```

**Usage:**
```bash
data-cli convert json csv input.json
data-cli validate schema data.json
data-cli analyze stats data.csv
data-cli transform filter --column=status --value=active
```

---

## āœ… QUALITY STANDARDS

Every generated CLI must pass these gates:

### 1. Compilation
- āœ… TypeScript compiles with zero errors
- āœ… Strict mode enabled
- āœ… No `any` types except justified

### 2. Functionality
- āœ… All commands work as specified
- āœ… Error handling comprehensive
- āœ… Exit codes correct (0 success, 1 error)

### 3. Documentation
- āœ… README explains philosophy and usage
- āœ… QUICKSTART has common examples
- āœ… --help text comprehensive
- āœ… All flags/options documented

### 4. Code Quality
- āœ… Type-safe throughout
- āœ… Clean function separation
- āœ… Error messages actionable
- āœ… Configuration externalized

### 5. Integration
- āœ… Follows PAI tech stack (Bun, TypeScript)
- āœ… CLI-First Architecture principles
- āœ… Deterministic output (JSON)
- āœ… Composable with other tools

---

## šŸŽÆ PHILOSOPHY

### Why This Skill Exists

Developers repeatedly create CLIs for APIs and tools. Each time:
1. Starts with bash script
2. Realizes it needs error handling
3. Realizes it needs help text
4. Realizes it needs type safety
5. Rewrites in TypeScript
6. Adds documentation
7. Now has production CLI

**This skill automates steps 1-7.**

### The llcli Pattern

The `llcli` CLI (Limitless.ai API) proves this pattern works:
- 327 lines of TypeScript
- Zero dependencies (no framework)
- Complete error handling
- Comprehensive documentation
- Production-ready immediately

**This skill replicates that success.**

### Design Principles

1. **Start Simple** - Default to Tier 1 (llcli-style)
2. **Escalate When Needed** - Tier 2 only when justified
3. **Complete, Not Scaffold** - Every CLI is production-ready
4. **Documentation First** - README explains "why" not just "how"
5. **Type Safety** - TypeScript strict mode always

---

## šŸ”— RELATED SKILLS

- **development** - For complex feature development (not CLI-specific)
- **mcp** - For web scraping CLIs (Bright Data, Apify wrappers)
- **lifelog** - Example of skill using llcli

---

**This skill turns "I need a CLI for X" into production-ready tools in minutes, following proven patterns from llcli and CLI-First Architecture.**

Overview

This skill generates production-ready TypeScript command-line tools following CLI-First Architecture and PAI standards. It defaults to a lightweight, zero-dependency llcli-style template, escalates to Commander.js when needed, and outputs complete code, tests, and documentation ready for Bun runtime. It applies user customizations if present before generation.

How this skill works

Before running, the skill checks for user customizations at ~/.claude/skills/CORE/USER/SKILLCUSTOMIZATIONS/CreateCLI/ and applies any preferences or config found there. It routes your request to the proper workflow (create new CLI, add command, upgrade tier), emits a voice and text notification when executing, then generates TypeScript source, strict tsconfig, Bun package setup, docs, and quality gates. Templates include Tier 1 (llcli-style), Tier 2 (Commander.js), and Tier 3 guidance for oclif-scale projects.

When to use it

  • You want a TypeScript CLI to wrap an API or automate repetitive terminal tasks
  • You repeatedly run complex bash scripts and need type safety, help text, and error handling
  • You need a small, composable JSON-output CLI for pipelines and tooling
  • You plan a multi-command tool with subcommands and need Commander.js escalation
  • You need production-ready docs, testing setup, and Bun-compatible packaging

Best practices

  • Default to Tier 1 (llcli-style) for 2–10 commands and simple flags to stay minimal and fast
  • Escalate to Tier 2 (Commander.js) only when subcommands, nested options, or plugins are required
  • Keep output deterministic JSON for composability with jq and other tools
  • Externalize configuration via .env and provide .env.example for reproducibility
  • Enforce strict TypeScript, explicit types, and exit codes for predictable behavior

Example use cases

  • Create a GitHub API CLI to list repos, create issues, and search code (Tier 1)
  • Build a file-processor CLI to convert markdown to HTML and extract frontmatter (Tier 1)
  • Generate a data pipeline CLI with conversion, validation, and analysis subcommands (Tier 2)
  • Add a new command to an existing CLI to support a new API endpoint or data format

FAQ

Where does the generated CLI get placed?

Personal CLIs go under ~/.claude/Bin/[cli-name]/ by default; project-specific CLIs can be placed in ~/Projects/[project-name]/. The skill prompts to confirm location before any git ops.

Which runtime and package manager are used?

Generated CLIs target Bun as the runtime and Bun tooling for package management; TypeScript strict mode is enforced and tests use Vitest when included.