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.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rust-async-reviewSkill
- rust-borrow-checkerSkill
- rust-crates-publishSkill
- rust-dependency-auditSkill
- rust-error-handlingSkill
- rust-lint-ciSkill
- rust-testing-benchesSkill
- rust-unsafe-reviewSkill
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
- Very specific: line 47
Always set resolver in a virtual workspace ("3" for edition 2024 members, "2" otherwise).
- Very specific: line 48
Put [profile.*], [patch.*] and [workspace.lints] only in the root.
- Very specific: line 62
If cargo is not available, say so and give the commands for the user to run.
≈ “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.
Files
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 = truekeys - The same dependency is listed with different versions in several
Cargo.tomlfiles - Adding an
xtaskcrate 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
- Inspect the current state (read-only):
Note members, editions, resolver and everypython3 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 availablehighfinding first. - 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.tomlhas only[workspace]), crates undercrates/ - automation (codegen, release, dist): an
xtaskcrate, see references/layout.md
- two or three crates, one main binary: root package +
- Write the root manifest from references/layout.md.
Always set
resolverin a virtual workspace ("3"for edition 2024 members,"2"otherwise). Put[profile.*],[patch.*]and[workspace.lints]only in the root. - 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 withfeatures = [...]next toworkspace = true). Internal crates go there too, with bothpathandversionso they can be published. - 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. - Verify:
Ifpython3 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 movecargois not available, say so and give the commands for the user to run.
Pitfalls
- A member without
editionbuilds as edition 2015; the checker reports it as high. default-features = falseon 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
membersorexclude. cargo publishfrom a workspace rewritesworkspace = truekeys into concrete values; path dependencies still need aversion.
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-targetsDoes 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.

