skills/refactor/SKILL.md
Large-scale code refactoring and transformation.
npx skillsauth add arbazkhan971/godmode refactorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
/godmode:refactor, "refactor this", "clean up"find . -name "*.ts" -o -name "*.js" -o -name "*.py" \
| xargs wc -l | sort -rn | head -20
grep -rn "<pattern>" --include="*.ts" --include="*.js"
Target: <file or module>
Lines: <N> | Complexity: <cyclomatic> | Coverage: <N%>
Dependents: <N files> | Risk: LOW|MEDIUM|HIGH|CRITICAL
Risk levels:
IF coverage < 60%: write characterization tests first. IF dependents > 30: use strangler pattern migration.
Extract (Function, Class, Interface, Module, Variable, Parameter), Inline (Function, Variable), Move (Function, Field), Rename (Symbol, File), Simplify (Conditional, Loop, Guard Clause), Replace (Inheritance with Composition, Conditional with Polymorphism).
grep -rl "<symbol>" --include="*.ts" --include="*.js"
Map directly affected (modified), indirectly affected (imports changed), and not affected files.
npm test 2>&1 | tail -10
npx jest --testPathPattern="<target>" 2>&1
IF coverage < 60%: STOP, write characterization tests, commit them separately, then proceed.
One transformation per commit. For each step:
"refactor: <pattern> -- <desc>"IF tests fail after transformation: revert first, then diagnose. Never debug forward.
Strangler pattern: create new alongside old, migrate dependents one at a time, each migration = separate commit, remove old code only after zero references.
IF >5 dependents: phase the migration over multiple PRs.
npm test
Compare: test count same or higher, coverage same or higher, no behavior change. Report pattern used, commits, files modified/created/deleted.
Cyclomatic: <= 10/function (eslint, radon, gocyclo)
Cognitive: <= 15/function (SonarQube, eslint sonarjs)
LOC: <= 50/function (wc -l)
Append .godmode/refactor.tsv:
timestamp target pattern tests_before tests_after coverage_before coverage_after status
KEEP if: tests pass AND complexity reduced
AND coverage maintained or increased.
DISCARD if: tests fail OR complexity unchanged
OR coverage dropped.
STOP when FIRST of:
- All targets below thresholds
(cyclomatic <= 10, cognitive <= 15)
- Test count and coverage same or higher
- Zero dead code detected
On failure: git reset --hard HEAD~1. Never pause.
<!-- tier-3 -->| Failure | Action | |--|--| | Tests fail after transform | Revert, plan smaller step | | Coverage decreases | Write tests before continuing | | Circular dependency | Extract shared into new module |
development
Web performance optimization. Lighthouse, bundle analysis, code splitting, image optimization, critical CSS, fonts, service workers, CDN.
development
Webhook design, delivery, retry, HMAC verification, event subscriptions, dead letter queues.
development
Vue.js mastery. Composition API, Pinia, Vue Router, Nuxt SSR/SSG, Vite optimization, testing.
development
Evidence gate. Run command, read full output, confirm or deny claim. No trust, only proof.