sd-rust-modules

Organizes Rust modules, visibility, re-export facades, and crate boundaries during refactors.

Updated Jun 26, 2026
One-click install
npx skills add https://github.com/platypeeps/sd-ai-command-pack --skill sd-rust-modules-platypeeps
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sd-rust-modules
Source: https://github.com/platypeeps/sd-ai-command-pack/tree/main/contrib/sd-rust-modules
Command: npx skills add https://github.com/platypeeps/sd-ai-command-pack --skill sd-rust-modules-platypeeps

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust codebases drift into god modules, scattered type buckets, and over-widened visibility as they grow. This Skill applies a consistent set of rules for module layout, visibility levels, re-export facades, and crate boundaries so reorganizations stay deliberate and behavior-preserving. ## Core Features & Use Cases - Module layout guidance: Enforces the sibling-file pattern for new code while matching existing mod.rs conventions during edits, and splits modules only when size coincides with distinct domain concepts. - Visibility discipline: Widens visibility one rung at a time (private, pub(super), pub(in path), pub(crate), pub) with each widening justified by a named consumer. - Facade and crate boundaries: Keeps public APIs flat behind re-export facades, co-locates tightly coupled types, and reserves new crates for real boundaries like compile-time firewalls. - Use Case: When a 600-line billing.rs mixes invoices, payments, and refunds, use this Skill to split it by domain concept, keep the facade so callers see no path change, and verify the build and tests still pass. ## Quick Start Use the sd-rust-modules skill to split my oversized billing module into cohesive submodules without changing the public API.

Frequently Asked Questions about sd-rust-modules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I split a large Rust module into smaller files?▼

Split a Rust module only when it exceeds roughly 400 lines and contains distinct domain concepts, or when a privacy boundary is needed. Cut by domain concept, keep the parent re-export facade, and verify the crate still builds and tests pass after the move.

Should I use mod.rs or the sibling file pattern in Rust?▼

Match the existing codebase convention first: a project using mod.rs keeps using it during edits. For new code, prefer the sibling file pattern where billing.rs declares mod invoice and billing/invoice.rs holds the child module.

When should I use pub(crate) vs pub(super) in Rust?▼

Use the narrowest level that reaches the actual consumer: pub(super) when only the parent module consumes the item, pub(crate) only when the consumer lives elsewhere in the crate. Reaching for pub(crate) when pub(super) suffices widens API surface unnecessarily.

When should I create a new crate instead of a module?▼

Create a new crate only for a real boundary: an independently reusable unit, a compile-time firewall, or a dependency direction the type system should enforce. A crate created for tidiness adds a version number and build unit you maintain forever.

What are the limits of automated Rust module reorganization?▼

This Skill governs structure only, not the code inside modules; idioms belong to quality tooling and type modeling to design tooling. It stays inside the requested scope, reporting layout defects found elsewhere rather than repairing them in passing.