system-create-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

system-create-cli

system-create-cli

Automated CLI Generation System
Generate production-ready TypeScript CLIs with comprehensive documentation, type safety, error handling, and PAI's CLI-First Architecture principles.

自动CLI生成系统
生成遵循PAI的CLI优先架构原则,具备全面文档、类型安全、错误处理机制的生产级TypeScript CLI。

WORKFLOW ROUTING (SYSTEM PROMPT)

工作流路由(系统提示)

When user requests CLI creation, follow this routing:
当用户请求创建CLI时,请遵循以下路由规则:

Primary Workflow: Create New CLI

主工作流:创建新CLI

Triggers: "create CLI", "build command-line tool", "make CLI for X", "generate CLI" Route to:
workflows/create-cli.md
Action: Generate complete CLI from requirements
触发条件:"create CLI"、"build command-line tool"、"make CLI for X"、"generate CLI" 路由至
workflows/create-cli.md
操作:根据需求生成完整的CLI

Extension Workflow: Add Command

扩展工作流:添加命令

Triggers: "add command to CLI", "extend CLI with", "add feature to existing CLI" Route to:
workflows/add-command.md
Action: Add new command to existing CLI
触发条件:"add command to CLI"、"extend CLI with"、"add feature to existing CLI" 路由至
workflows/add-command.md
操作:为现有CLI添加新命令

Migration Workflow: Upgrade Complexity Tier

迁移工作流:升级复杂度层级

Triggers: "upgrade CLI", "migrate to Commander", "CLI needs more complexity" Route to:
workflows/upgrade-tier.md
Action: Migrate Tier 1 → Tier 2 (manual → Commander.js)
触发条件:"upgrade CLI"、"migrate to Commander"、"CLI needs more complexity" 路由至
workflows/upgrade-tier.md
操作:从层级1迁移至层级2(手动实现 → Commander.js)

Testing Workflow: Add Test Suite

测试工作流:添加测试套件

Triggers: "add tests to CLI", "test scaffolding", "need CLI tests" Route to:
workflows/add-testing.md
Action: Generate comprehensive test suite
触发条件:"add tests to CLI"、"test scaffolding"、"need CLI tests" 路由至
workflows/add-testing.md
操作:生成全面的测试套件

Distribution Workflow: Setup Publishing

分发工作流:设置发布配置

Triggers: "publish CLI", "distribute CLI", "make standalone binary" Route to:
workflows/setup-distribution.md
Action: Configure npm publishing or binary distribution

触发条件:"publish CLI"、"distribute CLI"、"make standalone binary" 路由至
workflows/setup-distribution.md
操作:配置npm发布或二进制分发

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"
  • "为[API/服务/工具]创建CLI"
  • "为X构建命令行界面"
  • "制作一个能实现Y功能的CLI"
  • "生成TypeScript CLI"
  • "我需要一个用于Z的CLI工具"

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
  • 用户描述重复的API调用 → 建议使用CLI
  • 用户提到"我一直在输入这个命令" → 建议使用CLI封装器
  • 用户有执行复杂任务的bash脚本 → 建议替换为TypeScript CLI
  • 用户使用的API没有官方CLI → 建议创建一个

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"

  • ✅ "为GitHub API创建CLI"
  • ✅ "构建一个处理CSV文件的命令行工具"
  • ✅ "为我的数据库迁移制作CLI"
  • ✅ "生成一个封装此API的CLI"
  • ✅ "我需要一个类似llcli但适用于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)
READ:
references/tier-comparison.md
for detailed framework comparison, performance metrics, and migration paths
层级1:llcli风格(默认 - 80%的使用场景)
  • 手动参数解析(process.argv)
  • 无框架依赖
  • Bun + TypeScript
  • 类型安全接口
  • 总代码量约300-400行
  • 适用场景:API客户端、数据转换器、简单自动化任务
