Claude
Skill
cargo-workflows
Use when managing Cargo workspaces, feature flags, build scripts, CI caching, dependency auditing, or Cargo.lock with Rust.
Virus-scanned
Reviewed automatically before listing.
Download
outlinedriven-outline-driven-development-.devin_skills_cargo-workflows-b0e8ce8.zip · 4 KB
Install
skills CLI
npx skills add https://github.com/OutlineDriven/outline-driven-development/tree/main/.devin/skills/cargo-workflows
Claude Code
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install outlinedriven-outline-driven-development@llmmart
Git
git clone https://github.com/OutlineDriven/outline-driven-development.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole outlinedriven/outline-driven-development collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Cargo workflows
Contract
| Field | Bound contract |
|---|---|
| Trigger | The user manages a Cargo workspace, sets feature flags, writes a build.rs script, configures CI caching, runs cargo nextest, audits dependencies, or updates Cargo.lock. |
| Authority | Reversible local: writes only local Cargo.toml, build.rs, Cargo.lock, CI workflow files, and report files the user names; rollback is git checkout -- or git reset for tracked files and rm for new reports. No remote mutation. |
| Side effect | Local Cargo.toml, workspace, build.rs, CI, and lock files may change; guidance and command output go to chat. |
| Done | The requested Cargo workflow builds or runs cleanly, or the failing command and its cause are reported. |
Inputs
- The project path (required): the workspace root or member crate.
- The task (required): workspace setup, feature flags, build script, CI caching,
cargo nextest, dependency audit, orCargo.lockmanagement. - Rust version (optional): defaults to 1.98.1 with edition 2024.
- Target crate or feature names (optional): used for scoped builds, tests, and updates.
- CI platform (optional): GitHub Actions, GitLab CI, or local runner.
Procedure
- Identify the project and toolchain. Run
rustc --versionandcargo --version. Locate the workspace root by finding theCargo.tomlthat contains[workspace]or the root package. Done when: the toolchain version and the workspace root are known. - Workspace setup. If the task is workspace setup, create or edit the root
Cargo.tomlwith[workspace],members,resolver = "2",[workspace.dependencies], and[workspace.package]. In memberCargo.toml, inherit withversion.workspace = trueandedition.workspace = true. For pattern details, seereferences/workspace-patterns.md. Done when:cargo check --workspacesucceeds. - Feature flags. If the task is feature flags, configure
[features]in the memberCargo.toml. Keep features additive, usedep:optional_depsyntax for optional dependencies, and setresolver = "2". Verify withcargo check --no-default-featuresandcargo check --all-features. Done when: the requested feature combinations build cleanly. - Build scripts (
build.rs). If the task is build scripts, add or editbuild.rsat the crate root. Emitcargo:rerun-if-changed=...,cargo:rustc-link-lib,cargo:rustc-link-search,cargo:rustc-cfg,cargo:rustc-env, andcargo:warningdirectives. Done when:cargo buildreruns the script only when inputs change and the crate links or generates correctly. - Incremental builds and CI caching. If the task is CI caching, configure
Swatinem/rust-cache@v2oractions/cache@v3to cache~/.cargo/registryandtarget/. Set[profile.release] incremental = falsewhen release builds must stay deterministic. Done when: CI logs show cache hits and build times are stable. cargo nextest. If the task is test execution, installcargo-nextest 0.9.143and runcargo nextest run. Addnextest.tomlwith profiles for CI and local runs. Done when: tests pass under the chosen profile.- Dependency auditing. If the task is dependency auditing, run
cargo auditfromcargo-audit 0.22.2,cargo deny checkfromcargo-deny 0.20.2, orcargo machete. Configuredeny.tomlfor licenses, duplicate versions, and banned crates. Done when: the tool reports no blocking findings or names each finding. Cargo.lockmanagement. If the task is lock management, keepCargo.lockin version control for applications and binaries; omit it for libraries. Usecargo generate-lockfile,cargo update, andcargo update -p <crate> --precise <version>. Done when: the lock file matches the intended dependency versions.- Common commands. If the task is a one-off command, run the matching
cargo build,cargo test,cargo tree,cargo expand, orcargo packageinvocation for the requested crate and features. Done when: the command output confirms the requested state.
Failure and recovery
| Failure class | Behavior |
|---|---|
| Workspace does not build | Check members paths, resolver, and missing Cargo.toml; fix and rerun cargo check --workspace. |
| Feature unification leaks | Confirm resolver = "2"; split dev and prod feature edges; use cargo tree -e features. |
| Build script reruns too often | Add cargo:rerun-if-changed for every input file and environment variable. |
| CI cache misses | Verify cache keys include Cargo.lock and restore both target/ and ~/.cargo. |
| Audit blocks the build | Address the advisory, add a rationale to deny.toml, or switch to an allowed license. |
| Lock update changes unexpected crates | Use cargo update --dry-run and cargo update -p <crate> to scope the change. |
Output
- A configured
Cargo.toml, workspace,build.rs, or CI file matching the task. - A
Cargo.lockwhen needed, with deterministic dependency versions. - A
nextest.tomlordeny.tomlconfiguration when requested. - A chat report naming the commands run and any remaining advisories or cache metrics.
Files (outline-driven-development)
-
agents
-
openai.yaml 192 B
interface: display_name: "Cargo Workflows" short_description: "Use when managing Cargo workspaces, feature flags, build scripts, CI caching, dependency auditing, or Cargo.lock with Rust."
-
-
references
-
workspace-patterns.md 3.9 KB
# Cargo workspace patterns reference ## Workspace dependency management ### Centralizing versions ```toml # Root Cargo.toml [workspace.dependencies] # Pin all workspace members to same versions tokio = { version = "1.35", features = ["full"] } serde = { version = "1.0", features = ["derive"] } tracing = "0.1" anyhow = "1.0" thiserror = "1.0" [workspace.package] version = "0.1.0" edition = "2021" authors = ["team@example.com"] license = "MIT OR Apache-2.0" repository = "https://github.com/org/repo" ``` ```toml # Member Cargo.toml [package] name = "myapp-core" version.workspace = true edition.workspace = true authors.workspace = true license.workspace = true [dependencies] tokio.workspace = true # Inherit, including features serde = { workspace = true, features = ["derive"] } # Can add features ``` ## Feature resolution (resolver = "3") With `resolver = "3"` (the edition 2024 default; declare it explicitly in virtual manifests, which have no edition to infer from): ```toml [workspace] resolver = "3" ``` - Build deps, dev-deps, and regular deps get independent feature resolution. - Prevents a dev-only dependency from enabling features in prod builds. - `target.cfg()` conditional features are respected independently. ## Virtual manifest pattern A workspace without its own `[package]`: it just orchestrates members: ```toml # Root Cargo.toml (virtual manifest) [workspace] members = ["crates/*", "tools/*"] resolver = "3" [workspace.package] version = "0.1.0" edition = "2024" [profile.release] lto = "thin" ``` Useful for monorepos where the root is not a published crate. ## Path vs registry dependencies ```toml [dependencies] # Path (local development) mylib = { path = "../mylib" } # Registry (published) mylib = { version = "1.0" } # Git (unpublished / fork) mylib = { git = "https://github.com/user/mylib", branch = "main" } mylib = { git = "https://github.com/user/mylib", rev = "abc1234" } # Override registry dep with local path (for development) # In root Cargo.toml: [patch.crates-io] serde = { path = "../my-serde-fork" } ``` ## Selective build commands ```bash # Build only specific workspace member cargo build -p myapp-core cargo build -p myapp-cli --release # Test specific member cargo test -p myapp-core # Test all members cargo test --workspace # Build all members cargo build --workspace # Exclude member cargo build --workspace --exclude myapp-codegen ``` ## Cargo.lock management ```bash # Libraries: Cargo.lock in .gitignore (let users choose versions) # Applications: Cargo.lock in version control (reproducible builds) # Generate deterministic lock file cargo generate-lockfile # Update single dep cargo update -p tokio --precise 1.35.1 # Show what would change cargo update --dry-run ``` ## CI configuration patterns ### GitHub Actions matrix ```yaml strategy: matrix: rust: [stable, beta, nightly] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 - run: cargo check --workspace --all-features - run: cargo test --workspace - run: cargo clippy --workspace -- -D warnings - run: cargo fmt --check ``` ### MSRV (minimum supported Rust version) ```toml [package] rust-version = "1.85" # MSRV declaration [workspace.package] rust-version = "1.85" ``` ```bash # Test against MSRV rustup install 1.85 cargo +1.85 check --workspace ``` ## Published crate checklist ```toml [package] name = "mycrate" version = "1.0.0" edition = "2021" description = "Short description" license = "MIT OR Apache-2.0" repository = "https://github.com/..." documentation = "https://docs.rs/mycrate" readme = "README.md" keywords = ["systems", "async"] categories = ["network-programming"] exclude = ["tests/fixtures/**", ".github/**"] ``` ```bash # Verify what will be published cargo package --list # Dry run publish cargo publish --dry-run # Publish to crates.io cargo publish ```
-
-
SKILL.md 5.2 KB
--- name: cargo-workflows description: 'Use when managing Cargo workspaces, feature flags, build scripts, CI caching, dependency auditing, or Cargo.lock with Rust.' --- # Cargo workflows ## Contract | Field | Bound contract | |---|---| | Trigger | The user manages a Cargo workspace, sets feature flags, writes a `build.rs` script, configures CI caching, runs `cargo nextest`, audits dependencies, or updates `Cargo.lock`. | | Authority | Reversible local: writes only local `Cargo.toml`, `build.rs`, `Cargo.lock`, CI workflow files, and report files the user names; rollback is `git checkout --` or `git reset` for tracked files and `rm` for new reports. No remote mutation. | | Side effect | Local `Cargo.toml`, workspace, `build.rs`, CI, and lock files may change; guidance and command output go to chat. | | Done | The requested Cargo workflow builds or runs cleanly, or the failing command and its cause are reported. | ## Inputs 1. The project path (required): the workspace root or member crate. 2. The task (required): workspace setup, feature flags, build script, CI caching, `cargo nextest`, dependency audit, or `Cargo.lock` management. 3. Rust version (optional): defaults to 1.98.1 with edition 2024. 4. Target crate or feature names (optional): used for scoped builds, tests, and updates. 5. CI platform (optional): GitHub Actions, GitLab CI, or local runner. ## Procedure 1. Identify the project and toolchain. Run `rustc --version` and `cargo --version`. Locate the workspace root by finding the `Cargo.toml` that contains `[workspace]` or the root package. Done when: the toolchain version and the workspace root are known. 2. Workspace setup. If the task is workspace setup, create or edit the root `Cargo.toml` with `[workspace]`, `members`, `resolver = "2"`, `[workspace.dependencies]`, and `[workspace.package]`. In member `Cargo.toml`, inherit with `version.workspace = true` and `edition.workspace = true`. For pattern details, see `references/workspace-patterns.md`. Done when: `cargo check --workspace` succeeds. 3. Feature flags. If the task is feature flags, configure `[features]` in the member `Cargo.toml`. Keep features additive, use `dep:optional_dep` syntax for optional dependencies, and set `resolver = "2"`. Verify with `cargo check --no-default-features` and `cargo check --all-features`. Done when: the requested feature combinations build cleanly. 4. Build scripts (`build.rs`). If the task is build scripts, add or edit `build.rs` at the crate root. Emit `cargo:rerun-if-changed=...`, `cargo:rustc-link-lib`, `cargo:rustc-link-search`, `cargo:rustc-cfg`, `cargo:rustc-env`, and `cargo:warning` directives. Done when: `cargo build` reruns the script only when inputs change and the crate links or generates correctly. 5. Incremental builds and CI caching. If the task is CI caching, configure `Swatinem/rust-cache@v2` or `actions/cache@v3` to cache `~/.cargo/registry` and `target/`. Set `[profile.release] incremental = false` when release builds must stay deterministic. Done when: CI logs show cache hits and build times are stable. 6. `cargo nextest`. If the task is test execution, install `cargo-nextest 0.9.143` and run `cargo nextest run`. Add `nextest.toml` with profiles for CI and local runs. Done when: tests pass under the chosen profile. 7. Dependency auditing. If the task is dependency auditing, run `cargo audit` from `cargo-audit 0.22.2`, `cargo deny check` from `cargo-deny 0.20.2`, or `cargo machete`. Configure `deny.toml` for licenses, duplicate versions, and banned crates. Done when: the tool reports no blocking findings or names each finding. 8. `Cargo.lock` management. If the task is lock management, keep `Cargo.lock` in version control for applications and binaries; omit it for libraries. Use `cargo generate-lockfile`, `cargo update`, and `cargo update -p <crate> --precise <version>`. Done when: the lock file matches the intended dependency versions. 9. Common commands. If the task is a one-off command, run the matching `cargo build`, `cargo test`, `cargo tree`, `cargo expand`, or `cargo package` invocation for the requested crate and features. Done when: the command output confirms the requested state. ## Failure and recovery | Failure class | Behavior | |---|---| | Workspace does not build | Check `members` paths, `resolver`, and missing `Cargo.toml`; fix and rerun `cargo check --workspace`. | | Feature unification leaks | Confirm `resolver = "2"`; split dev and prod feature edges; use `cargo tree -e features`. | | Build script reruns too often | Add `cargo:rerun-if-changed` for every input file and environment variable. | | CI cache misses | Verify cache keys include `Cargo.lock` and restore both `target/` and `~/.cargo`. | | Audit blocks the build | Address the advisory, add a rationale to `deny.toml`, or switch to an allowed license. | | Lock update changes unexpected crates | Use `cargo update --dry-run` and `cargo update -p <crate>` to scope the change. | ## Output 1. A configured `Cargo.toml`, workspace, `build.rs`, or CI file matching the task. 2. A `Cargo.lock` when needed, with deterministic dependency versions. 3. A `nextest.toml` or `deny.toml` configuration when requested. 4. A chat report naming the commands run and any remaining advisories or cache metrics.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.