refactor
하는 일
이 도구는 코드를 정리하고 개선하도록 돕습니다. 무엇을 바꾸고 싶은지 이해하고, 코드가 어떻게 연결되어 있는지 분석한 뒤, 오류를 피하도록 변경을 안전하게 계획합니다.
사용하는 경우
- ✓복잡한 코드를 단순하게 만들고 싶을 때.
- ✓코드의 일부를 새 모듈로 분리해야 할 때.
- ✓오래된 프로젝트를 현대화하거나 구조를 다시 짜고 싶을 때.
스킬 링크
https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/refactor/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“로그인 함수를 새 인증 방식을 사용하도록 리팩터링해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 먼저 요청을 이해하고 모든 코드를 분석해 각 부분이 어떻게 연결되는지 봅니다. 그다음 자세한 계획을 세우고, 모든 것이 여전히 작동하는지 확인하면서 한 단계씩 변경합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
export const REFACTOR_TEMPLATE = `# Intelligent Refactor Command
Usage
``` /refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]
Arguments: refactoring-target: What to refactor. Can be: - File path: src/auth/handler.ts - Symbol name: "AuthService class" - Pattern: "all functions using deprecated API" - Description: "extract validation logic into separate module"
Options: --scope: Refactoring scope (default: module) - file: Single file only - module: Module/directory scope - project: Entire codebase
--strategy: Risk tolerance (default: safe) - safe: Conservative, maximum test coverage required - aggressive: Allow broader changes with adequate coverage ```
What This Command Does
Performs intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:
- Understands your intent - Analyzes what you actually want to achieve
- Maps the codebase - Builds a definitive codemap before touching anything
- Assesses risk - Evaluates test coverage and determines verification strategy
- Plans meticulously - Creates a detailed plan with Plan agent
- Executes precisely - Step-by-step refactoring with LSP and AST-grep
- Verifies constantly - Runs tests after each change to ensure zero regression
PHASE 0: INTENT GATE (MANDATORY FIRST STEP)
BEFORE ANY ACTION, classify and validate the request.
Step 0.1: Parse Request Type
| Signal | Classification | Action |
|---|---|---|
| Specific file/symbol | Explicit | Proceed to codebase analysis |
| "Refactor X to Y" | Clear transformation | Proceed to codebase analysis |
| "Improve", "Clean up" | Open-ended | MUST ask: "What specific improvement?" |
| Ambiguous scope | Uncertain | MUST ask: "Which modules/files?" |
| Missing context | Incomplete | MUST ask: "What's the desired outcome?" |
Step 0.2: Validate Understanding
Before proceeding, confirm:
- Target is clearly identified
- Desired outcome is understood
- Scope is defined (file/module/project)
- Success criteria can be articulated
If ANY of above is unclear, ASK CLARIFYING QUESTION:
``` I want to make sure I understand the refactoring goal correctly.
What I understood: [interpretation] What I'm unsure about: [specific ambiguity]
Options I see:
- [Option A] - [implications]
- [Option B] - [implications]
My recommendation: [suggestion with reasoning]
Should I proceed with [recommendation], or would you prefer differently? ```
Step 0.3: Create Initial Todos
IMMEDIATELY after understanding the request, create todos:
``` TodoWrite([ {"id": "phase-1", "content": "PHASE 1: Codebase Analysis - launch parallel explore agents", "status": "pending", "priority": "high"}, {"id": "phase-2", "content": "PHASE 2: Build Codemap - map dependencies and impact zones", "status": "pending", "priority": "high"}, {"id": "phase-3", "content": "PHASE 3: Test Assessment - analyze test coverage and verification strategy", "status": "pending", "priority": "high"}, {"id": "phase-4", "content": "PHASE 4: Plan Generation - invoke Plan agent for detailed refactoring plan", "status": "pending", "priority": "high"}, {"id": "phase-5", "content": "PHASE 5: Execute Refactoring - step-by-step with continuous verification", "status": "pending", "priority": "high"}, {"id": "phase-6", "content": "PHASE 6: Final Verification - full test suite and regression check", "status": "pending", "priority": "high"} ]) ```
PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)
Mark phase-1 as in_progress.
1.1: Launch Parallel Explore Agents (BACKGROUND)
Fire ALL of these simultaneously using `call_omo_agent`:
``` // Agent 1: Find the refactoring target call_omo_agent( subagent_type="explore", run_in_background=true, prompt="Find all occurrences and definitions of [TARGET]. Report: file paths, line numbers, usage patterns." )
// Agent 2: Find related code call_omo_agent( subagent_type="explore", run_in_background=true, prompt="Find all code that imports, uses, or depends on [TARGET]. Report: dependency chains, import graphs." )
// Agent 3: Find similar patterns call_omo_agent( subagent_type="explore", run_in_background=true, prompt="Find similar code patterns to [TARGET] in the codebase.
…
자주 묻는 질문
‘리팩터링’은 무슨 뜻인가요?
기존 코드가 하는 일은 그대로 두고, 더 깔끔하고 효율적이거나 이해하기 쉽도록 코드를 다시 정리하는 것을 말합니다.
AI는 어떻게 아무것도 망가뜨리지 않도록 하나요?
기존 테스트 범위를 분석하고, 작은 변경을 할 때마다 테스트를 실행해 기존 기능이 깨지지 않았는지(회귀) 확인합니다.
파일 전체를 리팩터링할지, 일부만 할지 정할 수 있나요?
네, 단일 파일, 모듈(디렉터리), 또는 전체 프로젝트 중 어디를 대상으로 할지 지정할 수 있습니다.
상세 정보
작성자의 원본 설명
Guides a refactor, cleanup, or restructure with the right decomposition. Use when the user asks to refactor, simplify, extract, or modernize code.
인기도
- GitHub 스타
- 70k
- 순위
- #3137
- 라이선스
- NOASSERTION
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
comment-checker
70k에이전트가 자동 댓글 검사기의 피드백을 이해하고 응답하도록 돕습니다. 자동화된 코드나 콘텐츠 검토 결과를 처리하는 데 유용합니다.
lcx-contribute-bug-fix
70k에이전트가 LazyCodex 관련 프로젝트에 버그 수정을 기여하도록 이슈나 PR을 만들어 코드 품질을 높이도록 돕습니다.
lcx-doctor
70k에이전트가 LazyCodex와 Codex CLI 설치 상태를 점검하도록 돕습니다. 업데이트나 변경 후 시스템이 이상하게 동작할 때 유용합니다.
lcx-report-bug
70k에이전트가 LazyCodex 프로젝트의 버그를 자세히 보고하도록 돕습니다. 개발자가 문제를 고칠 수 있도록 유용한 정보를 담은 이슈를 만듭니다.