rust-refactorlisted
Install: claude install-skill flowmux-ai/flowmux-terminal
# Rust refactoring (flowmux workspace)
Refactor in small, behavior-preserving steps, each verified by the
compiler, Clippy, and the test suite. Never refactor on red — get a
green baseline first (see `rust-testing`), change, re-verify.
## Golden loop
Run after every meaningful edit. Order matters: fmt → check → clippy → test.
```bash
cargo fmt --all
cargo check --workspace # headless crates (excludes GUI crate `flowmux`)
cargo check -p flowmux # GTK crate (needs GTK4/libadwaita/WebKitGTK 6.0 dev pkgs)
cargo clippy --workspace --all-targets -- -D warnings
```
`-D warnings` is the project bar (CI enforces it). A refactor is not
done until Clippy is silent at that level.
Scope a single crate while iterating to cut cycle time:
```bash
cargo clippy -p flowmux-core --all-targets -- -D warnings
cargo test -p flowmux-core
```
## Clippy as the refactor engine
Clippy (https://doc.rust-lang.org/clippy/) is the famous, canonical
Rust linter — 700+ lints. Use it as the to-do list, not just a gate.
```bash
# See every suggestion, including pedantic, without failing the build:
cargo clippy --workspace --all-targets -- -W clippy::pedantic -W clippy::nursery
# Auto-apply the mechanical fixes Clippy is confident about:
cargo clippy --fix --workspace --all-targets --allow-dirty --allow-staged
cargo fmt --all # re-format after --fix
```
After `--fix`, read the diff — Clippy's autofix is conservative but
not infallible. Re-run the golden loop