rust-test-separate

Extract inline Rust #[cfg(test)] modules into separate test files.

1|Updated Apr 8, 2026
One-click install
npx skills add https://github.com/maxenko/claude-skills --skill rust-test-separate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-test-separate
Source: https://github.com/maxenko/claude-skills/tree/main/rust-test-separate
Command: npx skills add https://github.com/maxenko/claude-skills --skill rust-test-separate

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Inline #[cfg(test)] test modules in Rust implementation files complicate readability and maintenance. This skill extracts those modules into dedicated test files while preserving hierarchy and accessible scope where possible.

Core Features & Use Cases

  • Preserves the module hierarchy so tests remain logically attached to their implementation modules.
  • Supports common Rust routing patterns (foo.rs with foo/tests.rs or foo/mod.rs with nested tests) and preserves private access where needed.
  • Reduces inline test bloat in source files and improves test organization for large crates.

Quick Start

Move inline #[cfg(test)] mod tests blocks into a separate test file following the project's module layout.

Frequently Asked Questions about rust-test-separate

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

FAQPage Schema
How do I move inline Rust tests into separate files?

To move inline Rust tests into separate files, extract #[cfg(test)] test modules from implementation files into dedicated test files. This process preserves the module hierarchy and ensures imports and visibility remain correct after extraction.

What is the best way to organize Rust tests for large crates?

Organizing Rust tests for large crates involves moving inline #[cfg(test)] test modules into dedicated test files. This reduces inline test bloat in source files and improves test organization while preserving module hierarchy and private access scope.

Does extracting Rust tests into separate files preserve module visibility?

Extracting Rust tests into separate files preserves module hierarchy and accessible scope where possible. The extraction process adapts use paths as needed to maintain correct imports and visibility across common Rust routing patterns, including nested tests.

Why do inline #[cfg(test)] modules complicate Rust code maintenance?

Inline #[cfg(test)] modules complicate Rust code maintenance because they bloat implementation files and reduce readability. Moving these test blocks into dedicated test files reorganizes the codebase while keeping tests logically attached to their implementation modules.

Can I extract nested Rust test modules into dedicated test files?

You can extract nested Rust test modules into dedicated test files. The extraction supports various mod patterns and common Rust routing patterns like foo.rs with foo/tests.rs or foo/mod.rs with nested tests, ensuring imports and visibility remain correct.