From cli-generator
Generates a production-ready Bun CLI from OpenAPI, JSON Schema, GraphQL SDL, markdown specs, or natural-language descriptions. Includes arg parsing, autocomplete, man page, and typed API client.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cli-generator:cli-generatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
SPEC → Bun CLI. Production-ready. Autocomplete, --help, token-aware output.
SPEC → Bun CLI. Production-ready. Autocomplete, --help, token-aware output.
/cli-generator from-spec <spec-file> — OpenAPI / JSON Schema → CLI
/cli-generator from-api <url> — live API → CLI (probe endpoints)
/cli-generator from-description "<text>" — natural language → CLI
/cli-generator validate <cli-dir> — check generated CLI against spec
| Source | Example | Best for |
|---|---|---|
| OpenAPI 3.x | openapi.yaml, swagger.json | REST APIs |
| JSON Schema | schema.json | Data tools, validators |
| GraphQL SDL | schema.graphql | GraphQL APIs |
| Markdown spec | SPEC.md | Feature-driven design |
| NL description | "CLI to manage user accounts with CRUD" | Rapid prototyping |
| Live API URL | https://api.example.com | Reverse-engineering |
my-cli/
├── package.json # bin entry, dependencies
├── tsconfig.json # Bun-optimized TS config
├── src/
│ ├── index.ts # entry point, commander setup
│ ├── commands/ # one file per subcommand
│ │ ├── list.ts
│ │ ├── get.ts
│ │ ├── create.ts
│ │ ├── update.ts
│ │ └── delete.ts
│ ├── lib/
│ │ ├── client.ts # typed API client (generated)
│ │ ├── format.ts # output formatters (json, table, yaml)
│ │ └── config.ts # env vars, config file handling
│ └── types.ts # generated from spec
├── completions/
│ ├── bash.sh
│ ├── zsh.sh
│ └── fish.sh
├── man/
│ └── my-cli.1 # man page
├── test/
│ └── commands.test.ts # bun test suite
├── README.md # usage docs
└── Makefile # build, install, test
Claude will:
package.json + tsconfig.jsonbun testbun run src/index.ts --help — validates CLI bootsbun test — all generated tests passbun run build — compiles without errorsnpm install -g or bun linkInput — OpenAPI snippet:
paths:
/users:
get:
operationId: listUsers
summary: List all users
parameters:
- name: role
in: query
schema:
type: string
enum: [admin, user, guest]
- name: limit
in: query
schema:
type: integer
default: 20
- name: offset
in: query
schema:
type: integer
default: 0
post:
operationId: createUser
summary: Create a new user
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name, email]
properties:
name:
type: string
email:
type: string
format: email
role:
type: string
enum: [admin, user, guest]
default: user
/users/{id}:
get:
operationId: getUser
summary: Get user by ID
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
Output — src/commands/list.ts:
import { Command } from 'commander'
import { client } from '../lib/client'
import { formatOutput } from '../lib/format'
import type { User } from '../types'
export const listUsersCommand = new Command('list')
.description('List all users')
.option('--role <role>', 'Filter by role (admin, user, guest)')
.option('--limit <number>', 'Max results', '20')
.option('--offset <number>', 'Pagination offset', '0')
.action(async (opts) => {
const { data, error } = await client.GET('/users', {
params: {
query: {
role: opts.role,
limit: Number(opts.limit),
offset: Number(opts.offset),
},
},
})
if (error) {
console.error(`Error: ${error.message}`)
process.exit(1)
}
formatOutput<User[]>(data, {
columns: ['id', 'name', 'email', 'role'],
format: opts.format ?? 'table',
})
})
Every generated CLI includes src/lib/format.ts with three modes:
| Flag | Mode | Use case |
|---|---|---|
--format json | Structured | Piped to jq, scripts |
--format table | Human-readable | Terminal viewing |
--format tokens | Token-optimized | AI harness consumption |
--format tokens strips whitespace, deduplicates, and outputs only essential fields — minimizing context window consumption when a CLI is invoked by an AI agent.
/cli-generator validate ./my-cli
Checks:
commander (most mature) or citty (lighter, Bun-native)openapi-fetch wrapper (typed) or fetch with Zod validation--format tokens mode for AI harness consumption--format tokensUser: /cli-generator from-spec ./openapi.yaml
Claude:
✓ Parsed OpenAPI 3.1 — 12 endpoints, 5 schemas
Command tree:
users list [--role] [--limit] [--offset]
users get <id>
users create --name --email [--role]
users update <id> [--name] [--email] [--role]
users delete <id>
Confirm? (y/n)
User: y
Claude:
✓ Scaffolded project (8 files)
✓ Generated typed client
✓ Generated 5 command files
✓ Generated autocomplete (bash/zsh/fish)
✓ Generated man page
✓ Generated 12 tests
✓ Build passing
✓ CLI boots: my-cli --help
Done. Try:
cd my-cli && bun link && my-cli users list --format tokens
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub andersonlimahw/lemon-ai-hub --plugin cli-generator