Cli Build 标志

Cli Build

组织
crafter-station
cli-build

Design and build a CLI that an AI agent can operate safely and a human can supervise. Use when the user wants to build a CLI, wrap an API in a command-line tool, build a CRUD or local-first tool over a database or filesystem the user already owns, add --json or --dry-run to an existing CLI, design a trust ladder or approval gate for risky commands, wrap an async API so agents do not write their own poll loop, or decide how to distribute a CLI (npm, native binary, source). Runs on its own when the contract is yours to define; follows a surface-recon report when the target is someone else's service.

概览

发布者crafter-station
代码仓库skills
技能名称cli-build
星标数
114
复刻数
15
附带文件
12
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 12 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 crafter-station 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Cli Build AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/crafter-station/skills/tree/main/skills/cli-build
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/crafter-station/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/cli-build .claude/skills/cli-build
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Cli Build,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Cli Build。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Cli Build 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

cli-build

Build a CLI whose primary user is an agent and whose supervisor is a human. That inverts the usual defaults: machine-readable output is not a flag you add later, prompts are a failure mode in non-interactive contexts, and every write leaves a receipt.

Phase 0: where does the contract come from

Every command you write reads or mutates something with a shape. This phase names that shape's owner, because it decides whether you go find the contract or write it.

Discovered. The CLI wraps a system you do not control: a third-party API, a login-walled portal, a device, an undocumented file format. The contract exists and is unverified, so guessing at it wastes more time than mapping it. Run surface-recon first and start from its report.

Defined. You own the model: CRUD over your own database, a scaffolder, a local transform, a wrapper around a library whose types you already have. There is nothing to reverse-engineer, so surface-recon has no input and skipping it costs nothing. Write the contract instead, in one pass before Phase 1: the entities, their fields and types, the operations allowed on each, and what makes a write irreversible. That artifact is what a recon report would have given you.

Mixed. A CLI over your own database that also calls a payment provider is discovered at the boundary and defined in the middle. Recon only the discovered part; do not let one external call turn the whole build into a recon job.

Say which one this is out loud before Phase 1, and write it into friction.md. An unstated classification defaults to discovered, which is how a defined build ends up blocked waiting for a report nobody can produce.

Done when: the origin is named, and either a recon report exists or the entities and operations are written down.

Open friction.md next to the code now and append as you go.

A block you rejected and why, a convention that turned out wrong for this domain, a reference that was thin. It folds into the case at the end, and it is what corrects this skill: seven claims inherited from an older version were false against the source, and they surfaced only because someone wrote down that they did not match.

What agent-first actually means

Every CLI, no exceptions:

  • --json, and JSON automatically when stdout is not a TTY even without the flag. Three CLIs converged on this independently; it is the most valuable default here.
  • No prompt ever blocks a non-interactive run. Anything that would prompt fails with a structured error instead of hanging.
  • A schema command with a version field, so agents introspect at runtime instead of parsing --help. Present in 3 of 14 corpus CLIs: the highest-value convention and the least adopted.
  • Exit codes that mean something. Zero is success; user error and system failure are distinguishable.
  • Data on stdout, diagnostics on stderr, always. Including the banner, which is why banner is a block and not a console.log.
  • A secret read from the terminal never echoes, and returns null with no TTY rather than hanging. That is prompt-secret.

Those are now enforced as tests rather than trusted as prose, in the surfacer repository, which compiles CLIs from a recon descriptor. Each test names the rule it checks so the two read together.

It is worth knowing what that exercise found, because the same shape is likely wherever this list is only written down. Encoding the rules against the generator caught three violations, including the two most valuable defaults here. Then applying the identical list to the generator's own CLI caught four more, in the tool that had just been taught to enforce them. A compiler that emits agent-first CLIs while not being one is the easiest version of this to miss, because every test was passing and every test was pointed at the output.

