Safe Multi-File Refactoring: Map Blast Radius, Then Batch and Verify
A large-refactor playbook for agents: first do a read-only survey of the 'blast radius' — which files, call sites, and tests are affected — then split the change into small batches, each preserving behavior, each run through its own tests, each its own atomic commit. Puts an end to 'change 40 files at once, then the build breaks and no one knows where to start fixing it.'
大型重構最怕 agent 一口氣改幾十個檔案、最後 build 全紅、根本不知道哪一步壞的。
這支指令逼它:① 先唯讀盤出完整影響範圍 ② 切成小批、每批行為不變 ③ 每批各自跑測試 + 各自一個原子 commit,壞了能精準回退。
[ Log in to see the full prompt ]Sign up free to see the full prompt, copy it, save it, and join the discussion. Free content unlocks on login; Pro content is a separate subscription.
Where to use it: structural refactors spanning multiple files — moving modules, renaming conventions, extracting shared logic, or swapping out every call site of an API. Why it works: (1) it forces a 'read-only blast-radius survey before touching anything,' the core discipline of professional refactoring, which keeps the agent from missing call sites and breaking the build; (2) batching, with each batch required to 'compile, pass tests, and be committable on its own,' means a break can be bisected precisely instead of facing one unmanageable pile of changes; (3) atomic commits that never mix refactoring with behavior changes make PR review faster and rollbacks easy; (4) it explicitly bans 'casually touching unrelated code or formatting that shouldn't be touched,' keeping the diff to the minimum reviewable size. Tip: pairing this with Claude Code's plan mode (double-tap Shift+Tab) or Codex's read-only sandbox for Phase 1 works best; fill VERIFY_COMMAND with a command you can run to verify everything in one shot. Every capability mentioned here (read-only exploration, plan mode, batched commits) is a real, existing workflow.
## Phase 1 — Blast radius Direct targets: src/api/*.ts 裡 11 處裸 fetch() Call sites & ripple: 23 個元件/hook import 這些函式(清單附檔名) Tests covering: api.test.ts(8 例)+ 4 個元件測試 = 安全網;profile 流程無測試 → 已標記 Risk hotspots: auth header 注入、401 重導邏輯(行為必須完全保留) Batch plan: - Batch 1/4:新增 apiClient(不改任何呼叫點)— 加法、零風險 - Batch 2/4:搬 read-only GET 端點 → apiClient - Batch 3/4:搬含 auth 的 POST/PUT(高風險批,逐一比對 header) - Batch 4/4:刪除舊裸 fetch + 死碼 每批結束:編譯通過、測試綠、單一 commit。 → 等你核准計畫,我再開始 Phase 2。
Suno Engineer's Mindset: 4 Steps to a Song That Doesn't Sound Like AI
A studio engineer's breakdown of Suno's fatal weaknesses (fried vocals, high-frequency artifacts), plus a 4-step DAW workflow and a Suno Studio cleanup prompt.
5 Claude Weekly Workflows That Stuck After 6 Months
Proposal generator / meeting processor / content repurposer / Friday review / shutdown reset — out of 40 I tried, only these 5 survived, each saving 30+ minutes per run.