rust-source-reorg

Reorders Rust source items and imports into canonical layout without behavior changes.

2|Updated May 6, 2026
One-click install
npx skills add https://github.com/bpcakes/jig-skills --skill rust-source-reorg-bpcakes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-source-reorg
Source: https://github.com/bpcakes/jig-skills/tree/main/plugins/jig-rust/skills/rust-source-reorg
Command: npx skills add https://github.com/bpcakes/jig-skills --skill rust-source-reorg-bpcakes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Rust files accumulate disorganized imports and out-of-order items over time, making code harder to navigate and review. This Skill restructures Rust source files into a canonical layout while preserving behavior, comments, attributes, and cfg-gated code. ## Core Features & Use Cases - Import Reorganization: Groups use statements into std, external crate, and crate-local sections, sorts them, merges shared prefixes, and removes unused or redundant imports. - Canonical Item Ordering: Reorders top-level items (modules, constants, traits, structs, impls, functions, test modules) into a consistent section order. - Attribute Normalization: Orders attributes by category and sorts #[derive(...)] trait lists alphabetically. - Use Case: After a large feature branch, run this Skill on the changed Rust files to clean up import sprawl and item ordering before opening a pull request, without touching any logic. ## Quick Start Ask the agent to reorganize the imports and item ordering of the Rust files in your current working changes without changing any behavior.

Frequently Asked Questions about rust-source-reorg

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

FAQPage Schema
How do I reorganize Rust imports and item ordering automatically?

Apply this Skill to your working changes or named files. It groups use statements into std, external, and crate-local sections, merges shared prefixes, removes unused imports, and reorders top-level items into a canonical section order.

How to clean up unused imports in Rust files?

The Skill removes imports not referenced anywhere in the file, including in macros, doc tests, and cfg-gated code. When usage is uncertain, such as macro expansions, it preserves the import and reports the limitation instead of guessing.

Does reordering Rust code change program behavior?

No. The Skill is a structural refactor only: it never changes names, signatures, visibility, or function bodies. It preserves cfg-gated items, macro_use attributes, and rustfmt::skip directives to keep compilation and runtime behavior intact.

Can I limit the reorganization to specific files or a branch?

Yes. Scope defaults to current working changes from git diff, but you can target a feature branch comparison, a base ref like main...HEAD, or explicitly named files and directories.

What are the limitations of automated Rust source reorganization?

Glob imports are expanded except for prelude and test helper modules, and order-sensitive macros or attributes are left in place when safe reordering cannot be established. Uncertain import usage is preserved rather than removed.