BosskuAI Rust Refactoring
Use this skill to carry out, or audit, a complete and coherent Rust refactor: every definition, caller, import, test, doc, and config reference updated together, with behaviour preserved unless a change is authorised. Rust has no classes, so read "class" as the relevant structs, enums, traits, impls, or modules.
How this differs from nearby skills
bosskuai-rust-patterns: idioms for writing new Rust (ownership, errors, traits). Use it as the style reference while refactoring.
bosskuai-rust-testing: how to write Rust tests; here tests are used as the safety net and extended with characterization tests.
bosskuai-code-revamp: safe refactors and legacy cleanup in any language; this skill holds the Rust-specific moves.
bosskuai-business-logic-review: reviews business rules, not structure.
Workflow
- Classify the request: audit, implement, explain, or plan. Fix scope, objective, compatibility expectations, and which behaviour changes are authorised.
- Read repository instructions, manifests, toolchain and lint config, CI, and feature definitions. Check uncommitted work and never overwrite changes you did not make. Compare
rustc --version with the channel in rust-toolchain.toml and the rust-version in Cargo.toml, and use only APIs present in the rust-version from Cargo.toml when it is set. When it is not, use the channel in rust-toolchain.toml, or the installed rustc if no file pins one.
- Map the affected surface: definitions, callers, traits, impls, tests, re-exports, macros, features, errors, side effects.
pub alone does not prove external reachability; check visibility and re-exports. Use the language server's references first, then search macro input, attributes, include_* paths, build scripts, snapshots, string dispatch, serialisation names, FFI names, and doctests.
- Baseline. Run the narrowest existing tests and checks before editing and record pre-existing failures. Add characterization tests where behaviour matters but is underspecified. Profile or benchmark before any performance work.
- Design coherent batches. Group mutually dependent changes, order by dependency, risk, and verification cost. Keep unrelated cleanup out.
- Implement end to end. Leave no half-renamed symbols, duplicate old and new paths, or stale comments. Add regression tests for any defect you fix.
- Verify with the relevant matrix: format check, targeted tests then crate or workspace tests,
cargo check, Clippy, docs. Derive feature and target coverage from manifests, cfg use, and CI rather than assuming --all-features is valid. Run a semver checker if the public API may have changed. Also run cargo test --release, since integer overflow behaves differently there.
- Review the final diff: every changed file belongs to the transformation, no accidental lockfile, dependency, or formatting churn.
Audit inventory item
### RUST-001: category and short title
- Location: crate/path, symbol
- Evidence: what the code does and who calls it
- End state: the target design
- Coupled changes: files that must move together
- API or behaviour impact: internal only / needs authorisation
- Risk and value: low/medium/high
- Verification: tests and checks
Report every evidence-backed finding in scope, state what was and was not inspected (feature-gated, macro-generated, target-specific code), and skip style preferences.
Behaviour that counts as observable
Public API shape, errors, ordering, side effects, panic conditions, serialisation, I/O, drop timing, lock scope, .await boundaries, cancellation. Iterator rewrites can change ordering or short-circuit behaviour; entry().or_insert is not the same as "update only if present".
Guardrails
- Ask before changing public API, ABI, CLI, config, features, wire or persistence formats, dependencies, toolchain or MSRV, lint policy, or existing
unsafe, FFI, cryptography, or authentication code.
- Do not add
unsafe to get past the borrow checker. Do not weaken, skip, or rewrite tests to accept new behaviour.
- Do not replace an error with a default or ignored result unless the contract says so.
- Do not change a numeric type, sign or rounding without a test that proves the same results.
as casts truncate silently.
- Claim a speed-up only after a comparable measurement. Report a command as passed only if it ran and passed.
- No destructive Git operations (reset, clean, force checkout) without explicit authorisation. Do not expose secrets found while reading.
- If the existing design is clearer and safer, say so and leave it.
Output format
Implemented scope: [objective, batches]
Files and symbols: [moved, renamed, deleted]
Behavior and API: [preserved, intentional changes]
Verification: [exact commands and results]
Remaining risk: [unverified targets, deferred items]
Also check the shared quality bar: ../../references/checklists/engineering-quality-bar.md.
Adapted from agency-agents/engineering/engineering-rust-refactoring-specialist.md (agency-agents, MIT).
1---2name: bosskuai-rust-refactoring3description: "Use when refactoring a Rust codebase at crate or workspace scale: safe renames, module restructuring, duplication removal, ownership and panic hardening, Clippy fixes, with an audit inventory and full-verification report."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-rust-refactoring6---78# BosskuAI Rust Refactoring910Use this skill to carry out, or audit, a complete and coherent Rust refactor: every definition, caller, import, test, doc, and config reference updated together, with behaviour preserved unless a change is authorised. Rust has no classes, so read "class" as the relevant structs, enums, traits, impls, or modules.1112## How this differs from nearby skills1314- **`bosskuai-rust-patterns`**: idioms for writing new Rust (ownership, errors, traits). Use it as the style reference while refactoring.15- **`bosskuai-rust-testing`**: how to write Rust tests; here tests are used as the safety net and extended with characterization tests.16- **`bosskuai-code-revamp`**: safe refactors and legacy cleanup in any language; this skill holds the Rust-specific moves.17- **`bosskuai-business-logic-review`**: reviews business rules, not structure.1819## Workflow20211. Classify the request: audit, implement, explain, or plan. Fix scope, objective, compatibility expectations, and which behaviour changes are authorised.222. Read repository instructions, manifests, toolchain and lint config, CI, and feature definitions. Check uncommitted work and never overwrite changes you did not make. Compare `rustc --version` with the channel in `rust-toolchain.toml` and the `rust-version` in `Cargo.toml`, and use only APIs present in the `rust-version` from `Cargo.toml` when it is set. When it is not, use the channel in `rust-toolchain.toml`, or the installed `rustc` if no file pins one.233. Map the affected surface: definitions, callers, traits, impls, tests, re-exports, macros, features, errors, side effects. `pub` alone does not prove external reachability; check visibility and re-exports. Use the language server's references first, then search macro input, attributes, `include_*` paths, build scripts, snapshots, string dispatch, serialisation names, FFI names, and doctests.244. Baseline. Run the narrowest existing tests and checks before editing and record pre-existing failures. Add characterization tests where behaviour matters but is underspecified. Profile or benchmark before any performance work.255. Design coherent batches. Group mutually dependent changes, order by dependency, risk, and verification cost. Keep unrelated cleanup out.266. Implement end to end. Leave no half-renamed symbols, duplicate old and new paths, or stale comments. Add regression tests for any defect you fix.277. Verify with the relevant matrix: format check, targeted tests then crate or workspace tests, `cargo check`, Clippy, docs. Derive feature and target coverage from manifests, `cfg` use, and CI rather than assuming `--all-features` is valid. Run a semver checker if the public API may have changed. Also run `cargo test --release`, since integer overflow behaves differently there.288. Review the final diff: every changed file belongs to the transformation, no accidental lockfile, dependency, or formatting churn.2930## Audit inventory item3132```markdown33### RUST-001: category and short title34- Location: crate/path, symbol35- Evidence: what the code does and who calls it36- End state: the target design37- Coupled changes: files that must move together38- API or behaviour impact: internal only / needs authorisation39- Risk and value: low/medium/high40- Verification: tests and checks41```4243Report every evidence-backed finding in scope, state what was and was not inspected (feature-gated, macro-generated, target-specific code), and skip style preferences.4445## Behaviour that counts as observable4647Public API shape, errors, ordering, side effects, panic conditions, serialisation, I/O, drop timing, lock scope, `.await` boundaries, cancellation. Iterator rewrites can change ordering or short-circuit behaviour; `entry().or_insert` is not the same as "update only if present".4849## Guardrails5051- Ask before changing public API, ABI, CLI, config, features, wire or persistence formats, dependencies, toolchain or MSRV, lint policy, or existing `unsafe`, FFI, cryptography, or authentication code.52- Do not add `unsafe` to get past the borrow checker. Do not weaken, skip, or rewrite tests to accept new behaviour.53- Do not replace an error with a default or ignored result unless the contract says so.54- Do not change a numeric type, sign or rounding without a test that proves the same results. `as` casts truncate silently.55- Claim a speed-up only after a comparable measurement. Report a command as passed only if it ran and passed.56- No destructive Git operations (reset, clean, force checkout) without explicit authorisation. Do not expose secrets found while reading.57- If the existing design is clearer and safer, say so and leave it.5859## Output format6061```text62Implemented scope: [objective, batches]63Files and symbols: [moved, renamed, deleted]64Behavior and API: [preserved, intentional changes]65Verification: [exact commands and results]66Remaining risk: [unverified targets, deferred items]67```6869Also check the shared quality bar: `../../references/checklists/engineering-quality-bar.md`.7071Adapted from agency-agents/engineering/engineering-rust-refactoring-specialist.md (agency-agents, MIT).