← 提示词库 Anthropic/claude-code/skills/run-skill-generator/examples/cli.md 原文 md
🌐 中英双语对照

Example: CLI tool / 示例:CLI 工具

CLIs are the simplest case - there's usually no background process to
manage, no ports, no lifecycle. The skill focuses on installation,
representative invocations, and testing.

CLI 是最简单的情况——通常没有需要管理的后台进程、没有端口、没有生命周期。该技能关注的重点是安装、代表性调用和测试。

What matters / 重点关注

Example snippet / 示例片段


name: run-mytool
description: Build, install, and run mytool. Use when asked to run mytool, test it, or verify it's installed correctly.
description:构建、安装并运行 mytool。当被要求运行 mytool、测试它或验证其已正确安装时使用。

Setup / 环境搭建

pip install -e .

This puts mytool on PATH. Verify:
这会把 mytool 放到 PATH 上。验证方式:

mytool --version
# -> mytool 0.3.1

Run / 运行

Process a single file:
处理单个文件:

mytool process input.json
# -> Processed 42 records, wrote output.json

Read from stdin, write to stdout:
从 stdin 读取,写入 stdout:

cat input.json | mytool process -

Lint a directory (exits non-zero on problems):
对目录执行 lint(发现问题时以非零值退出):

mytool lint ./src
echo $?  # 0 if clean, 1 if issues found

Test / 测试

pytest

Keep it short / 保持精简

A CLI's run skill can be very compact. Don't pad it with every flag -
the --help output covers that. Just show enough that an agent can
(a) build it, (b) confirm it works, (c) run the tests.

CLI 的 run 技能可以写得很紧凑。不要把每一个旗标都塞进去——--help 的输出已经覆盖了这些内容。只要展示出足够的信息,让智能体能够(a)构建它、(b)确认它能正常工作、(c)运行测试即可。