large-mechanical-refactor
Use when a wide refactor ripples across many files.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- large-mechanical-refactor
- author
- Moses
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "refactor", "async", "signature", "delegation", "verification" ], "related_skills": [ "test-driven-development", "subagent-driven-development", "survey-before-action" ] } }
- description
- Use when a wide refactor ripples across many files.
02 资源文件 1
- 参考文档references/async-conversion-rust.md2.1 KB
03 SKILL.md 正文
Large Mechanical Refactor — safe execution of a wide API/signature change
When to Use
A refactor changes a signature (or makes an API async, sync, callback, etc.) and the change ripples across many files in one repo — so wide it cannot be proven by the compiler alone and must land as one compiling commit (an intermediate HEAD won't build). Trigger on: converting an API to async across call sites, renaming a symbol tree-wide, or a signature change used in many files. The failure shape is doing this by hand across dozens of files, or delegating it blind.
The discipline
- Baseline the suite first. Capture the true count
cargo test --workspace -- --list | grep -cE ': test$'BEFORE touching anything. A wide refactor cannot be measured against a broken baseline — a stray missing-import compile error in an unrelated test file surfaces here as the blocker it is, and you fix it as a separate commit BEFORE your refactor so your diff is clean. - Map the full blast radius, not just the named methods. A sync→async conversion on three
core methods forces every internal caller chain async too (helpers that call them), plus a
runtime in any bin, plus each sync
#[test]caller must become#[tokio::test] async fnwith.await. Grep for the SYMBOL across the whole tree (.handle(,.record(,.dispatch() so you know every file and call-site count before writing the first patch — hand-rolled mocks and sibling helpers silently re-implement the old shape and fail on a shard you did not run. - Prove the recipe on ONE small instance by hand. Pick the smallest affected test file,
apply the full conversion by hand, watch it compile and pass. This locks the exact pattern:
marker becomes
#[tokio::test] async fn,.awaitgoes BEFORE.unwrap()(x.handle().await.unwrap()), helperfns that call async methods becomeasync fnand all their call sites gain.await. Encapsulate this in the delegation context. - Delegate the bulk to a subagent with the proven recipe. The remaining files are the same
mechanical transformation, independent per file. Hand the subagent the exact recipe (steps,
the
.await-before-.unwrap()ordering, which symbols become async vs stay sync, an explicit DON'T-TOUCH list, and the per-file verify commandcargo test -p <crate> --test <name> --no-run) plus the ONE already-converted file path as a forbidden-to-edit reference. Tell it not to git add/commit and not to run the full suite. - Verify the full suite YOURSELF — the subagent's
--no-runpass is a claim, not proof. After it returns, run the full workspace suite and confirm the count you captured at step 1 holds (or grew exactly as expected). Never report green without your own real output. - Commit and verify often. This user prefers small, frequent, verified commits over one giant dump. One atomic commit per logical slice (baseline-fix commit, then the refactor commit, each verifiable), never batch unrelated edits.
Pitfalls
- Do not re-derive call sites from memory —
search_filesthe symbol every time; a refactor targets what the compiler and the grep agree on, never what you remember. - Ignore linter "async fn not permitted in Rust 2015" on an edition-2021 workspace — the lint tool reads the default edition and misreports; cargo is the source of truth, not the inline linter.
- A compile-breaking refactor must land green or not at all — either it lands as one compiling commit or the committed HEAD fails the suite; an intermediate HEAD that doesn't build is not a checkpoint.
- Keep unrelated rustfmt diffs out of the commit — a whole-crate
cargo fmtreformats pre-existing files and turnsgit statusinto noise. Revert files you didn't otherwise touch; confirm a remaining diff is pre-existing viagit stash+cargo fmt --check+git stash pop. - A new doc that reuses a numbered vocabulary claimed by an earlier plan in the same repo
collides corpus-wide (two plans each with their own "Story 0–7" / "Story 0–9").
search_filesthe corpus for the planned label before naming new stories/slices; if the number is taken, namespace the new set with a thematic prefix (SS0–SS9) and carry both the slice code and the story id in the ownership table so the owning plan is unambiguous.
See references/async-conversion-rust.md for the explicit Rust sync→async recipe.
04 同仓库更多 Skills
macbook-linux-maintenance
Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.
governance-regression-triage
Triage a host's governance issues: what changed.
enforcement-immutability
Use when enforcement files lose their immutable flag.
steadfaste-fleet-repo-deploy
Use when committing to the steadfaste-fleet repo.
steadfaste-fleet-maintenance
Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.
fleet-preflight
DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its "Repo-Specific Pre-Flight" section covers git search, Hermes boundary, and deployment verification.