tomevault-io

workspace-shared-dependencies

Use when adding or modifying a dependency in a crate's `Cargo.toml` that is or may become shared by multiple workspace crates — keep its version defined in one place.

tomevault-io 1 Updated 1mo ago
GitHub

Install

npx skillscat add tomevault-io/tomes/workspace-shared-dependencies

Install via the SkillsCat registry.

About this skill

This skill enforces declaring shared Cargo dependencies once in the root workspace `[workspace.dependencies]` table, with member crates referencing them via `workspace = true`. It prevents version drift and duplicate crate resolution across workspace members. Use it when adding or modifying a dependency in any crate's `Cargo.toml` that may be used by more than one workspace crate.

SKILL.md

Workspace-Level Shared Dependencies

Rule

When adding a dependency that another crate in the workspace already uses (or that you anticipate adding to another crate), declare it once in the root Cargo.toml's [workspace.dependencies] table. In each crate that uses it, write:

[dependencies]
serde = { workspace = true }

Don't duplicate version strings across crates. Don't keep a dependency crate-local once a second crate adopts it — promote it to the workspace.

For dependencies used in only one crate, keep them crate-local. Promote when a second crate starts using them.

Why

A workspace declaration is the single source of truth for a shared version. Without it, each crate pins its own, versions drift, cargo resolves duplicates, and compile times grow.

Examples

# Good (workspace root)
[workspace.dependencies]
serde = "1.0"
thiserror = "1.0"

# Good (crate)
[dependencies]
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }
# Bad: two crates pinning the same dep at potentially different versions
# crates/foo/Cargo.toml
[dependencies]
serde = "1.0"

# crates/bar/Cargo.toml
[dependencies]
serde = "1.0.130"

Source: 0xMiden/protocol — distributed by TomeVault.

Categories