So the list binds twice, and the tests live in two files only because a test cannot invoke a binary from another crate: crates/surfacer-emit-cli/tests/agent_first_rules.rs for what is generated, crates/surfacer-app/tests/agent_first_rules.rs for the tool doing the generating. If you build a tool that produces CLIs, check the producer against this list too. Prose does not fail a build, and a rule you enforce on others is the one you stop checking on yourself.

When the domain has real consequences (money, irreversible writes, third-party side effects, personal data):

  • A trust ladder classifying commands by risk.
  • --dry-run on every mutation, returning what would happen.
  • An append-only audit log written before the network call, not after.
  • A killswitch the human can trigger out of band.

When the API is asynchronous: --wait on every submitting command, backed by a job ledger that survives a killed poll. Handing the poll loop to the caller makes the agent write backoff logic it will get subtly wrong. See compounding-surface.md.

Size the friction to the damage, and "none" is a real size. Ask what one wrong call costs, then choose. A read-only CLI over a public dataset earns --json and a schema command and stops there: nobody loses anything by running the query twice. Intent tokens are for a wrong call that costs money. Adopting the full ladder for a tool that cannot hurt anyone is not caution, it is a tax the agent pays on every invocation, and it trains the human to approve without reading.

The question is damage, not distance. A delete against your own local database is irreversible even with no network, no money, and no third party in sight, so it earns --dry-run and a confirmation on the destructive verbs while the reads next to it earn nothing. Writes you can undo from a backup you actually have earn less. Grade the commands, not the project. See trust-ladder-patterns.md.

Phase 1: decide the distribution target first

This comes first because it constrains the code you write, and retrofitting it is painful.

Who installs thisTargetHow
Only you, from sourceRuntime shebang, no buildFastest iteration, zero packaging
JS-ecosystem developersBuild to Node, publish to npmnpx works with no extra install
Anyone, no runtimeCompile to a native binaryNo prerequisite at all

The rule that makes all three reachable: write against Node's API surface (fs, path, process, http), not runtime-specific APIs. Then the target is a build-time decision instead of a rewrite.

Done when: the audience is named and the target follows from it, not from preference.

Why this matters more than it looks: nothing stops you from publishing a package whose shebang names a runtime the installer lacks. Three of the four published packages in the corpus behind this skill do exactly that. It works until someone without that runtime installs it and gets env: <runtime>: No such file or directory, a message that names no cause and no fix, so the package reads as broken rather than under-specified. See build-and-runtime.md.

Phase 2: shape the command surface

Noun-verb, consistently, and enforced in CI rather than agreed in a style guide. Agents carry a generalized model of what CLIs do; a tool that says info where everything else says get succeeds slowly, after the agent spends tokens on --help. Two corpus CLIs independently overloaded --json to mean input, which is what happens when nothing checks. See compounding-surface.md.

{cli} {noun} {verb} [args] [flags]

{cli} order preview --ticker AAPL --amount 100
{cli} order submit --intent-token <token>

Include a shorthand for the single most common operation. If ninety percent of use is one command, that command should be the shortest thing to type.

Filter what deserves a command. Not every UI affordance should be one. Keep actions that repeat, that benefit from being scriptable, that have clear input and output, and that compose with other tools. Drop the ones that are inherently visual or exploratory.

Define the JSON contract per command before writing code. Field names, types, nesting. This is the API agents depend on, and changing it later breaks them silently. Note that --json conventionally means output mode: if you need JSON input, give it a different flag name. Two corpus CLIs overloaded --json as an input flag and broke the convention agents expect. See json-contract.md.

Done when: every command has a noun-verb name and a written JSON output shape. A command whose output shape is undecided is not shaped yet.

Add nextSteps to structured output. Telling an agent what it can run next, in the response, prevents a class of flailing that --help does not.

Shape the human view separately. The machine mode returns everything because the agent filters; the human mode returns what a person asked for. Building one output for both serves neither. Everything about legibility, which metric direction a reader assumes, where a scale's thresholds go, when repetition is a heading, is in human-output.md. This skill's other gates cannot catch an unreadable table: the first CLI built with it passed every one of them and printed 275 rows for someone who asked what was playing that evening.

