scaffold-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScaffold CLI
Scaffold CLI
Scaffold a production-ready TypeScript CLI project (Node 22+) with ESM modules, dual-build (CLI + library), automated releases, and an agent skill definition.
搭建一个生产就绪的TypeScript CLI项目(要求Node 22+),包含ESM模块、双构建(CLI + 库)、自动化发布以及Agent技能定义。
Reference Files
参考文件
| File | Read When |
|---|---|
| Default: templates for package.json, tsconfig, tsdown, gitignore, license, changeset config, GitHub Actions |
| Default: templates for src/cli.ts, src/index.ts, src/types.ts, AGENTS.md, README.md, skills/SKILL.md |
| After generating files: post-scaffold commands and validation checklist |
| 文件 | 读取时机 |
|---|---|
| 默认:package.json、tsconfig、tsdown、gitignore、license、changeset配置、GitHub Actions的模板 |
| 默认:src/cli.ts、src/index.ts、src/types.ts、AGENTS.md、README.md、skills/SKILL.md的模板 |
| 生成文件后:搭建完成后的命令和验证清单 |
Scaffold Workflow
搭建流程
Copy this checklist to track progress:
text
Scaffold progress:
- [ ] Step 1: Gather project info
- [ ] Step 2: Create directory structure
- [ ] Step 3: Generate config files
- [ ] Step 4: Generate source files
- [ ] Step 5: Generate docs and skill
- [ ] Step 6: Run post-scaffold commands
- [ ] Step 7: Validate scaffold复制以下清单来跟踪进度:
text
Scaffold progress:
- [ ] Step 1: Gather project info
- [ ] Step 2: Create directory structure
- [ ] Step 3: Generate config files
- [ ] Step 4: Generate source files
- [ ] Step 5: Generate docs and skill
- [ ] Step 6: Run post-scaffold commands
- [ ] Step 7: Validate scaffoldStep 1: Gather project info
步骤1:收集项目信息
Collect from the user (ask only what was not provided):
| Variable | Example | Default | Used in |
|---|---|---|---|
| | — (required) | package.json name, README title |
| | — (required) | package.json, README, SKILL.md |
| | same as | package.json bin field, CLI examples |
| | — (required) | package.json repository, badges |
| | — (required) | package.json, LICENSE |
| | current year | LICENSE |
从用户处收集以下信息(仅询问未提供的内容):
| 变量 | 示例 | 默认值 | 使用位置 |
|---|---|---|---|
| | —(必填) | package.json名称、README标题 |
| | —(必填) | package.json、README、SKILL.md |
| | 与 | package.json的bin字段、CLI示例 |
| | —(必填) | package.json的仓库信息、徽章 |
| | —(必填) | package.json、LICENSE |
| | 当前年份 | LICENSE |
Step 2: Create directory structure
步骤2:创建目录结构
{{name}}/
.changeset/
.github/
workflows/
src/
skills/{{bin}}/{{name}}/
.changeset/
.github/
workflows/
src/
skills/{{bin}}/Step 3: Generate config files
步骤3:生成配置文件
Load . Generate all config files, replacing every with actual values.
references/scaffold-configs.md{{placeholder}}Files: , , , , , , , ,
package.jsontsconfig.jsontsdown.config.ts.gitignoreLICENSE.md.changeset/config.json.changeset/README.md.github/workflows/ci.yml.github/workflows/npm-publish.yml加载。生成所有配置文件,将所有替换为实际值。
references/scaffold-configs.md{{placeholder}}文件:、、、、、、、、
package.jsontsconfig.jsontsdown.config.ts.gitignoreLICENSE.md.changeset/config.json.changeset/README.md.github/workflows/ci.yml.github/workflows/npm-publish.ymlStep 4: Generate source files
步骤4:生成源代码文件
Load . Generate:
references/scaffold-source.md- — Commander entry point
src/cli.ts - — Public API exports
src/index.ts - — Shared type definitions
src/types.ts
加载。生成:
references/scaffold-source.md- — Commander入口文件
src/cli.ts - — 公开API导出文件
src/index.ts - — 共享类型定义文件
src/types.ts
Step 5: Generate docs and skill
步骤5:生成文档与Agent技能
Load . Generate:
references/scaffold-source.md- — Commands, architecture, gotchas
AGENTS.md - — Badges, features, install, usage, API, license
README.md - — Agent skill definition
skills/{{bin}}/SKILL.md
Then create symlink:
ln -s AGENTS.md CLAUDE.md加载。生成:
references/scaffold-source.md- — 命令、架构、注意事项
AGENTS.md - — 徽章、功能、安装、使用方法、API、许可证
README.md - — Agent技能定义
skills/{{bin}}/SKILL.md
然后创建符号链接:
ln -s AGENTS.md CLAUDE.mdStep 6: Run post-scaffold commands
步骤6:执行搭建完成后的命令
Load . Run the full command sequence in order.
references/post-scaffold.md加载。按顺序执行完整的命令序列。
references/post-scaffold.mdStep 7: Validate scaffold
步骤7:验证搭建结果
Load . Run all validation checks and confirm every item passes.
references/post-scaffold.md加载。运行所有验证检查并确认所有项均通过。
references/post-scaffold.mdPlaceholder Reference
占位符参考
All templates use syntax. Do a final sweep to catch any missed placeholders before writing files.
{{variable}}| Placeholder | Source |
|---|---|
| Project name (kebab-case) |
| One-line project description |
| CLI binary name |
| GitHub owner/repo |
| Author name |
| Current year |
所有模板使用语法。在写入文件前,需进行最终检查以确保没有遗漏任何占位符。
{{variable}}| 占位符 | 来源 |
|---|---|
| 项目名称(短横线命名法) |
| 一行项目描述 |
| CLI二进制文件名 |
| GitHub所有者/仓库名 |
| 作者姓名 |
| 当前年份 |
Dependencies
依赖项
Runtime:
, ,
@clack/promptscommandergray-matterDevelopment:
, , , , ,
@changesets/cli@types/nodetsdowntypescriptultracitevitestBuilt-in (no install needed):
styleText for colors (replaces chalk), spinner for progress (replaces ora)
node:util@clack/prompts运行时:
, ,
@clack/promptscommandergray-matter开发环境:
, , , , ,
@changesets/cli@types/nodetsdowntypescriptultracitevitest内置(无需安装):
的styleText用于颜色(替代chalk),的spinner用于进度显示(替代ora)
node:util@clack/promptsAnti-patterns
反模式
- Do not use CommonJS — all output must be ESM with
"type": "module" - Do not skip AGENTS.md or directory — every CLI project needs agent instructions
skills/ - Do not create test files in the scaffold — let the user add tests for their specific features
- Do not merge the dual tsdown builds — CLI (with shebang) and library (with dts) must stay separate
- Do not call oxlint or oxfmt directly — always use or
ultracite fixultracite check - Do not configure git hooks manually — ultracite sets up lefthook automatically
- Do not add chalk or ora — use styleText for colors and
node:utilspinner@clack/prompts
- 请勿使用CommonJS — 所有输出必须为ESM,且设置
"type": "module" - 请勿跳过AGENTS.md或目录 — 每个CLI项目都需要Agent相关说明
skills/ - 请勿在搭建过程中创建测试文件 — 让用户为其特定功能添加测试
- 请勿合并tsdown的双构建 — CLI(包含shebang)和库(包含dts)必须保持分离
- 请勿直接调用oxlint或oxfmt — 始终使用或
ultracite fixultracite check - 请勿手动配置git钩子 — ultracite会自动设置lefthook
- 请勿添加chalk或ora — 使用的styleText实现颜色,使用
node:util的spinner实现进度显示@clack/prompts