- name
SKILL.md
ไฟล์สกิลยังคงอยู่ในรีโพซิทอรีของผู้เผยแพร่
วางคำสั่งที่คัดลอกไว้ในเทอร์มินัล คำสั่งจะติดตั้ง SKILL.md นี้ลงในเอเจนต์ตัวนั้น
npx skills add omagents/omagents --skill refactor -a cursor -yวางคำสั่งที่คัดลอกไว้ในเทอร์มินัล คำสั่งจะติดตั้ง SKILL.md นี้ลงในเอเจนต์ตัวนั้น
npx skills add omagents/omagents --skill refactor -a claude-code -yวางคำสั่งที่คัดลอกไว้ในเทอร์มินัล คำสั่งจะติดตั้ง SKILL.md นี้ลงในเอเจนต์ตัวนั้น
npx skills add omagents/omagents --skill refactor -a codex -yวางคำสั่งที่คัดลอกไว้ในเทอร์มินัล คำสั่งจะติดตั้ง SKILL.md นี้ลงในเอเจนต์ตัวนั้น
npx skills add omagents/omagents --skill refactor -a grok -yส่งข้อความที่คัดลอกไว้ในแชต Grok Bot แล้ว Bot จะดึง SKILL.md นี้จาก GitHub และเพิ่มลงในสกิลที่ Bot ทุกตัวของคุณใช้ร่วมกัน
Install this skill: https://github.com/omagents/omagents/tree/HEAD/packages/core/skills/refactorจากผู้เผยแพร่
Systematically refactor code targets one by one, with verification after each change. The loop engine tracks progress and survives context clearing.
Scan the codebase for refactoring opportunities:
# Long functions (> 50 lines)
grep -rn "def \|function \|const .* = " --include="*.py" --include="*.ts" --include="*.js" | head -50
# High complexity (deep nesting)
# Use codegraph to find complex call paths
codegraph_codegraph_explore query="complex functions with deep nesting"
# Code duplication
# Use grep to find repeated patterns
grep -rn "duplicate pattern" --include="*.py"
loop_engine.py init refactor '[
{"file": "src/auth.py", "target": "split authenticate() into validate_credentials() + create_session()", "description": "Refactor auth.py: split authenticate()"},
{"file": "src/cache.py", "target": "replace manual caching with functools.lru_cache", "description": "Refactor cache.py: use lru_cache"},
{"file": "src/utils.ts", "target": "extract duplicate validation logic into shared validator", "description": "Refactor utils.ts: extract validator"}
]'
Repeat until next returns null:
Step 1: Get next task
loop_engine.py next refactor
If output is null, go to Phase 4.
Step 2: Read and understand the target
Read the file, understand what it does currently, and plan the specific changes.
Step 3: Apply the refactoring
Use the host's edit tools to make the changes. If the active host exposes LSP rename support:
lsp tool for prepare_rename and rename operationslsp tool for findReferences to ensure all callers are updatedIf using ast-grep:
sg -p 'old_pattern' -r 'new_pattern' --lang python --update-all <file>
Step 4: Verify
# Run tests
npm test 2>/dev/null || pytest tests/ 2>/dev/null || true
# Run linter
ruff check <file> 2>/dev/null || npx eslint <file> 2>/dev/null || true
# Check LSP diagnostics if available
# Use lsp tool with diagnostics operation
Step 5: Record result
If verification passes:
loop_engine.py complete refactor <id> "Split authenticate() into 2 functions, all tests pass"
If tests fail:
loop_engine.py fail refactor <id> "test_auth.py failed after split"
loop_engine.py summary refactor
Present the summary. For blocked tasks, show what failed and suggest manual review.
Systematic code refactoring using a durable loop workflow. Each refactoring target is processed, verified, and marked complete before moving to the next. Trigger when the user says 'refactor', 'restru
---name: refactordescription: Systematic code refactoring using a durable loop workflow. Each refactoring target is processed, verified, and…---# packages/core/skills/refactor/SKILL.mdภาพรวม
Systematic code refactoring using a durable loop workflow. Each refactoring target is processed, verified, and marked complete before moving to the next. Trigger when the user says 'refactor', 'restructure code', or wants to improve code without changing behavior.
FAQ
ดาวน์โหลด packages/core/skills/refactor/SKILL.md จากผู้เผยแพร่ หรือคัดลอกพาธแล้วเปิดรีโพซิทอรี PlugMCP แสดงรายการสกิลเท่านั้น ไม่ได้โฮสต์ไฟล์
ผู้เผยแพร่เก็บไว้ที่ https://github.com/omagents/omagents
Claude, Cursor, Codex และ Grok Build อ่าน SKILL.md ที่คุณเพิ่มจากรีโพซิทอรีของผู้เผยแพร่ได้ ส่วน Grok Bot จะติดตั้งให้เมื่อคุณส่งลิงก์โฟลเดอร์ GitHub ของสกิลในแชต