top | item 47164263

Show HN: Rust-reorder – a CLI tool for reordering top-level items in Rust source

1 points| soletta | 4 days ago |github.com

I watched Claude burn tokens reordering functions in a Rust file, removing each one and rewriting it in the new position, clogging its own context window in the process. I started doing the reorders manually, then paused. This is a closed problem: fully verifiable. A good fit for building quickly with an AI coding agent. So I did.

When an agent needs to move a struct above its impl block, or group related functions together, it has to delete and re-insert lines — tracking whitespace, comments, attributes, and hoping nothing gets lost.

rust-reorder parses the file with syn, assigns ordinals to every top-level item, and lets you move or reorder them. Comments and doc attributes travel with their items. A safety check verifies no non-empty lines were lost or duplicated.

Three commands: `list` (shows items with ordinals), `move` (relocate one item before/after another), `order` (full reorder by ordinal sequence).

Works fine for humans too, but the real use case is giving agents a reliable primitive for code organization.

discuss

order

No comments yet.