rust-architecture

Installation
SKILL.md

Rust architecture

Use this skill when a change crosses modules or crates, establishes a public API, selects an execution model, or adds a long-lived abstraction.

Map the existing design

Read workspace manifests, package boundaries, feature flags, public exports, binary/library split, error types, and neighboring implementations. Check the project's MSRV and compatibility policy. Prefer the smallest boundary that gives the change a clear owner; don't introduce a workspace, layer, service abstraction, or trait solely because it is a familiar pattern.

Crates, modules and APIs

  • Keep implementation details private by default. Expose public items for real consumers, and document behavior, errors, invariants, feature requirements, and examples.
  • Use crate boundaries when independent reuse, compile-time isolation, ownership, or dependency direction benefits are concrete. Modules are usually enough to organize code within one package.
  • Design APIs around caller needs. Follow Rust API Guidelines for naming, conversions, collections, errors, and interoperability, while respecting the crate's existing compatibility promises.
  • Avoid public types or trait abstractions that make simple use harder. Conversely, don't hide meaningful domain states in strings or loosely structured maps when typed data improves correctness.
  • Treat feature flags as part of the public surface: check combinations, defaults, and downstream impact before adding or changing them.

Errors and boundaries

Use domain-specific errors where callers need to distinguish or handle failures. At an application boundary, add context that helps operators or users act. Keep low-level source errors available for diagnosis. Separate invalid input, expected absence, environmental failure, and violated internal invariants where that distinction affects behavior.

Installs
1
First Seen
5 days ago