Code revamp
For refactors and migrations that touch several files. Behaviour must not change except where the request says so.
- Map the blast radius before you edit. Search for every use of what you are changing: imports, calls, string references,
__all__ and re-exports, scripts and CLI entry points, README and docs examples, tests. Name the processes that run it (web, worker, scheduler), how many run at once, and each store, cache or queue it writes and who else reads it. Read the language and framework versions the code runs from its manifests and lockfiles, and use only the APIs that version has.
- Pin today's behaviour with tests (write them if they are missing) before you touch the code. Use production-shaped inputs and types (a money value can arrive as the string "0.01"), and cover the edge cases a refactor breaks: empty, null, duplicate, boundary. Walk the scenarios in the shared bar section 3 for each caller and version that can reach the change, including a job queued before the deploy; name any path left untested. Revamp-only cases (mock targets, serialized names):
reference.md.
- Work in small slices that each leave the tests green. Put the new shape next to the old one (alias, shim, wrapper, deprecation warning), move callers one at a time, and remove the old path only if the request says to. Queued jobs, caches and other services still send the old names and shapes, so keep the old path until they have drained.
- Keep old import paths and signatures working unless told otherwise. Warn with the right category, once per call, not once per item.
- Search again for the old name when you finish; run the full tests and the code in the README. For a change to types, formats or ordering, diff the old and new output on a copy of production data. A green suite does not catch a string that became a number.
- Do not mix refactoring with new behaviour, and do not tidy code you were not asked to touch.
- Touching locks, transactions or ordering? Run the same concurrent cases before and after the change.
A revamp needs a concrete harm to justify it; a local fix is better when one will do. Migration patterns (strangler fig, module extraction, interface introduction), the risk matrix and the rollback checklist: read reference.md in this folder.
Shared bar: ../../references/checklists/engineering-quality-bar.md.
Inheriting a legacy style
When new code must match a hand-written codebase, extract its unwritten rules first instead of imposing your own:
- Size the repo (count source files) and pick the depth: under ~50 files read closely; 50-500 read the infrastructure layer fully and sample 2-3 files per dimension in the business layer; above ~500 sample strictly from a
git diff --stat or tree summary.
- Scan four dimensions: in-file declaration order, naming of state/async/pagination/flags, where cross-cutting code lives (middleware, formatters, interceptors), and error handling (try/catch, global handler, result types, null checks).
- A tiny minority (under ~5% and fewer than ~10 occurrences) is noise: the majority wins and the minority goes on the DONT list. In a small project, "3 vs 2" is not a majority; ask.
- Resolve real conflicts with the user one question at a time, citing a file for each side, with options: follow A, follow B, the project is evolving, or give a new rule.
- Record the result as golden-file exemplars (path plus what each shows), checkable naming and control-flow rules, and DONTs. Date the file and append later changes as a log; never overwrite old rules.
- Before writing code, name the exemplar you follow and the DONTs you avoid. Reuse the exemplar's structure, not its bugs; flag defects instead of copying them. Ask before adding any enforcing hook.
Adapted in part from ECC skills/inherit-legacy-style (affaan-m/ECC, MIT).
1---2name: bosskuai-code-revamp3description: "Use when revamping legacy code safely: modernization, structural cleanup, and refactors that respect the current codebase structure and avoid unnecessary churn."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-code-revamp6---78# Code revamp910For refactors and migrations that touch several files. Behaviour must not change except where the request says so.11121. **Map the blast radius before you edit.** Search for every use of what you are changing: imports, calls, string references, `__all__` and re-exports, scripts and CLI entry points, README and docs examples, tests. Name the processes that run it (web, worker, scheduler), how many run at once, and each store, cache or queue it writes and who else reads it. Read the language and framework versions the code runs from its manifests and lockfiles, and use only the APIs that version has.132. **Pin today's behaviour** with tests (write them if they are missing) before you touch the code. Use production-shaped inputs and types (a money value can arrive as the string "0.01"), and cover the edge cases a refactor breaks: empty, null, duplicate, boundary. Walk the scenarios in the shared bar section 3 for each caller and version that can reach the change, including a job queued before the deploy; name any path left untested. Revamp-only cases (mock targets, serialized names): `reference.md`.143. **Work in small slices that each leave the tests green.** Put the new shape next to the old one (alias, shim, wrapper, deprecation warning), move callers one at a time, and remove the old path only if the request says to. Queued jobs, caches and other services still send the old names and shapes, so keep the old path until they have drained.154. **Keep old import paths and signatures working** unless told otherwise. Warn with the right category, once per call, not once per item.165. **Search again for the old name** when you finish; run the full tests and the code in the README. For a change to types, formats or ordering, diff the old and new output on a copy of production data. A green suite does not catch a string that became a number.176. **Do not mix refactoring with new behaviour,** and do not tidy code you were not asked to touch.187. **Touching locks, transactions or ordering?** Run the same concurrent cases before and after the change.1920A revamp needs a concrete harm to justify it; a local fix is better when one will do. Migration patterns (strangler fig, module extraction, interface introduction), the risk matrix and the rollback checklist: read `reference.md` in this folder.2122Shared bar: `../../references/checklists/engineering-quality-bar.md`.2324## Inheriting a legacy style25When new code must match a hand-written codebase, extract its unwritten rules first instead of imposing your own:26- Size the repo (count source files) and pick the depth: under ~50 files read closely; 50-500 read the infrastructure layer fully and sample 2-3 files per dimension in the business layer; above ~500 sample strictly from a `git diff --stat` or tree summary.27- Scan four dimensions: in-file declaration order, naming of state/async/pagination/flags, where cross-cutting code lives (middleware, formatters, interceptors), and error handling (try/catch, global handler, result types, null checks).28- A tiny minority (under ~5% and fewer than ~10 occurrences) is noise: the majority wins and the minority goes on the DONT list. In a small project, "3 vs 2" is not a majority; ask.29- Resolve real conflicts with the user one question at a time, citing a file for each side, with options: follow A, follow B, the project is evolving, or give a new rule.30- Record the result as golden-file exemplars (path plus what each shows), checkable naming and control-flow rules, and DONTs. Date the file and append later changes as a log; never overwrite old rules.31- Before writing code, name the exemplar you follow and the DONTs you avoid. Reuse the exemplar's structure, not its bugs; flag defects instead of copying them. Ask before adding any enforcing hook.3233Adapted in part from ECC skills/inherit-legacy-style (affaan-m/ECC, MIT).