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.
In this repository5 other files it gives its agents.
- ci-pipelineSkill
- dockerizeSkill
- pr-readySkill
- tdd-loopSkill
- vertical-sliceSkill
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
- Very specific: line 8
Create a Rust CLI the way an experienced Rust engineer would start one: argument parsing with clap, ergonomic error handling, a testable …
- Distinctive: line 12
Ask (or infer) the binary name, a one-line description, and the first subcommand or core operation.
- Very specific: line 23
Add thiserror instead of / alongside anyhow if the tool is library-like and needs typed errors.
- Very specific: line 54
Use #[derive(Parser)] with #[command(version, about)] so --help / --version work for free.
- Very specific: line 56
Add #[derive(Debug)] to public types.
- Distinctive: line 57
Read config from flags first, env second, defaults last.
- Very specific: line 62
Add #[cfg(test)] unit tests for the pure logic functions (the easy wins).
- Very specific: line 63
Add one integration test under tests/ using assert_cmd + predicates to exercise the built binary end-to-end.
- Very specific: line 68
Run cargo build and cargo test and confirm both pass.
≈ “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.
Files
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 anyhowAdd 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 workmain.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/--versionwork for free. - Return
Result<T>and use?; neverunwrap()/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
mainif 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/usingassert_cmd+predicatesto exercise the built binary end-to-end. Runcargo add --dev assert_cmd predicates. - Generate a
cargo fmt --check+cargo clippy -D warnings+cargo testGitHub Actions workflow (hand off to theci-pipelineskill 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.
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
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.

