agentleFS
HM-IT-CODEHM-IT-CODE/forge-skills/skills/systems/rust-cli-scaffold/SKILL.md

rust-cli-scaffold

Skill0 starsChanged 6 months agoMITView on GitHub

Bootstraps a clean, idiomatic Rust command-line application. Use when the user says "new Rust CLI", "scaffold a Rust binary", "start a Rust command-line tool", or wants a Rust project set up with argument parsing, error handling, and tests. Produces a buildable project following current Rust conventions.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create a Rust CLI the way an experienced Rust engineer would start one: argument parsing with clap, ergonomic error handling, a testable …

    line 8
  2. Distinctive:

    Ask (or infer) the binary name, a one-line description, and the first subcommand or core operation.

    line 12
  3. Very specific:

    Add thiserror instead of / alongside anyhow if the tool is library-like and needs typed errors.

    line 23
  4. Very specific:

    Use #[derive(Parser)] with #[command(version, about)] so --help / --version work for free.

    line 54
  5. Very specific:

    Add #[derive(Debug)] to public types.

    line 56
  6. Distinctive:

    Read config from flags first, env second, defaults last.

    line 57
  7. Very specific:

    Add #[cfg(test)] unit tests for the pure logic functions (the easy wins).

    line 62
  8. Very specific:

    Add one integration test under tests/ using assert_cmd + predicates to exercise the built binary end-to-end.

    line 63
  9. Very specific:

    Run cargo build and cargo test and confirm both pass.

    line 68

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Rust CLI Scaffold

Create a Rust CLI the way an experienced Rust engineer would start one: argument parsing with clap, ergonomic error handling, a testable core separated from main, and CI ready to go.

Step 1 — Confirm the basics

Ask (or infer) the binary name, a one-line description, and the first subcommand or core operation. Keep the scaffold focused on one real command rather than empty boilerplate.

Step 2 — Create the project

cargo new <name> --bin
cd <name>
cargo add clap --features derive
cargo add anyhow

Add thiserror instead of / alongside anyhow if the tool is library-like and needs typed errors. Use anyhow for the binary's top level.

Step 3 — Lay out testable structure

Separate the CLI shell from the logic so the logic can be unit-tested without spawning a process:

src/
├── main.rs        # parse args, call run(), map errors to exit codes
├── cli.rs         # clap Parser/Subcommand definitions
└── lib logic...   # pure functions that do the actual work

main.rs stays thin:

use anyhow::Result;
use clap::Parser;

mod cli;

fn main() -> Result<()> {
    let args = cli::Cli::parse();
    cli::run(args)
}

cli.rs holds the #[derive(Parser)] struct, the Subcommand enum, and a run() that dispatches to pure functions. Those pure functions are what your tests target.

Step 4 — Apply conventions

  • Use #[derive(Parser)] with #[command(version, about)] so --help / --version work for free.
  • Return Result<T> and use ?; never unwrap()/expect() on recoverable errors in shipped paths.
  • Add #[derive(Debug)] to public types.
  • Read config from flags first, env second, defaults last.
  • Map errors to meaningful process exit codes in main if the tool is meant to be scripted.

Step 5 — Tests and CI

  • Add #[cfg(test)] unit tests for the pure logic functions (the easy wins).
  • Add one integration test under tests/ using assert_cmd + predicates to exercise the built binary end-to-end. Run cargo add --dev assert_cmd predicates.
  • Generate a cargo fmt --check + cargo clippy -D warnings + cargo test GitHub Actions workflow (hand off to the ci-pipeline skill if available).

Step 6 — Verify

Run cargo build and cargo test and confirm both pass. Show the user the tree, the --help output shape, and the next command to implement. Hand off to tdd-loop to build the real behavior test-first.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.