AGENT SKILL

cli-scaffold-compiled

Generate a production-grade CLI scaffold in a compiled language — Rust, Go, or .NET. Use when the user requests a CLI in one of those three languages. Not the entry point — scaffold-cli resolves the language and dispatches here; a raw request such as "scaffold a new command-line tool in Rust" should go to scaffold-cli first. Produces a lib+binary split where the core library has zero CLI-framework imports, packaging metadata for the language's idiomatic channel, and a snapshot test for --help. Loads the cli-architecture doctrine first, generates freeform from the per-language reference, then hands the scaffold to the cli-scaffold-verifier before presenting; fixes any fixable gaps and re-verifies.

License 许可
MIT
所属仓库
Anselmoo/werkstoff
最近更新
2026-11-02
Stars
★ 1
Forks
0

01 前言 Front Matter

name
cli-scaffold-compiled
description
Generate a production-grade CLI scaffold in a compiled language — Rust, Go, or .NET. Use when the user requests a CLI in one of those three languages. Not the entry point — scaffold-cli resolves the language and dispatches here; a raw request such as "scaffold a new command-line tool in Rust" should go to scaffold-cli first. Produces a lib+binary split where the core library has zero CLI-framework imports, packaging metadata for the language's idiomatic channel, and a snapshot test for --help. Loads the cli-architecture doctrine first, generates freeform from the per-language reference, then hands the scaffold to the cli-scaffold-verifier before presenting; fixes any fixable gaps and re-verifies.

02 资源文件 3

03 SKILL.md 正文

Compiled CLI scaffold (Rust / Go / .NET)

You generate a CLI in Rust, Go, or .NET. All rules come from the cli-architecture doctrine — load it first and follow it; this skill does not restate it.

Precondition — invoked via scaffold-cli

This skill assumes scaffold-cli has already resolved the language and dispatched here with paradigm: compiled (Rust, Go, or .NET). If invoked directly and no resolved language was handed off, do not resolve it yourself — stop and tell the user to invoke scaffold-cli instead. If you must confirm ambiguity, you may re-run python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/lang_router.py" "<language-as-given>", but only continue if its JSON paradigm is compiled; on AMBIGUOUS:, UNSUPPORTED:, or any other paradigm, refuse and name scaffold-cli as the correct entry point — mirroring scaffold-cli's own AMBIGUOUS/UNSUPPORTED handling rather than scaffolding anyway.

Step 1 — Load doctrine

Load the cli-architecture skill. Do not generate anything before it is loaded.

Step 2 — Read the per-language reference

Read the reference for the resolved language (each maps 1:1 onto the five pillars):

  • Rust → ${CLAUDE_PLUGIN_ROOT}/skills/cli-scaffold-compiled/references/rust.md
  • Go → ${CLAUDE_PLUGIN_ROOT}/skills/cli-scaffold-compiled/references/go.md
  • .NET → ${CLAUDE_PLUGIN_ROOT}/skills/cli-scaffold-compiled/references/dotnet.md

Step 3 — Resolve the write target (in code)

python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/write_scope.py" "<app-name>"

Write the scaffold only under the path it prints. If it exits non-zero, stop and ask for a valid app name — never write outside the declared output scope.

Step 4 — Generate the scaffold freeform

Following the reference idioms (not stored boilerplate), generate:

  • the lib + binary split: a core library file with zero CLI-framework imports, and a thin binary entry point that only parses, dispatches into the core, formats output, and maps the frozen exit codes;
  • packaging metadata for the one idiomatic channel named in the reference;
  • a snapshot test for --help;
  • the discoverability, NO_COLOR, --json, --no-input, and stdout/stderr behavior the doctrine requires;
  • a root cli-scaffold.manifest.json declaring the file roles (see the doctrine for the schema) — the verifier reads this.

Identical requests must converge on the same structure.

Step 5 — Verify before presenting (mandatory)

Hand the scaffold to the cli-scaffold-verifier agent for a read-only check against the doctrine and reference. The verifier runs:

python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/verify_scaffold.py" "<scaffold-dir>" "<language>"
  • Exit 0 (verdict pass) → present the scaffold.
  • Exit 1 (verdict gaps) → read the JSON report path it prints. For each finding with disposition: fixable, fix it and re-run the verifier. Only findings marked disposition: needs-human-judgment are surfaced to the user unmodified. The verifier bounds the loop itself: after MAX_FIX_ITERATIONS it HALTs — if that happens, surface the remaining findings to the user instead of looping.

A report with both kinds of finding looks like this:

{
  "verdict": "gaps",
  "findings": [
    {
      "disposition": "fixable",
      "rule": "snapshot-test-missing",
      "detail": "No snapshot test found for `--help` output."
    },
    {
      "disposition": "needs-human-judgment",
      "rule": "packaging-channel-ambiguous",
      "detail": "Both a workspace Cargo.toml and a standalone one are plausible; pick one."
    }
  ]
}

Never present a scaffold that still has fixable findings.

Step 6 — Render the architecture tree

Once verification passes, render the scaffold's real file tree, each file tagged with which five-pillar role it plays — derived from the same cli-scaffold.manifest.json keys the verifier just read, not re-invented:

python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/build_architecture_tree.py" "<scaffold-dir>" \
    --template "${CLAUDE_PLUGIN_ROOT}/assets/architecture-tree-viewer.html" \
    --d3 "${CLAUDE_PLUGIN_ROOT}/assets/inline-d3.html" \
    --tokens "${CLAUDE_PLUGIN_ROOT}/assets/tokens.css"

Writes <scaffold-dir>/ARCHITECTURE.html — inside the scaffold itself, since here the output IS the deliverable, not a report about existing code. Mention this path when presenting the scaffold.

04 同仓库更多 Skills