From rust-skills
Implement reusable Rust library crates after the project shape is chosen, including public API design, module visibility, error types, feature flags, documentation examples, unit tests, integration tests, doctests, and Cargo validation. Use for Rust library implementation, API refactors, crate-boundary cleanup, or package-facing behavior.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rust-skills:build-library-crateThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implement reusable Rust library behavior with a small public API, clear module visibility, and tests at the boundary users actually call.
Implement reusable Rust library behavior with a small public API, clear module visibility, and tests at the boundary users actually call.
The practical goal is a crate that is easy to use from downstream code, easy to test inside the repository, and honest about compatibility, features, and errors.
Use repo-local Rust files, checked-out dependency sources, Dash MCP or Dash HTTP for installed Rust and Cargo docsets, and then official Rust and Cargo documentation when Dash/local coverage is missing or stale:
Use the repository's existing API style before introducing a new pattern.
Cargo.tomlsrc/lib.rssrc/tests/lib.rsPrefer private modules with explicit public re-exports:
mod parser;
pub use parser::{ParseError, parse_document};
Use pub(crate) for shared internal behavior that crosses modules inside one crate. Avoid pub just to make tests easy; use unit tests in the module for private behavior and integration tests for public behavior.
Split modules when a file starts owning unrelated jobs such as parsing, validation, rendering, and I/O.
Use Cargo features for real optional behavior:
std versus no_stdDo not add feature flags for uncertain future work. Every feature should have tests or at least a documented validation path.
Use unit tests for private transformations and edge cases.
Use integration tests under tests/ when the public API should be exercised like a downstream caller:
use my_crate::parse_document;
#[test]
fn parses_empty_document() {
let document = parse_document("").unwrap();
assert!(document.items().is_empty());
}
Use doctests when examples in public documentation should stay compiling and accurate.
Choose the narrowest command that proves the change:
cargo test -p package-name
cargo test -p package-name --doc
cargo clippy -p package-name --all-targets --all-features
cargo fmt --check
For publishable crates, defer packaging details to rust:package-workflow.
Return:
Library surface: public types, functions, modules, features, and errors changed.Caller impact: who uses the API and what becomes easier or safer.Visibility: what is public, pub(crate), or private and why.Tests: unit, integration, doctest, or feature coverage added or recommended.Validation: exact Cargo commands run or skipped with the concrete reason.Next skill: usually rust:testing-workflow, rust:tooling-style-workflow, or rust:package-workflow.npx claudepluginhub gaelic-ghost/socket --plugin rust-skillsCreates, edits, and verifies skills using a test-driven development approach with pressure scenarios and subagents.