Standards

Archetype: CLI / service tool

On this page
  1. Repo shape
  2. Standards that apply
  3. Registry distribution
  4. Checklist

A standalone binary distributed to machines (not a hosted service with clients). It may be its own repo or a bin/ member inside a product monorepo. The distinguishing feature is distribution through the registry with an install manifest.

Reference: a someproduct CLI and a worker (a background companion service).

Repo shape#

<tool>/  (or bin/<tool>/ inside a product)
├── Cargo.toml
├── build.rs                version derivation (+ optional libbuildinfo emit)
├── src/main.rs             clap entrypoint; product_name!("dev.thmsn.<product>.cli")
├── completions/            shipped shell completions (or generated by a subcommand)
├── .github/workflows/      cli.release.yml → publish to registry (see ci-cd.md naming)
├── .standards.conf         PRODUCT / ARCHETYPE identity (or the parent monorepo's)
└── AGENTS.md               Standards: line (archetype, product) + repo overrides

Standards that apply#

StandardHow it applies here
VersioningDerived MAJOR.MINOR.<count> via build.rs; wired into clap #[command(version = env!("APP_VERSION"))].
Build infolibbuildinfo recommended — a --version/version subcommand that prints commit hash + dirty flag is invaluable for a distributed binary.
Identifiersdev.thmsn.<product>.cli (or .worker, etc.) via libproduct.
Registry publishingThe defining standard — published as registry kind = cli; see below.
CI/CDcli.release.yml builds per-target artifacts on self-hosted runners and publishes.
TestingTest command/arg logic and parsing; completions generation.
WorkflowCommit to main.
Configurationlibconfig (Loader / config!{}); defaults→TOML→shared→prefixed.
Error handlingthiserror/liberror trinity; map to a clean exit code/message.
Rust conventionsEdition 2024, clippy pedantic, git deps.
lib* ecosystemReuse libsignal (shutdown), libcmd/libwhich, etc.
READMEsRoot README.md leads with the registry install one-liner (re-running it upgrades), then a subcommand tour and config/completions.
ShortcutsRoot SHORTCUTS.md holds the routes to the install manifest and the latest published version.
Service architectureN/A (a CLI is not a hosted service).
Data & persistenceN/A (a CLI is not a hosted service).
ContractsN/A (a CLI is not a hosted service).
Auth integrationN/A (a CLI is not a hosted service).
Web & client archN/A (a CLI is not a hosted service).
BrandingN/A (a CLI ships via the registry, not a deploy).
DeploymentN/A (a CLI ships via the registry, not a deploy).
Platform UXN/A (a CLI ships via the registry, not a deploy).

Registry distribution#

Published with kind = cli, which supports multi-target artifacts (one per os/arch/libc) under a single version, plus an install manifest describing how to set it up on a machine:

{
  "bin_name": "<tool>",
  "version_command": ["<tool>", "--version"],
  "symlinks": { "<alias>": "<tool>" },
  "man": ["man/<tool>.1"],
  "completions": {
    "bash": { "generate": ["<tool>", "completions", "bash"] },
    "zsh":  { "generate": ["<tool>", "completions", "zsh"] },
    "fish": { "bundled": "completions/<tool>.fish" }
  }
}

Install is via the registry's platform-detecting installer (GET /install/<slug> for Unix, …/install/<slug>.ps1 for Windows), which selects the right artifact, verifies the SHA-256, and applies the manifest. Publish per release with charliethomson/registry/.github/actions/publish@main (or scripts/registry-publish.sh). See registry-publishing.md.

Checklist#

  • build.rs derives the version; --version reports it (plus commit hash via libbuildinfo).
  • product_name!("dev.thmsn.<product>.<tool>") declared and published with set_global() at the top of main (../identifiers.md).
  • Release workflow builds per-target artifacts on self-hosted runners.
  • Published to the registry as kind = cli with a complete install manifest.
  • Shell completions shipped or generated by a subcommand.
  • Command/parsing logic tested.
  • Root README.md leads with the registry install one-liner (and that re-running it upgrades), then a subcommand tour and config/completions (../readmes.md).