Getting Started
Prerequisites
Install the Rust toolchain and cargo-generate:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install cargo-generate
Create a Project
cargo generate rararulab/cli-template
You’ll be prompted for three values:
| Placeholder | Format | Example | Used For |
|---|---|---|---|
project-name | kebab-case | my-awesome-cli | Binary name, directory, npm pkg |
crate_name | snake_case | (auto-derived) | Rust module name |
github-org | — | myorg | Repo URLs, CI badges |
crate_nameis derived automatically fromproject-name— you rarely need to change it.
First Run
cd my-awesome-cli
cargo check
cargo test
cargo run -- --help
cargo run -- hello world
The hello command is a working example wired end-to-end. Use it as a reference when adding your own commands.
What to Customize
Once you’ve verified the template builds, update these files:
CLAUDE.md— add a description of your project for AI-assisted developmentCargo.toml— setdescription,repository, andhomepagesrc/cli/mod.rs— replace the exampleHellocommand with your ownsrc/app_config.rs— replaceExampleConfigwith your app’s config fieldsREADME.md— rewrite for your project
Clean Up Example Code
Once your first real command is in place, remove the scaffolding:
- Delete the
Hellovariant from theCommandenum insrc/cli/mod.rs - Delete its match arm in
main.rs - Replace
ExampleConfiginsrc/app_config.rswith your own config struct
Don’t delete the example code until you have a real command working. It serves as a reference for the patterns used throughout the template.
Verify
cargo check && cargo test && cargo clippy
All three should pass cleanly before your first commit.
Next Steps
- Project Structure — understand the module layout and conventions