Archetype: CLI / service tool
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#
| Standard | How it applies here |
|---|---|
| Versioning | Derived MAJOR.MINOR.<count> via build.rs; wired into clap #[command(version = env!("APP_VERSION"))]. |
| Build info | libbuildinfo recommended — a --version/version subcommand that prints commit hash + dirty flag is invaluable for a distributed binary. |
| Identifiers | dev.thmsn.<product>.cli (or .worker, etc.) via libproduct. |
| Registry publishing | The defining standard — published as registry kind = cli; see below. |
| CI/CD | cli.release.yml builds per-target artifacts on self-hosted runners and publishes. |
| Testing | Test command/arg logic and parsing; completions generation. |
| Workflow | Commit to main. |
| Configuration | libconfig (Loader / config!{}); defaults→TOML→shared→prefixed. |
| Error handling | thiserror/liberror trinity; map to a clean exit code/message. |
| Rust conventions | Edition 2024, clippy pedantic, git deps. |
lib* ecosystem | Reuse libsignal (shutdown), libcmd/libwhich, etc. |
| READMEs | Root README.md leads with the registry install one-liner (re-running it upgrades), then a subcommand tour and config/completions. |
| Shortcuts | Root SHORTCUTS.md holds the routes to the install manifest and the latest published version. |
| Service architecture | N/A (a CLI is not a hosted service). |
| Data & persistence | N/A (a CLI is not a hosted service). |
| Contracts | N/A (a CLI is not a hosted service). |
| Auth integration | N/A (a CLI is not a hosted service). |
| Web & client arch | N/A (a CLI is not a hosted service). |
| Branding | N/A (a CLI ships via the registry, not a deploy). |
| Deployment | N/A (a CLI ships via the registry, not a deploy). |
| Platform UX | N/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.rsderives the version;--versionreports it (plus commit hash vialibbuildinfo).product_name!("dev.thmsn.<product>.<tool>")declared and published withset_global()at the top ofmain(../identifiers.md).- Release workflow builds per-target artifacts on self-hosted runners.
- Published to the registry as
kind = cliwith a complete install manifest. - Shell completions shipped or generated by a subcommand.
- Command/parsing logic tested.
- Root
README.mdleads with the registry install one-liner (and that re-running it upgrades), then a subcommand tour and config/completions (../readmes.md).