Refactoring
Changing structure without changing behaviour: extract, rename, simplify, remove dead code.
Download all 20
- Apply a design pattern where it removes complexity
Finds the complexity a design pattern would actually remove, such as a growing switch or tangled construction, applies it with identical behaviour, or says no pattern fits.
- Convert callbacks to async/await
Converts callback-style and promise-chain code to async/await across a module or repo without changing behaviour, keeping error handling, ordering and concurrency, with tests run before and after.
- Decouple code for testability
Breaks hard-wired dependencies such as clocks, network calls, globals and singletons behind seams so a class or module can be unit tested, keeping behaviour and public callers unchanged.
- Extract configuration from code
Finds hard-coded URLs, limits, credentials and feature switches, moves them into typed configuration with defaults and validation, and updates usages and docs without committing secrets.
- Extract a module
Moves one responsibility out of a large file or class into its own module in small, test-verified steps, without changing behaviour or the public API. Use when a file does too many things.
- Enable a lint rule and fix every violation
Enables a new lint or formatter rule and fixes its violations across a repository in small commits, keeping mechanical fixes apart from risky ones. Use when adopting a rule on an existing codebase.
- Improve naming in code
Proposes clearer names for variables, functions, types and modules, explains each rename and applies them without changing behaviour. Use when code reads poorly because of its names.
- Legacy code steward
Acts as an engineer who looks after old, business-critical code, understanding before changing, pinning behaviour with characterisation tests and shipping tiny safe changes. Use on inherited systems.
- Legacy codebase takeover track
Takes over an unfamiliar legacy codebase in gated steps, from building and running it to mapping risks, pinning behaviour with tests, a first small change and takeover notes.
- Plan a large refactor in safe steps
Turns a large refactor into small, independently shippable steps that keep the build green, each with a rollback, using patterns like expand-contract. Use for refactors too big for one PR.
- Reduce code duplication
Finds duplicated logic, separates true duplication from code that only looks alike, and merges only true duplicates behind one well-named function. Use when one fix keeps landing in many places.
- Refactoring specialist
Acts as a refactoring specialist who improves existing code in small behaviour-preserving steps, pins behaviour with tests first and stops when the code is clear enough for the next change.
- Remove dead code safely
Finds unused code, flags, endpoints, jobs and dependencies, proves each dead with static and runtime evidence, and removes it or stages a reversible retirement. Use to shrink a codebase.
- Remove stale feature flags safely
Finds feature flags that are fully rolled out or dead, removes each flag and its losing branch with tests passing, and leaves a cleanup list for the flag service. Use to pay down flag debt.
- Replace loose types with precise ones
Replaces any, unknown casts, stringly typed values and optional-field bags in a module with precise types and discriminated unions, and shows which bugs the compiler now catches.
- Restructure a firmware superloop
Restructures a tangled single-loop firmware sketch full of globals and delays into non-blocking state machines and modules, keeping behaviour and timing the same, one step at a time.
- Simplify a complex function
Rewrites a hard-to-follow function into a clearer one with identical behaviour, using guard clauses, named steps and simpler conditions, verified by tests. Use on long or deeply nested code.
- Plan splitting a large module
Maps the responsibilities and internal dependencies of an oversized file or class and plans its split into cohesive modules, in small steps that keep tests green. Use before breaking up a god class.
- Tidy a research script
Restructures a long analysis script written by a researcher into functions, configuration and a clear entry point without changing results, and checks outputs match before and after.
- Untangle circular dependencies
Finds circular dependencies between modules and plans breaking each cycle with interfaces, inversion or extraction in safe steps. Use when import cycles cause build errors or tangled code.
Not: version or framework upgrades (migration); speed-ups (performance).