Agent skill
cargo-build
Run cargo build with consistent flags and colorless output for CI/log parsing. Formats code first, then builds all workspace targets. Trigger when asked to build Rust projects or prepare binaries.
Stars
163
Forks
31
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/cargo-build
SKILL.md
Cargo Build
Overview
Standardize cargo build runs with consistent flags, colorless output, and format-first workflow. Ensures reproducible builds across environments.
Quick Start
- Run
skills/cargo-build/scripts/run_build.shfrom repository root. - Fix formatting errors first, then address compiler errors.
- Rerun script until build succeeds.
Workflow
- Format first:
cargo fmt --allensures code is formatted before building. - Build command:
cargo build --all-features --workspace --all-targets --message-format=short - Environment:
NO_COLOR=1- Disables color outputCARGO_TERM_COLOR=never- Ensures cargo output is colorless
- Scope: Builds all targets (lib, bin, tests, examples, benches) across entire workspace with all features enabled.
- Output format:
--message-format=shortprovides concise, parseable output.
Best Practices
- Always disable colors: Use
cargo --color=neveror setCARGO_TERM_COLOR=neverfor consistent, parseable output. - Format before build: Run
cargo fmt --allto catch formatting issues early. - Use workspace builds: Build entire workspace with
--workspaceunless targeting specific packages. - Enable all features: Use
--all-featuresto catch feature-gated compilation errors. - Run from root: Execute from repository root to ensure proper workspace resolution.
- Avoid ad hoc flags: Use consistent, documented build commands rather than one-off invocations.
Common Variations
Target specific package
bash
cargo --color=never build -p <package-name>
Release build
bash
cargo --color=never build --release --workspace --all-targets
Check without building
bash
cargo --color=never check --all-features --workspace --all-targets
Failure Handling
- Formatting failures: Fix code formatting issues reported by
cargo fmt. - Compilation errors: Address errors in the order reported by the compiler.
- Rerun full script: Don't run partial commands; always use the complete workflow.
Didn't find tool you were looking for?