원클릭으로
refactor
Use when code smells are identified and tests or specs exist to refactor without changing behavior.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when code smells are identified and tests or specs exist to refactor without changing behavior.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when Ground Truth alignment finds memory contamination and the user explicitly requests scoped cleanup with /cleanse.
Use when registering, reviewing, merging, or rebuilding HXSK glossary term definitions after glossary-detect suggests a candidate or the user invokes /define.
Use when staged changes exist requiring qlty checks, logical split detection, or HXSK phase-scoped conventional commit creation.
Use when validating code for circular imports, layer violations, or design doc logic errors before merging architecture-level changes.
Use when .hxsk/.bootstrap-version is missing (fresh install) or exists (verify/update) to initialize HExoskeleton.
Use when shell scripts need linting/formatting before execution or commit to ensure code quality.
| allowed-tools | ["Read","Edit","Grep","Glob","Bash"] |
| description | Use when code smells are identified and tests or specs exist to refactor without changing behavior. |
| name | refactor |
| trigger | 리팩토링, 코드 정리, 함수 분리, 코드 스멜 제거, refactor, extract method, rename, simplify, long method, duplicated code, god object, feature envy, magic number, nested conditionals, dead code, guard clause, introduce constant, parameter object, code smell fix, 테스트 기반 리팩토링, 안전 리팩토링, refactoring workflow, extract function, remove duplication, clean code, 코드 개선, 구조 개선, primitive obsession, inappropriate intimacy, single responsibility, 동작 보존, 증분 리팩토링, 코드 중첩 제거, 마직넘버, 상수 추출, 파라미터 객체, 캡슐화 개선, 위임 패턴, 책임 분리, 긴 함수 분리, 중복 로직 제거, 신비한 숫자, 중첩 조건문 평탄화, 사각지대 코드 삭제, 테스트 없는 리팩토링 금지, 코드 냄새 고치기, 리팩토링 가이드, refactoring rules, code smell catalog, extract method pattern, guard clause pattern, introduce parameter object, remove dead code, simplify logic, improve readability, code hygiene, refactoring checklist, safe refactoring, incremental refactoring, behavior preservation, test driven refactoring, TDR, 리팩토링 전략, 코드 리팩토링 단계, 리팩토링 원칙, 코드 구조 최적화, 함수 추출, 조건문 단순화, 상수화, 도메인 타입 도입, 값 객체, delegation, encapsulation, refactoring steps, how to refactor, fix code smell, clean up code, organize code, refactor code, improve code structure, reduce complexity, simplify code logic, remove code duplication, handle long method, fix god object, resolve feature envy, eliminate primitive obsession, fix inappropriate intimacy, remove magic values, flatten nested ifs, delete unused code, introduce constants, group parameters, split responsibilities, code refactoring best practices, refactoring without breaking, safe code changes, step by step refactoring, code smell removal, technical debt reduction, code optimization, software craftsmanship, refactoring techniques, refactoring patterns, refactoring guide, refactoring tips, code refactoring tutorial, how to clean code, code refactoring examples, refactoring workflow steps, refactoring process, refactoring methodology, refactoring approach, refactoring strategy, refactoring plan, refactoring checklist items, refactoring rules of thumb, refactoring dos and donts, refactoring pitfalls, refactoring benefits, refactoring importance, refactoring necessity, refactoring urgency, refactoring priority, refactoring focus, refactoring scope, refactoring context, refactoring environment, refactoring tools, refactoring support, refactoring assistance, refactoring help, refactoring advice, refactoring consultation, refactoring review, refactoring feedback, refactoring critique, refactoring analysis, refactoring assessment, refactoring evaluation, refactoring measurement, refactoring metrics, refactoring quality, refactoring standards, refactoring guidelines, refactoring principles, refactoring philosophy, refactoring culture, refactoring mindset, refactoring attitude, refactoring habit, refactoring practice, refactoring routine, refactoring discipline, refactoring commitment, refactoring dedication, refactoring passion, refactoring enthusiasm, refactoring motivation, refactoring inspiration, refactoring creativity, refactoring innovation, refactoring evolution, refactoring revolution, refactoring transformation, refactoring metamorphosis, refactoring rebirth, refactoring renewal, refactoring regeneration, refactoring restoration, refactoring recovery, refactoring rescue, refactoring salvation, refactoring redemption, refactoring liberation, refactoring freedom, refactoring independence, refactoring autonomy, refactoring sovereignty, refactoring authority, refactoring power, refactoring strength, refactoring might, refactoring force, refactoring energy, refactoring vitality, refactoring vigor, refactoring stamina, refactoring endurance, refactoring resilience, refactoring robustness, refactoring durability, refactoring longevity, refactoring sustainability, refactoring maintainability, refactoring extensibility, refactoring scalability, refactoring portability, refactoring interoperability, refactoring compatibility, refactoring consistency, refactoring coherence, refactoring cohesion, refactoring coupling, refactoring modularity, refactoring granularity, refactoring abstraction, refactoring generalization, refactoring specialization, refactoring polymorphism, refactoring inheritance, refactoring composition, refactoring aggregation, refactoring association, refactoring dependency, refactoring relationship, refactoring interaction, refactoring communication, refactoring collaboration, refactoring cooperation, refactoring teamwork, refactoring synergy, refactoring harmony, refactoring balance, refactoring equilibrium, refactoring stability, refactoring security, refactoring reliability, refactoring availability, refactoring performance, refactoring efficiency, refactoring effectiveness, refactoring productivity, refactoring quality, refactoring value, refactoring benefit, refactoring advantage, refactoring gain, refactoring profit, refactoring return, refactoring yield, refactoring output, refactoring result, refactoring outcome, refactoring consequence, refactoring effect, refactoring impact, refactoring influence, refactoring significance, refactoring importance, refactoring relevance, refactoring pertinence, refactoring applicability, refactoring suitability, refactoring appropriateness, refactoring feasibility, refactoring viability, refactoring possibility, refactoring probability, refactoring likelihood, refactoring chance, refactoring opportunity, refactoring potential, refactoring capacity, refactoring capability, refactoring competence, refactoring proficiency, refactoring expertise, refactoring mastery, refactoring excellence, refactoring perfection, refactoring optimization, refactoring refinement, refactoring improvement, refactoring enhancement, refactoring upgrade, refactoring update, refactoring revision, refactoring modification, refactoring alteration, refactoring adjustment, refactoring correction, refactoring amendment, refactoring rectification, refactoring remedy, refactoring solution, refactoring fix, refactoring repair, refactoring restoration, refactoring recovery, refactoring rehabilitation, refactoring rejuvenation, refactoring revitalization, refactoring reinvigoration, refactoring reanimation, refactoring resurrection, refactoring revival, refactoring renewal, refactoring regeneration, refactoring rebirth, refactoring reincarnation, refactoring metamorphosis, refactoring transformation, refactoring evolution, refactoring revolution, refactoring reformation, refactoring reconstruction, refactoring reorganization, refactoring restructuring, refactoring reengineering, refactoring redesign, refactoring redevelopment, refactoring reimplement, refactoring rewrite, refactoring refactor, refactoring refactorize, refactoring refactorization, refactoring refactorment, refactoring refactoringness, refactoring refactoringnesses, refactoring refactoringnesses, refactoring refactoringnesses, refactoring refactoringnesses |
Before refactoring:
테스트 확인
# 테스트 존재 여부 확인
find . -name "*.test.*" -o -name "*_test.*" -o -name "*spec*" | head -10
테스트 없으면 동작 명세를 먼저 작성하거나 사용자에게 확인.
브랜치 생성
git checkout -b refactor/{describe-smell}
현재 상태 커밋 — commit 스킬 패턴으로 안전 기점 확보
| 스멜 | 신호 | 해결 방향 |
|---|---|---|
| Long method | 함수 40줄+ | 책임별 Extract Method |
| Duplicated logic | 유사 블록 3회+ | 공통 함수 추출 |
| God object | 클래스 10+ 메서드 | Single Responsibility로 분리 |
| Excessive parameters | 파라미터 4개+ | 파라미터 객체로 그룹화 |
| Feature envy | A가 B의 데이터를 자주 사용 | 로직을 B로 이동 |
| Primitive obsession | 원시 타입 남용 | 도메인 타입/값 객체 도입 |
| Magic values | 의미없는 숫자/문자열 | 상수/enum으로 교체 |
| Nested conditionals | if 3단계+ 중첩 | Guard clause로 평탄화 |
| Dead code | 미호출 함수/변수 | 완전 삭제 |
| Inappropriate intimacy | 과도한 내부 접근 | 위임(delegation)으로 캡슐화 |
PICK ONE — 이번 세션에서 처리할 스멜 하나만 선택한다.
Extract Method (Long method 해결):
긴 함수 → 의도를 드러내는 이름의 작은 함수들로 분리
변경 전: one_big_function() { step1; step2; step3; }
변경 후: handle_request() { validate(); process(); respond(); }
Guard Clause (Nested conditionals 해결):
중첩 if → 조기 반환으로 평탄화
변경 전: if (ok) { if (valid) { if (auth) { ... }}}
변경 후: if (!ok) return; if (!valid) return; if (!auth) return; ...
Introduce Named Constant (Magic values 해결):
변경 전: if (status == 3) { ... }
변경 후: MAX_RETRY = 3; if (status == MAX_RETRY) { ... }
각 기법 적용 후:
# 테스트 실행
<test command>
# 통과하면 커밋
git add -A && git commit -m "refactor: <what changed>"
empirical-validation 스킬로 최종 검증:
git diff main -- *.d.ts 또는 API 명세 확인)commit — 각 안전 상태 커밋 프로토콜clean — shellcheck/shfmt 코드 품질 (shell scripts)verifier — 구현 완료 후 전체 검증empirical-validation — 경험적 검증 (테스트 실행 + 결과 확인)NO REFACTOR WITHOUT TEST OR SPEC FIRST NO MULTI-SMELL REFACTOR WITHOUT SINGLE-FOCUS FIRST NO COMMIT WITHOUT TEST PASS FIRST NO BEHAVIOR CHANGE WITHOUT INTERFACE PRESERVATION FIRST NO NEXT STEP WITHOUT EMPIRICAL VALIDATION FIRST