何时使用层级1
  • ✅ 2-10个命令
  • ✅ 简单参数(标志、值)
  • ✅ JSON输出
  • ✅ 无子命令
  • ✅ 快速开发
层级2:Commander.js(进阶 - 15%的使用场景)
  • 基于框架的参数解析
  • 子命令 + 嵌套选项
  • 自动生成帮助信息
  • 支持插件
  • 适用场景:复杂多命令工具
何时使用层级2
  • ❌ 需要分组的10个以上命令
  • ❌ 复杂嵌套选项
  • ❌ 插件架构
  • ❌ 多种输出格式
层级3:oclif(仅参考 - 5%的使用场景)
  • 仅提供文档(无模板)
  • 企业级插件系统
  • 适用场景:Heroku CLI、Salesforce CLI等规模的工具(罕见)
阅读
references/tier-comparison.md
获取详细的框架对比、性能指标及迁移路径

What Every Generated CLI Includes

每个生成的CLI包含的内容

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

1. 完整实现
  • 具备完整类型安全的TypeScript源码
  • 所有命令功能可用且经过测试
  • 带有正确退出码的错误处理机制
  • 配置管理
2. 全面文档
  • 包含理念、用法、示例的README.md
  • 针对常见模式的QUICKSTART.md
  • 内置帮助文本(--help)
  • API响应文档
3. 开发环境设置
  • package.json(Bun配置)
  • tsconfig.json(严格模式)
  • .env.example(配置模板)
  • 文件权限已配置
4. 质量标准
  • 全程类型安全
  • 确定性输出(JSON)
  • 可组合(可通过管道传递给jq、grep)
  • 带上下文的错误信息
  • 符合退出码规范

INTEGRATION WITH QARA

与QARA的集成

Technology Stack Alignment

技术栈对齐

Generated CLIs follow PAI's 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)
生成的CLI遵循PAI的标准:
  • 运行时:Bun(非Node.js)
  • 语言:TypeScript(非JavaScript或Python)
  • 包管理器:Bun(非npm/yarn/pnpm)
  • 测试:Vitest(添加测试时使用)
  • 输出:确定性JSON(可组合)
  • 文档:README + QUICKSTART(llcli模式)

Repository Placement

仓库位置

Generated CLIs go to:
  • ${PAI_DIR}/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将存放在:
  • ${PAI_DIR}/bin/[cli-name]/
    - 个人CLI(如llcli)
  • ~/Projects/[project-name]/
    - 项目专属CLI
  • ~/Projects/PAI/examples/clis/
    - 示例CLI(公开仓库)
安全提示:执行git操作前务必验证仓库位置

CLI-First Architecture Principles

CLI优先架构原则

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

每个生成的CLI都遵循以下原则:
  1. 确定性 - 相同输入 → 相同输出
  2. 简洁 - 单一职责
  3. 可组合 - JSON输出可传递给其他工具
  4. 文档完善 - 全面的帮助信息和示例
  5. 可测试 - 可预测的行为

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
  • workflows/create-cli.md
    - 主CLI生成工作流(决策树,10步流程)
  • workflows/add-command.md
    - 为现有CLI添加命令
  • workflows/upgrade-tier.md
    - 从简单到复杂的迁移
  • workflows/add-testing.md
    - 测试套件生成
  • workflows/setup-distribution.md
    - 发布配置

Reference Documentation

参考文档

READ:
references/tier-comparison.md
for comprehensive framework comparison including:
  • Detailed feature comparison (Tier 1 vs 2 vs 3)
  • Performance metrics (startup time, memory usage)
  • Migration paths between tiers
  • Decision algorithm for tier selection
  • Real-world examples and recommendations
READ:
references/cli-examples.md
for 6 complete examples covering:
  • API clients (GitHub, Notion)
  • File processors (markdown, CSV)
  • Data pipelines (complex workflows)
  • Database operations (PostgreSQL)
  • Common patterns and testing approaches
  • Documentation templates