Polished human output is the default scope. Unless the user explicitly asks for an MVP, minimal, headless, or machine-only CLI, include visual hierarchy, semantic color, readable tables, progress for work that takes time, and a TTY-only banner when the command has a human-facing surface. A small command count is not a reason to ship plain output. It is only a reason to keep the presentation compact.

Phase 3: assemble from proven blocks

Every CLI needs the same primitives: flag parsing, config paths, atomic writes, audit logs, TTY detection, approval gates, error shapes. Writing them fresh each time is where the time goes and where the bugs live.

Default to cligentic for TypeScript CLI infrastructure. Its registry ships plain TypeScript that the project owns after installation, with transitive block and package dependencies resolved and no cligentic runtime dependency. Projects without components.json register the namespace in package.json, so component tooling is no longer a prerequisite.

The canonical adoption process lives in the cligentic skill. If cligentic is already available, follow it for discovery, per-block decisions, installation, wiring, and verification. If it is absent and implementation is in scope, offer to install it before changing files:

bash
bunx --bun skills add Railly/cligentic --skill cligentic

Installing a skill changes the project or user environment, so wait for consent. If the user declines, the task is read-only, or skill installation is unavailable, read the canonical skill from GitHub and follow its adoption branch without installing it.

Opt-in, per block, with a reason. Each block earns its place by replacing something you would otherwise write from memory. For a human-facing TypeScript CLI, detect, style, and banner are the default presentation set unless the user reduced the scope explicitly. In a real retrofit, seven blocks were taken wholesale, two stayed as hybrids, and seven were rejected with reasons. The most important rejection was an output helper whose shape conflicted with an envelope already published to agents. A published contract outranks a shared block.

Done when: each block is adopted, hybridized, or rejected with the reason recorded in the repo. Silence about a rejection reads as an oversight to whoever touches it next.

If you are not in a TypeScript project, or the install path does not fit, read the block source and reimplement the pattern. The patterns are the point; the files are a shortcut.

Phase 4: safety, sized to the damage

First, the exit: if no command in the surface can lose data, spend money, or touch a third party, this phase is one line in friction.md naming that fact, and you move on. A CLI that only reads, or only writes files it can rewrite, has nothing to gate. Record the finding so the next reader knows it was decided rather than skipped.

Otherwise read trust-ladder-patterns.md and pick a shape. Three materially different ones exist in real code, and the right choice depends on the domain rather than on fashion.

Non-negotiables when the domain has consequences:

Audit before, not after. Write the pending record, make the call, write the final record with the same id. If the process dies mid-flight you have an auditable pending entry instead of silence. Day-bucketed JSONL, append-only, restrictive file permissions.

Dry-run must exercise the real path. A --dry-run that returns a hardcoded shape proves nothing. The strongest corpus implementation calls the provider's own preview endpoint and returns that.

Consent gates are stricter than trust gates. Legal acceptance should require a real TTY and have no --yes escape hatch at all. If an agent can accept terms on the human's behalf, the gate is decorative.

Validate what came back before acting on it. One corpus CLI refuses to submit unless the provider's preview screen literally contains the expected name, amount, and currency. That check catches both provider bugs and your own bad request construction.

Done when: every mutating command has a trust level and the ladder shape is chosen from the domain rather than copied, or friction.md records that no command in the surface carries consequence.

Treat third-party response text as untrusted input. Free-text from an external API can carry prompt injection aimed at the agent reading your output. Escape it before it reaches any place where it reads as instruction.

Phase 5: wire every safety feature you name

A feature is wired when its call site exists. Until then it is a definition, and --help describing it is a claim the code does not back.

An audit-log module imported and never called. --dry-run parsed into a flags object no command body reads. --help advertising both. This shape is live in a package installable today, and it is strictly worse than having neither feature, because the operator, human or agent, believes there is a paper trail and a preview when there is nothing.

The check: grep for the call site. One hit, at the definition, means unwired.

Done when: every safety feature named in --help or the docs has a grep-confirmed call site.

