.cursor/skills/refactoring/SKILL.md
Improve code structure without changing behavior. Use when refactoring, cleaning up, optimizing, simplifying, extracting methods, or reducing complexity. Requires tests BEFORE refactoring, small steps, commit after each green test.
npx skillsauth add dmitryprg-ai/cursor-develop-autorules refactoringInstall 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.
Principle: CHANGE STRUCTURE, NOT BEHAVIOR.
If behavior changes, it's NOT refactoring -- it's a feature or bugfix.
| Refactor When | Do NOT When | |---------------|-------------| | Code works but hard to understand | Code doesn't work yet | | Duplicated code | No tests exist | | Long methods (> 50 lines) | Under time pressure | | Deep nesting (> 3 levels) | "Just because" |
1. VERIFY -> All tests pass
2. IDENTIFY -> What to refactor
3. PREPLAN -> Check file size limits (standard-file-size-limits rule)
4. PLAN -> Small steps
5. EXECUTE -> One step
6. TEST -> Tests after step
7. COMMIT -> Commit if green
8. REPEAT -> Next step
| Code Smell | Refactoring | |------------|-------------| | Long Method (> 50 lines) | Extract Method | | Duplicate Code | Extract Method/Class | | Long Parameter List (> 4) | Parameter Object | | Deep Nesting (> 3 levels) | Guard Clauses | | Magic Numbers | Extract Constant |
development
Scan codebase for technical debt and fix safely with TDD. Use to find oversized files, duplicated code, code smells, and refactor safely. Workflow - SCAN, TEST CASES, REFACTOR, VERIFY. Keywords - techdebt, tech debt, duplicates, code quality audit.
development
Test-Driven Development workflow with strict Red-Green-Refactor cycle. Use when developing features with TDD, writing tests before code, or when test-driven approach is needed. MANDATORY order - test cases table BEFORE code, failing tests BEFORE implementation.
testing
Review work session quality and capture improvements. Use at end of session, after large tasks, after series of errors, or when user asks for session review, retrospective, lessons learned. Records improvements to backlog.
data-ai
Analyze data, investigate datasets, work with CSV/parquet/pandas/dataframes. Use when analyzing data, exploring datasets, running experiments, or when user mentions data, analysis, parquet, csv, pandas, dataframe, statistics, investigation.