Workspace shared dependencies

From 0xMiden/protocol · View interactive version

Workspace shared dependencies is an AI agent skill from the GitHub repository 0xMiden/protocol. 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.

How to use this skill

Skill file

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"
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.