Command parsing
clap
Typed commands plus a mature terminal widget/rendering ecosystem.
Limits: Keep domain code separate from rendering and support non-TTY output; restore terminal on errors and interruption.
Portable command-line tools with explicit memory and resource control.
Clap · Ratatui when needed · Cargo
These recipes and dependency combinations need checking in your actual project before you rely on them.
Paste the guide address into your agent chat, together with what you want to build.
Use cases: Fast native developer tools; parsers and analyzers; shipped terminal applications.
Generator documentation reviewed: 2026-10-18. Evidence: documentation-reviewed; commands not executed.
Use when: A new Rust CLI needs a new directory.
Working directory: /path/to/workspace (existing local source parent)
Generate the executable package baseline.
cargo new project --binUse when: An existing source directory has no Cargo.toml and must become a package; choose this instead of cargo new.
Working directory: /path/to/workspace/project (existing directory without Cargo.toml)
Initialize a binary package in place.
cargo init --binUse when: Interactive terminal UI is selected at project creation; use this alternative to the plain Cargo starter, rather than overlaying a template onto an existing app.
Working directory: /path/to/workspace (existing local source parent)
Install the chosen template generator.
cargo install cargo-generate --version "${CARGO_GENERATE_VERSION:?Set the selected cargo-generate version}" --lockedWorking directory: /path/to/workspace (parent of the new app; Git available)
Choose and generate a maintained Ratatui template interactively.
cargo generate ratatui/templatesUse when: Only when dist is selected for shipping binaries and no equivalent release owner exists.
Working directory: /path/to/workspace/project (Rust toolchain installed)
Install the selected dist release from its cargo-dist package.
cargo install cargo-dist --version "${DIST_VERSION:?Set the selected dist package version}" --lockedWorking directory: /path/to/workspace/project (application package/workspace root)
Generate release settings and selected CI.
dist initUse when: Only when SQLx is selected and owns schema migrations; metadata applies when checked query macros are used.
Working directory: /path/to/workspace/project (matching sqlx-cli installed)
Create an editable migration file.
sqlx migrate add initialWorking directory: /path/to/workspace/project (DATABASE_URL targets a disposable database; migration SQL reviewed)
Apply migrations to the disposable database.
sqlx migrate runWorking directory: /path/to/workspace/project (checked query macros and matching disposable schema available)
Generate offline query metadata.
cargo sqlx prepareChoose the tools your application needs. The brief includes your selections, their purpose and their limits; the complete guide keeps all recommendations and sources.
clap
Typed commands plus a mature terminal widget/rendering ecosystem.
Limits: Keep domain code separate from rendering and support non-TTY output; restore terminal on errors and interruption.
Ratatui only for interactive screens
Typed commands plus a mature terminal widget/rendering ecosystem.
Limits: Keep domain code separate from rendering and support non-TTY output; restore terminal on errors and interruption.
reqwest
Reusable typed HTTP client APIs.
Limits: Choose blocking or async deliberately; configure timeouts, TLS and response bounds. Never call blocking client inside an async runtime indiscriminately.
None for stateless tools
Start without a database; add schema ownership only for persistent products.
Limits: SQLite feature/driver and migration setup require target testing; durable local state is not shared distributed workflow state.
Serde-backed settings + config
Typed settings plus structured events/spans.
Limits: Set precedence explicitly; validate semantics; install a tracing subscriber; never log secrets.
tracing + configured subscriber
Typed settings plus structured events/spans.
Limits: Set precedence explicitly; validate semantics; install a tracing subscriber; never log secrets.
cargo test; rustfmt; Clippy; cargo audit
Compiler, style, behavior and known-advisory checks complement each other.
Limits: Audit coverage is advisory-driven; compile success does not establish behavior or security. Test supported feature combinations rather than blindly enabling incompatible features.
assert_cmd
Tests real exit codes, stdout/stderr and command contracts.
Limits: Snapshot changes need review; also test actual error and side-effect behavior.
Delegate to a durable service; retain resumable job identity
CLI lifetime does not own remote work lifetime.
Limits: Checkpoint schema, atomic persistence and external idempotency must be designed; async execution alone adds no durability.
dist (formerly cargo-dist) + Cargo release builds
Generates multi-platform release pipelines and installers.
Limits: Review generated CI before tags can publish; test installers and target-native dependencies. Signing and notarization are separate platform work.
serde_json
Stable JSON output lets scripts consume commands without parsing terminal text
Limits: Add an explicit --json/output mode and document schema/exit codes; reserve stdout for results, stderr for diagnostics, and disable interactive/color output for pipelines.
Tokio signal handling for async commands
User interrupts should cancel outbound work and leave terminal/files usable
Limits: Propagate cancellation through work; bound cleanup time and test interrupts during writes. Avoid adding an async runtime to a synchronous Rust CLI solely for signals.
Build with the stack’s strengths
Recommendation: clap derives/parses a stable command interface, domain operations return Result, and the entry point converts errors to streams/status after cleanup. Serde owns a versioned machine format; Ratatui is an optional terminal client. Cargo/dist prepare artifacts for explicitly supported targets and update channels.
Version scope: Reviewed clap 4.6.7 and Rust std 1.99.0 documentation; Serde, Ratatui and current axodotdev cargo-dist book. Pin rust-toolchain.toml/Cargo.lock and dist version/config. The older opensource.axo.dev book path failed; no target install or release workflow was executed. · Reviewed 2026-10-11 · Evidence: documentation-reviewed · Source: inputs/research/migrations-systems.json
For an existing application
These are documented options and proposed checks. Inspect the actual source application before adopting a transition.
Record current commands, option defaults, exit codes, stdout/stderr, JSON field names and shell completions consumed by callers.
Recommendation: keep an old command adapter and explicit schema version while migrating parsing to clap. Preserve old names/aliases and map new domain errors into the established protocol.
Recommendation: clap plus typed result/error JSON and main ExitCode mapping. clap usage failures use status 2 while help/version uses success; application failures need their own documented policy.
Recommendation: return consumers to the previous binary/schema while retaining old option adapters. Keep version selection explicit so a rollback does not silently alter JSON meaning.
Typed parsing and a stable output envelope make command automation explicit.
Requires: Contract fixtures cover old callers; result schemas and error/status mapping are versioned; help/completion behavior is checked.
Tradeoffs: Parser defaults can change compatibility; numeric status meanings are not universal across platforms; Rust error types do not define the public protocol.
Inventory configuration file locations, schema versions, defaults, permissions and old binaries' ability to read newer files.
Recommendation: read old config into a versioned internal model and migrate only through an explicit command with backup. Keep concurrent writer ownership explicit; read-only startup must not silently rewrite files.
Recommendation: Serde-tagged/versioned configuration and documented unknown-field handling. Validate a temporary representation before replacing the live file; platform atomicity, permissions and crash behavior require implementation checks.
Recommendation: restore the preserved old config and binary as a pair. Reconcile new-only fields before using an old reader; avoid destructive in-place downgrade guesses.
Explicit config migration decouples executable upgrades from accidental data loss.
Requires: Old/new fixtures and semantic transforms exist; backup/restore works; unsupported versions fail before write.
Tradeoffs: Strict Serde unknown-field rejection can prevent mixed-version use; deny_unknown_fields does not compose with flatten; replacing a file is not a complete durability protocol.
Preserve ordering, per-item effects, timeout and interrupt semantics for batch/network subcommands.
Recommendation: retain sequential mode while qualifying bounded parallel work using dry-run/fixtures. Store item operation IDs and completion receipts before enabling resume against live systems.
Recommendation: a bounded executor selected for CPU or async I/O with cooperative stop, tracked joins and cleanup. Started blocking work needs its own stop protocol or process boundary; do not label a task timeout as effect cancellation.
Recommendation: use sequential mode with the same receipt format and reconcile unknown outcomes. A previous executable must be able to read checkpoint versions or an explicit converter is required.
Bounded parallel execution can overlap independent work without unlimited task creation.
Requires: Independent item semantics; capacity/budget limits; stable effect IDs; tested cancellation and resume contract.
Tradeoffs: Speed is unmeasured; running blocking tasks may continue; a cancelled remote write can have an ambiguous outcome.
Capture existing target triples, libc/native dependencies, install path, package metadata and update/downgrade contracts.
Recommendation: prepare dist artifacts beside the previous release; review generated CI and installers, and use a prerelease or test channel for target qualification. Do not promise all platforms merely because dist generates a matrix.
Recommendation: pinned dist configuration and Cargo.lock with release artifacts/installers for exercised targets. Keep signing/attestation, system dependency baselines and update channel ownership explicit.
Recommendation: restore the previous verified package/update channel and retain older installers/checksums. Review data/config compatibility before allowing downgrade; never change a public channel based only on a plan.
Generated release plans coordinate binary artifacts and installers across targets.
Requires: dist version is pinned; generated workflow is reviewed; native dependencies and every advertised target are exercised.
Tradeoffs: dist init may replace generated workflows; OS signing and Linux libc compatibility remain separate obligations; a plan is not build/publication evidence.
Run these in the configured application. They are instructions, not recorded passes.
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked
cargo audit
cargo build --release --lockedOriginal source review: 2026-10-10. Core guidance rechecked: 2026-10-13. Check scope.