阅读
references/tier-comparison.md
获取全面的框架对比,包括:
  • 详细功能对比(层级1 vs 2 vs 3)
  • 性能指标(启动时间、内存占用)
  • 跨层级迁移路径
  • 层级选择决策算法
  • 真实案例及推荐方案
阅读
references/cli-examples.md
获取6个完整示例,涵盖:
  • API客户端(GitHub、Notion)
  • 文件处理器(markdown、CSV)
  • 数据管道(复杂工作流)
  • 数据库操作(PostgreSQL)
  • 常见模式及测试方法
  • 文档模板

PHILOSOPHY

设计理念

Why This Skill Exists

此技能的存在意义

User repeatedly creates 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.
用户反复为API和工具创建CLI,每次的流程都是:
  1. 从bash脚本开始
  2. 意识到需要错误处理
  3. 意识到需要帮助文本
  4. 意识到需要类型安全
  5. 用TypeScript重写
  6. 添加文档
  7. 得到生产级CLI
此技能将步骤1-7自动化。

The llcli Pattern

llcli模式

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.
llcli
CLI(Limitless.ai API)证明了此模式的有效性:
  • 327行TypeScript代码
  • 无依赖(无框架)
  • 完整的错误处理
  • 全面的文档
  • 可立即投入生产使用
此技能复制了这一成功模式。

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

  1. 从简开始 - 默认使用层级1(llcli风格)
  2. 按需进阶 - 仅在必要时使用层级2
  3. 完整交付,而非脚手架 - 每个CLI都可直接投入生产
  4. 文档优先 - README解释“为什么”而非仅“怎么做”
  5. 类型安全 - 始终启用TypeScript严格模式

QUALITY STANDARDS

质量标准

Every generated CLI must pass these gates:
每个生成的CLI必须通过以下检查:

1. Compilation

1. 编译

  • ✅ TypeScript compiles with zero errors
  • ✅ Strict mode enabled
  • ✅ No
    any
    types except justified
  • ✅ TypeScript编译无错误
  • ✅ 启用严格模式
  • ✅ 除非合理,否则不使用
    any
    类型

2. Functionality

2. 功能

  • ✅ All commands work as specified
  • ✅ Error handling comprehensive
  • ✅ Exit codes correct (0 success, 1 error)
  • ✅ 所有命令按指定要求工作
  • ✅ 错误处理全面
  • ✅ 退出码正确(0表示成功,1表示错误)

3. Documentation

3. 文档

  • ✅ README explains philosophy and usage
  • ✅ QUICKSTART has common examples
  • ✅ --help text comprehensive
  • ✅ All flags/options documented
  • ✅ README解释设计理念和使用方法
  • ✅ QUICKSTART包含常见示例
  • ✅ --help文本全面
  • ✅ 所有标志/选项都有文档说明

4. Code Quality

4. 代码质量

  • ✅ Type-safe throughout
  • ✅ Clean function separation
  • ✅ Error messages actionable
  • ✅ Configuration externalized
  • ✅ 全程类型安全
  • ✅ 函数划分清晰
  • ✅ 错误信息可操作
  • ✅ 配置外部化

5. Integration

5. 集成

  • ✅ Follows PAI tech stack (Bun, TypeScript)
  • ✅ CLI-First Architecture principles
  • ✅ Deterministic output (JSON)
  • ✅ Composable with other tools

  • ✅ 遵循PAI技术栈(Bun、TypeScript)
  • ✅ 符合CLI优先架构原则
  • ✅ 输出确定性JSON
  • ✅ 可与其他工具组合使用

RELATED SKILLS

相关技能

  • development - For complex feature development (not CLI-specific)
  • personal-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 PAI's CLI-First Architecture.
Total lines: 205 (was 353)
  • development - 用于复杂功能开发(非CLI专属)
  • personal-lifelog - 使用llcli的技能示例

此技能可将“我需要一个用于X的CLI”在几分钟内转化为符合llcli模式和PAI的CLI优先架构的生产级工具。
总行数:205(原353)