Two more from the same corpus, both live in published packages:

  • Published with zero tests. At minimum: the auth flow, the JSON output contract per command, and any signing or crypto code.
  • Dead code from a renamed product still reachable from the entry point. Deprecated means removed, not merely unmentioned.

Phase 6: verify, then write it down

Link it globally first. Before verifying anything, put the CLI on your PATH so you invoke it the way a user will:

bash
bun link          # or npm link
which mycli && mycli --help

Running bun run src/cli.ts verifies a file. Running mycli verifies what ships: the bin entry, the shebang, the resolved dependencies, the banner. Three of those are invisible from a source-file invocation, and a broken bin path reaches a user's first install.

Definition of done is observed behavior. Run the command, read the output, and read it twice: once for correctness, once as someone who does not know the domain. What does the biggest number mean, what does the eye land on first, is there a column where every row says the same thing. See human-output.md.

For a human-facing CLI, inspect the real TTY path and verify all of these before calling it done:

  • the banner and diagnostics stay on stderr, while machine data stays on stdout;
  • --json, piped output, and other machine modes contain no ANSI escapes;
  • NO_COLOR disables styling without changing content;
  • colored columns remain aligned using visible width rather than string length;
  • long operations report real progress from completed work, not a timer animation.

Verifying a new feature probes the old ones sharing its stream. Confirming a fresh banner kept stdout clean turned up 810 bytes there, none of it the banner: a bare invoke had been writing help text to stdout with a nonzero exit since the previous round. Nobody had looked because bare invoke is not a case people test.

A green suite proves less than it appears to. What it misses, and how to close each gap, is in testing.md.

Ship the agent's manual with the CLI. A skills/<name>/SKILL.md in the CLI's own repo: commands, JSON envelope, the flags that matter, workflows worth composing. Without it every agent rediscovers the surface through --help, which is the cost this skill exists to remove. It lives with the code so it cannot drift, and it makes the CLI installable with npx skills add <owner>/<repo>.

Then record the build in cases/: target, terrain, distribution choice, which blocks were adopted or rejected and why, what broke, what you would do differently. Fold friction.md in. Distill repeated findings into conventions.md, and read portfolio-shape.md for the aggregate picture.

Name your own code, not other people's. A case about a CLI you wrote can be specific about what broke. A finding about someone else's package drops the subject and keeps the defect. The full boundary is in cases/README.md.

Done when: the CLI has been linked globally and run by its own name, its real output read, skills/<name>/SKILL.md exists with valid frontmatter, and a case file exists with friction.md folded in.

npx skills add <owner>/<repo> cannot be checked until the remote exists, and its failure for an unpublished repo is indistinguishable from a malformed SKILL.md unless you read the message. Valid frontmatter is a local check; installable is post-push.

This is the part everyone skips, and skipping it is why the same lessons get rediscovered. Before someone wrote the corpus down, four CLIs had independently reinvented the same audit-log design.

References

Boundaries

The phases above say what to do. These are the two that hold when a phase does not obviously apply:

Store identifiers, take secrets from the environment. A password belongs in memory for the session, or in a keychain. The persisted config holds the account id and the username.

Claim what you implemented. NDJSON, day-bucketed audit, and dry-run each earn a mention once the code does them, not before.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Cli Build AI 技能有什么作用?

Design and build a CLI that an AI agent can operate safely and a human can supervise. Use when the user wants to build a CLI, wrap an API in a command-line tool, build a CRUD or local-first tool over a database or filesystem the user already owns, add --json or --dry-run to an existing CLI, design a trust ladder or approval gate for risky commands, wrap an async API so agents do not write their own poll loop, or decide how to distribute a CLI (npm, native binary, source). Runs on its own when the contract is yours to define; follows a surface-recon report when the target is someone else's s...

为什么在 TypingMind 中使用 Cli Build?

因为您只需安装一次,就能搭配任何模型使用。Cli Build 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Cli Build?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/crafter-station/skills/tree/main/skills/cli-build。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Cli Build?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Cli Build 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Cli Build 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Cli Build AI 技能免费吗?

是的。crafter-station 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