clack
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClack CLI Skill
Clack CLI Skill
Implement robust, user-friendly CLI flows with Clack.
使用Clack实现健壮、用户友好的CLI流程。
Follow This Workflow
遵循以下工作流程
- Identify the implementation target.
- Use for most interactive CLI flows.
@clack/prompts - Use for low-level/custom prompt rendering and lifecycle control.
@clack/core
- Load only the relevant references.
- Prompt-centric workflows:
references/prompts-api.md - Low-level/core extension work:
references/core-api.md - UX and reliability review:
references/best-practices.md - Pattern selection and scaffolding:
references/examples.md - Source links and freshness checks:
references/sources.md - If user asks for a starter file quickly, run .
scripts/scaffold-clack.sh
- Build a minimal runnable skeleton first.
- Include imports, , flow logic, and
intro().outro() - Add install/run commands for the user's runtime.
- Add prompts with explicit validation and cancellation paths.
- Validate every user-facing field that can fail constraints.
- Handle cancellation after each prompt result with and
isCancel(...).cancel(...)
- Add UX support functions intentionally.
- Use for structured feedback.
log.* - Use for long-running single operations.
spinner() - Use for summaries and next actions.
note()
- For asynchronous multi-step work, use task-oriented patterns.
- Prefer clear status updates and concise task titles.
- Keep success/error messages short and actionable.
- Finalize with a production-ready answer.
- Return complete runnable code (not fragments) unless user asks otherwise.
- Include quick verification steps.
- 明确实现目标。
- 大多数交互式CLI流程使用。
@clack/prompts - 底层/自定义提示渲染和生命周期控制使用。
@clack/core
- 仅加载相关参考资料。
- 以提示为中心的工作流:
references/prompts-api.md - 底层/核心扩展工作:
references/core-api.md - UX与可靠性评审:
references/best-practices.md - 模式选择与脚手架搭建:
references/examples.md - 源码链接与版本新鲜度检查:
references/sources.md - 如果用户需要快速获取启动文件,运行。
scripts/scaffold-clack.sh
- 先构建最小可运行骨架。
- 包含导入语句、、流程逻辑和
intro()。outro() - 添加适用于用户运行时的安装/运行命令。
- 添加带有显式验证和取消路径的提示。
- 对所有可能不符合约束的用户输入字段进行验证。
- 在每个提示结果后使用和
isCancel(...)处理取消操作。cancel(...)
- 有针对性地添加UX支持函数。
- 使用输出结构化反馈。
log.* - 针对长时间运行的单一操作使用。
spinner() - 使用显示总结信息和后续操作指引。
note()
- 对于异步多步骤任务,采用面向任务的模式。
- 优先使用清晰的状态更新和简洁的任务标题。
- 保持成功/错误消息简短且具备可操作性。
- 最终产出可用于生产环境的结果。
- 返回完整的可运行代码(而非代码片段),除非用户另有要求。
- 包含快速验证步骤。
Bundled Resources
内置资源
-
scripts/scaffold-clack.sh -
Generate a starter CLI from curated templates in JS or TS.
-
Usage:
bash scripts/scaffold-clack.sh <target-dir> [basic|spinner] [js|ts] [auto|npm|pnpm|yarn|bun] -
assets/templates/basic-cli.mjs -
Baseline prompt flow with validation, cancellation handling, and summary note.
-
assets/templates/spinner-cli.mjs -
Prompt flow plus spinner-driven execution pattern for longer operations.
-
assets/templates/basic-cli.ts -
TypeScript variant of the baseline prompt flow.
-
assets/templates/spinner-cli.ts -
TypeScript variant of the spinner flow.
-
scripts/scaffold-clack.sh -
从精心挑选的JS或TS模板生成启动CLI。
-
使用方法:
bash scripts/scaffold-clack.sh <target-dir> [basic|spinner] [js|ts] [auto|npm|pnpm|yarn|bun] -
assets/templates/basic-cli.mjs -
包含验证、取消处理和总结提示的基准提示流程。
-
assets/templates/spinner-cli.mjs -
提示流程加上适用于长时间操作的加载动画执行模式。
-
assets/templates/basic-cli.ts -
基准提示流程的TypeScript版本。
-
assets/templates/spinner-cli.ts -
加载动画流程的TypeScript版本。
Non-Negotiable Rules
不可违反的规则
- Always include a cancellation-safe path.
- Never assume valid input; validate and explain fixups in-place.
- Use consistent tone in status and error messages.
- Keep prompt trees shallow; split complex flows into grouped steps.
- Prefer sensible defaults to reduce user typing and errors.
- 始终包含支持取消的路径。
- 绝不假设输入有效;在原地验证并说明修正方法。
- 状态和错误消息使用一致的语气。
- 保持提示层级简洁;将复杂流程拆分为分组步骤。
- 优先使用合理的默认值以减少用户输入和错误。
Freshness Policy
版本新鲜度策略
- Treat Clack APIs as evolving.
- Use as the source-of-truth link map.
references/sources.md - If the user asks for the latest behavior or version-specific details, re-check the official docs before finalizing.
- If no web access is available, state that constraint explicitly and stick to documented APIs in this skill.
- 视Clack API为持续演进的状态。
- 将作为链接映射的权威来源。
references/sources.md - 如果用户询问最新行为或特定版本的细节,在最终答复前重新检查官方文档。
- 如果无法访问网络,需明确说明此限制,并严格遵循本技能中记录的API。