split-rust-file

Splits oversized Rust source files into cohesive module-based layouts.

3|Updated Jan 17, 2026
One-click install
npx skills add https://github.com/waki285/dotfiles --skill split-rust-file-waki285
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: split-rust-file
Source: https://github.com/waki285/dotfiles/tree/main/.skills/split-rust-file
Command: npx skills add https://github.com/waki285/dotfiles --skill split-rust-file-waki285

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Large Rust files become hard to navigate and maintain, and splitting them incorrectly can break module paths, visibility, and public APIs. This Skill refactors oversized Rust files into proper module structures while preserving the public API and keeping the crate compiling. ## Core Features & Use Cases - Automatic candidate discovery: When no file is specified, it finds every Rust file over 1000 lines using platform-appropriate commands for macOS, Linux, and Windows. - Layout guidance: Chooses between sibling extraction and directory-module conversion based on the code's actual structure, while forbidding invalid layouts like coexisting foo.rs and foo/ directories. - Safe refactoring workflow: Moves code by responsibility, updates use and visibility paths, keeps mod.rs as a thin routing layer, and validates with cargo fmt and cargo check. - Use Case: You inherit a Rust project where src/parser.rs has grown to 2500 lines mixing types, parsing, and rendering. The Skill splits it into src/parser/mod.rs, types.rs, parse.rs, and render.rs with re-exports preserving the existing API. ## Quick Start Ask the AI to split every Rust file over 1000 lines in this project into well-organized modules and verify the crate still builds.

Frequently Asked Questions about split-rust-file

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

FAQPage Schema
How do I split a large Rust file into modules?▼

Split a large Rust file by identifying responsibility boundaries such as types, parsing, and rendering, then moving each into its own module file. Keep mod.rs as a thin layer with module declarations and re-exports, and validate with cargo fmt and cargo check.

How to find Rust files over 1000 lines in a project?▼

On macOS or Linux, run find with wc -l and filter with awk for files over 1000 lines. On Windows, use Get-ChildItem with [System.IO.File]::ReadAllLines to count physical lines per file.

Should I use sibling modules or a directory module in Rust?▼

Use sibling extraction when the original file should remain the facade or entry point for its API. Convert foo.rs into foo/mod.rs only when foo should own a nested namespace and the final layout fully replaces foo.rs.

Can foo.rs and a foo directory coexist in Rust?▼

No, having both foo.rs and a foo/ directory is a forbidden layout. Also avoid foo/foo.rs, and never place type definitions, impl blocks, or logic inside mod.rs, which should only declare and re-export modules.

When should I not split a large Rust file?▼

Do not split a file that is long only because of one tightly coupled algorithm or a single large match table. If the code is one cohesive unit, explain that instead of forcing a poor module structure.