rust-module-layout
Installation
SKILL.md
Rust Module Layout (Inside a Single Crate)
Authority: The Rust Book ch7, Rust Reference ch7, Rust API Guidelines — Organization (C-HIERARCHY, C-REEXPORT), Rust Style Guide.
This skill is the crate-internal counterpart to rust-workspace. That skill decides crate boundaries (workspace, packages, dependency direction). This skill decides what lives inside one crate's src/: the file tree, the mod declarations, the visibility, and the public re-export surface.
Capability Boundaries
✅ Strengths
- Translating a logical module hierarchy into a physical
src/directory tree - Writing
lib.rs/main.rsas a thin index, not a dumping ground - Choosing between
foo.rs/foo/mod.rs/foo/(Edition 2018+ vs legacy) - Naming modules semantically (
connectionrather thandb,runtimerather thanrt) - Applying
pub/pub(crate)/pub(super)/pub(in path)deliberately - Designing a flat public facade over a deep private tree via targeted
pub use - Recognizing and refactoring the "flat lib.rs +
pub use *::*" anti-pattern (common in crates ported from Java/Python) - Splitting a 500+ line file into a directory without breaking callers
- Migrating legacy
mod.rslayouts to the modernfoo.rs + foo/form