agentleFS
saizulsaizul/rust-dev-skills/skills/rust-workspace-setup/SKILL.md

rust-workspace-setup

Skill0 starsChanged 3 days agoMITView on GitHub

Set up or fix a Cargo workspace - crates/ layout, virtual vs root-package manifests, resolver 2/3, shared [workspace.package] metadata, [workspace.dependencies] and [workspace.lints] inheritance, profiles and patches at the root, and xtask helpers. Includes a checker that finds missing members, members without edition (silently 2015), undefined workspace keys, the same dependency pinned differently across crates, [profile] sections cargo ignores and orphan crates. Use when the user wants to split a crate into several, start a multi-crate Rust project, sees "current package believes it's in a workspace when it's not", "profiles for the non root package will be ignored" or resolver warnings, or asks to clean up duplicated dependency versions across crates.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Always set resolver in a virtual workspace ("3" for edition 2024 members, "2" otherwise).

    line 47
  2. Very specific:

    Put [profile.*], [patch.*] and [workspace.lints] only in the root.

    line 48
  3. Very specific:

    If cargo is not available, say so and give the commands for the user to run.

    line 62

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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 workspace setup

Goal: one root Cargo.toml that owns shared metadata, dependency versions, lint levels and profiles; members that inherit them; and a layout that scales from 2 to 50 crates.

Paths below are relative to this skill's folder (in Claude Code: ${CLAUDE_SKILL_DIR}).

When to use

  • "Split this crate into a library and a CLI", "set up a monorepo for these Rust crates"
  • Cargo warnings about workspaces, resolvers, ignored profiles or workspace = true keys
  • The same dependency is listed with different versions in several Cargo.toml files
  • Adding an xtask crate for project automation

When not to use

  • Auditing which dependencies to keep or replace: rust-dependency-audit
  • Setting lint levels and CI jobs: rust-lint-ci (this skill only wires [workspace.lints])
  • Publishing workspace crates in order: rust-crates-publish

Workflow

  1. Inspect the current state (read-only):
    python3 scripts/workspace_check.py .            # text report
    python3 scripts/workspace_check.py . --json     # machine-readable
    cargo metadata --no-deps --format-version 1 | head -c 2000   # if cargo is available
    Note members, editions, resolver and every high finding first.
  2. Pick the layout (decision table in references/layout.md):
    • two or three crates, one main binary: root package + members = ["crates/*"] is fine
    • libraries + several binaries, or more than three crates: a virtual workspace (root Cargo.toml has only [workspace]), crates under crates/
    • automation (codegen, release, dist): an xtask crate, see references/layout.md
  3. Write the root manifest from references/layout.md. Always set resolver in a virtual workspace ("3" for edition 2024 members, "2" otherwise). Put [profile.*], [patch.*] and [workspace.lints] only in the root.
  4. Move shared values up. For every dependency used by two or more members, add it once to [workspace.dependencies] (features that everyone needs go there; extra features are added per member with features = [...] next to workspace = true). Internal crates go there too, with both path and version so they can be published.
  5. Make members inherit: version.workspace = true, edition.workspace = true, license.workspace = true, rust-version.workspace = true, dep.workspace = true, and [lints] workspace = true. Show the user the diff for each manifest before writing it.
  6. Verify:
    python3 scripts/workspace_check.py . --fail-on low
    cargo metadata --format-version 1 > /dev/null && cargo check --workspace --all-targets
    cargo tree -d          # duplicate versions left after the move
    If cargo is not available, say so and give the commands for the user to run.

Pitfalls

  • A member without edition builds as edition 2015; the checker reports it as high.
  • default-features = false on a member has no effect if the workspace entry enables default features; set it in [workspace.dependencies] instead.
  • Nested crates that are not members make cargo fail with "current package believes it's in a workspace": add them to members or exclude.
  • cargo publish from a workspace rewrites workspace = true keys into concrete values; path dependencies still need a version.

Output

Workspace: virtual, resolver 3, 4 members (crates/core, crates/api, crates/cli, xtask)
Fixed: 2 high (missing edition in crates/api, undefined workspace dep `tokio`),
       1 medium (serde pinned 1.0.150 / 1.0.200 -> [workspace.dependencies])
Changed files: Cargo.toml, crates/*/Cargo.toml (diff above)
Verify: cargo check --workspace --all-targets

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.