Back to browse
GitHub Repository

Reorder top-level items in Rust source files. Designed for AI coding agents.

4 starsRust

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

by soletta·Feb 26, 2026·1 point·0 comments

AI Analysis

●●●BangerSolve My ProblemBig Brain

Stops AI from rewriting entire functions to reorder them; uses syn ordinals to preserve whitespace.

Strengths
  • Genuinely solves a real AI token-waste problem (Claude burning context rewriting functions)
  • Parse-preserving approach with safety checks guarantees no line loss or duplication
  • Scripting-friendly ordinal-based output designed for agent integration, not just human use
Weaknesses
  • Narrow use case—most useful for AI agents rather than manual Rust development
  • Requires syn expertise to understand; limited adoption potential outside agentic workflows
Target Audience

AI coding agents, Rust developers managing file structure, tool builders automating code reorganization

Post Description

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.

Similar Projects

Developer Tools●●●Banger

Overture – Interactive plan viewer for AI coding agents (open source)

Visual approval gates for AI agents before code writes—Claude/Cursor integration ready.

Big BrainSolve My Problem
AdewoleJasper
203mo ago