Token导航 LogoToken导航

Agent Skill · 研究检索

code-refactoring(代码重构)

code-refactoring 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

code-refactoring 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为可写文件;许可证信息还不明确,第三方扫描有未通过项,按安装量在研究检索类的 73,675 个 Skill 里排第 70,604。

总安装 210周安装 9GitHub Stars 8下载 73核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:code-refactoring(代码重构)
来源仓库:https://github.com/womendefiningai/claude-code-skills
仓库路径:skills/code-refactoring
安装命令:
npx skills add https://github.com/womendefiningai/claude-code-skills --skill code-refactoring
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/womendefiningai/claude-code-skills --skill code-refactoring

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

code-refactoring 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。它可结合来源仓库、安装命令和原始 README 继续核验具体用法。

安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

安装命令:npx skills add https://github.com/womendefiningai/claude-code-skills --skill code-refactoring 来源仓库:https://github.com/womendefiningai/claude-code-skills

来源仓库内路径:skills/code-refactoring

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/womendefiningai/claude-code-skills --skill cod…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要可写文件,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

code-refactoring 怎么安装?

在终端执行 npx skills add https://github.com/womendefiningai/claude-code-skills --skill code-refactor…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

code-refactoring 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

code-refactoring 需要什么权限?

权限级别是可写文件。该 Skill 可能写入或修改本地文件,使用前需要确认目标目录和修改范围。

code-refactoring 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

code-refactoring 用的人多吗?

公开数据是累计安装 210 次,近一周安装 9 次,下载 73 次,GitHub 8 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

code-refactoring 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
code-refactoring

代码重构 · 本页

2108可写文件未明确未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Code Refactoring Skill

🎯 Purpose: Prevent Complexity Before It Becomes a Problem

Problem this solves: "I rarely know when to refactor, typically get caught by accident"

Solution: AI proactively monitors file sizes and complexity patterns, alerting you BEFORE making changes that would worsen the problem.

Works with: JavaScript/TypeScript (React, Node), Python, and general codebases.

🔔 CRITICAL FIRST STEP: Check for File Watcher Alerts

BEFORE doing anything else when this skill is invoked, ALWAYS check for unread alerts from the background file watcher:

node ~/.claude/plugins/marketplaces/custom-skills/code-refactoring/scripts/check-alerts.js

Why this is critical:

  • The file watcher runs in the background monitoring code file sizes
  • It writes alerts to watcher-alerts.json when files are edited and exceed thresholds
  • These alerts tell you which files the user just edited that need refactoring attention
  • You must check these alerts FIRST to provide real-time feedback

If alerts exist:

  1. Display the alerts using the check-alerts.js script output
  2. Ask the user if they want help refactoring the alerted files NOW or LATER
  3. Then proceed with the rest of the skill workflow

If no alerts:

  • Continue with normal skill workflow (checking file sizes manually, etc.)

User can also manually check alerts with: /check-refactor-alerts


🤖 AUTO-INVOKE CONDITIONS (AI Should Check These)

1. Before Editing Files (PREVENTIVE)

When AI is about to edit a file, check size first:

# Check file size before editing
wc -l [target-file]

# If result:
# 150-200 lines → ⚠️ WARN: Getting large, plan extraction
# 200-300 lines → 🚨 ALERT: Should split before adding more
# 300+ lines   → 🛑 STOP: Must refactor before editing

Example workflow:

User: "Add new feature to UserProfile.tsx"
AI: *Before editing, checks file size*
AI: *Sees 280 lines*
AI: *Auto-invokes code-refactoring skill*
Skill: "🚨 UserProfile.tsx is 280 lines. Before adding features:
       - Extract data to separate file
       - Split modal into separate component
       - Then add new feature safely"

2. During File Creation (PROACTIVE)

While creating new code file, track size:

  • At 100 lines → ✅ Good, continue
  • At 150 lines → ⚠️ Pause, suggest structure
  • At 200 lines → 🚨 Stop, extract now

Example workflow:

AI: *Creating new DashboardService.py*
AI: *Reaches 150 lines*
AI: *Auto-invokes code-refactoring skill*
Skill: "⚠️ File reached 150 lines. Before continuing:
       1. Extract data/config to constants file
       2. Move helper functions to utils module
       3. Continue with cleaner structure"

3. After Reading Files (REACTIVE)

When AI reads a file and discovers size issues:

# After reading, if file >300 lines, suggest refactor
wc -l filename

# If >300 lines, proactively suggest refactor BEFORE user asks for changes

Example workflow:

User: "Take a look at the analytics module"
AI: *Reads analytics.py*
AI: *Sees 450 lines*
AI: *Auto-invokes code-refactoring skill*
Skill: "🛑 analytics.py is 450 lines (150 lines over limit).

       Refactor plan:
       1. Extract constants to analytics_config.py (50 lines)
       2. Create AnalyticsChart class (100 lines)
       3. Create AnalyticsProcessor class (120 lines)
       4. Keep Analytics as orchestrator (180 lines)

       Should I proceed with refactoring before making other changes?"

4. Pattern Detection (AUTOMATIC)

AI should automatically detect these patterns and invoke skill:

Universal Patterns (All Languages)
  • ✅ Large data structures (>20 lines) → Suggest separate config/data file
  • ✅ Complex conditionals (5+ branches) → Suggest strategy pattern or dispatch table
  • ✅ Deeply nested logic (>3 levels) → Suggest extraction
  • ✅ Repeated code blocks → Suggest function/method extraction
  • ✅ Long parameter lists (>5 params) → Suggest config object or builder pattern
JavaScript/TypeScript/React Patterns
  • ✅ 5+ data items hardcoded → Suggest data file extraction
  • ✅ 4+ useState/useEffect hooks → Suggest custom hook extraction
  • ✅ Modal/Dialog code → Suggest separate component
  • ✅ Complex form (10+ fields) → Suggest separate form component
  • ✅ Large switch statements → Suggest lookup table or component map
Python Patterns
  • ✅ Class >300 lines → Suggest splitting into multiple classes
  • ✅ Function >50 lines → Suggest breaking into smaller functions
  • ✅ Module >500 lines → Suggest splitting into package
  • ✅ Too many methods (>15) → Suggest composition or mixins
  • ✅ Complex init (>20 lines) → Suggest factory method or builder

📏 File Size Guidelines (Language-Specific)

JavaScript/TypeScript/React Components

  • 100-200 lines: ✅ Perfect for most components
  • 200-300 lines: ⚠️ Good for complex components, watch closely
  • 300+ lines: 🛑 MUST split into logical sub-components

Python Modules

  • 150-250 lines: ✅ Good module size
  • 250-400 lines: ⚠️ Consider splitting by responsibility
  • 400+ lines: 🛑 Split into multiple modules or package

Python Classes

  • 100-200 lines: ✅ Well-focused class
  • 200-300 lines: ⚠️ Check single responsibility principle
  • 300+ lines: 🛑 Split into multiple classes or use composition

General Files (Any Language)

  • 150-250 lines: ✅ Maintainable size
  • 250-400 lines: ⚠️ Getting complex
  • 400+ lines: 🛑 Refactor needed

🔍 Refactoring Analysis Template

When skill is invoked, provide this analysis:

## Code Refactoring Analysis: [Filename]

**Current State:** [X] lines - [✅ Good / ⚠️ Warning / 🛑 Critical]

**Identified Issues:**
- File size issues (>200 or >300 lines)
- Complex nested logic / too many responsibilities
- Language-specific patterns (hooks, data arrays, classes, etc.)

**Refactoring Recommendations:**
1. Extract [what] to [new-file] (saves [X] lines, [X] mins)
2. Extract [what] to [new-file] (saves [X] lines, [X] mins)

**Result:** Main file → [target] lines | Risk: [Low/Med/High] | Time: [X] mins

**Proceed?** [Yes/No/Later/Review]

For complete template with all fields, see FORMS.md


🚨 Automatic Splitting Triggers

When ANY of these conditions occur, AUTO-INVOKE this skill:

Universal Triggers (All Languages)

  1. ✅ File reaches 150 lines → Suggest extraction points
  2. ✅ File reaches 200 lines → Alert and plan refactor
  3. ✅ File reaches 300 lines → Stop and refactor first
  4. ✅ Complex nested logic detected
  5. ✅ Repeated code patterns found

JavaScript/TypeScript Triggers

  1. ✅ Component reaches 150 lines → Extract next section
  2. ✅ 3+ useState hooks → Extract to custom hook
  3. ✅ Large data array → Move to data file immediately
  4. ✅ Modal/Dialog code → Separate component from start
  5. ✅ Complex form → Separate form component immediately

Python Triggers

  1. ✅ Class reaches 250 lines → Plan class split
  2. ✅ Function reaches 40 lines → Suggest breaking down
  3. ✅ Module reaches 350 lines → Plan module split
  4. ✅ 10+ methods in class → Consider composition
  5. ✅ Complex init → Suggest factory pattern

📋 Quick Decision Matrix

When to extract what (Quick Reference):

JavaScript/TypeScript/React:

  • Data file: 5+ items, arrays >20 lines, config objects
  • Sub-component: Modal/dialog, complex list items, distinct UI sections
  • Custom hook: 4+ useState, complex logic, reusable state

Python:

  • Config file: 5+ variables, large data (>20 lines), magic numbers
  • New class: Class >300 lines, multiple responsibilities, 10+ methods
  • Utility function: Repeated logic, pure functions, generic operations
  • New module: File >400 lines, distinct responsibilities, testable independently

For detailed extraction patterns and examples, see REFERENCE.md


💡 Proactive Suggestions

AI should auto-suggest at these milestones:

  • New file: Monitor size, alert at 150 lines
  • 100 lines: Looking good, will alert at 150
  • 150 lines: ⚠️ Check if should extract before continuing
  • 200 lines: 🚨 Recommend refactoring now
  • Reading large file: Offer refactoring plan before changes

🔧 EXECUTION PHASE (After User Approval)

IMPORTANT: This skill can EXECUTE refactoring, not just suggest it!

Step 1: Present Plan and Get User Approval

After analyzing file size and creating refactoring plan, always ask for approval:

## Refactoring Plan Ready

**File:** [filename] ([X] lines)
**Target:** Reduce to <[target] lines

### Proposed Changes:
1. Extract [data/component/class] to [new-file] (saves [X] lines)
2. Extract [component/function] to [new-file] (saves [X] lines)
3. Extract [hook/utility] to [new-file] (saves [X] lines)

**Result:** Main file reduced to ~[X] lines
**Estimated time:** [X] minutes
**Risk level:** Low (all changes are git-committed incrementally)

### Options:

**✅ Yes** - Execute refactoring now (recommended)
  - I'll split the file step-by-step
  - Each step will be tested and committed
  - You can rollback if needed
  - Then I'll continue with your original request

**❌ No** - Skip refactoring
  - I'll continue with your edit
  - Warning: File will grow larger
  - May become harder to maintain

**⏰ Later** - Save plan for later
  - I'll save the plan to `refactoring-plan-[filename].md`
  - You can execute it manually later
  - I'll continue with your edit now

**📋 Review** - Show detailed step-by-step execution plan
  - I'll explain exactly what will happen
  - Then you can choose Yes/No/Later

**Your choice?**

Step 2: Execute Refactoring (Only if User Says "Yes")

When user approves, execute refactoring incrementally:

  1. Create backup commit (safety first)
  2. Verify starting state (lint, type-check, test must pass)
  3. Execute step-by-step (extract → verify → commit for each change)
  4. Final verification (full test suite)
  5. Rollback automatically if any step fails

Key execution principles:

  • ✅ Each step is atomic and committed separately
  • ✅ Each step is verified before proceeding
  • ✅ Automatic rollback on any failure
  • ✅ User can cancel at any time

For detailed execution procedures, safety measures, rollback procedures, and examples, see REFERENCE.md → "EXECUTION PHASE - Detailed Procedures"


Step 3: Continue With Original Request

After execution (success or skip):

Refactoring: ✅ Complete (or ⏭️ Skipped)
Original request: "[user's request]"

Now proceeding with your request...

🔄 Integration with Other Skills

Works with:

  • ui-ux-audit - Check file sizes during UI audits
  • technical-writing - Document refactored structure
  • qa-testing - Ensure tests cover refactored code

Triggers:

  • Before major edits to large files
  • During file creation
  • After reading files >200 lines
  • When detecting size/complexity patterns

🔍 CODEBASE AUDIT MODE (For Existing Technical Debt)

Use this mode when user asks to:

  • "Audit the codebase" or "find large files"
  • Check for "technical debt" or "existing problems"
  • "Scan for refactoring opportunities"
  • Review legacy/inherited codebase
  • Plan major refactoring initiative

Audit Workflow (Brief):

  1. Scan for oversized files by language/type
  2. Categorize by severity (Critical >300, High 200-300, Medium 150-200, Good <150)
  3. Prioritize using formula: (Size/100) + (Change Frequency × 2) + (Business Impact × 3)
  4. Create refactoring roadmap with time estimates
  5. Execute incrementally (one file per sprint)

Quick scan commands:

# Find oversized files by type
find src -name "*.tsx" -exec wc -l {} \; | awk '$1 > 200' | sort -rn

# Use helper script
bash scripts/check-size.sh src/ '*.tsx'

For detailed audit procedures, report templates, prioritization matrices, and batch analysis commands, see REFERENCE.md → "CODEBASE AUDIT MODE - Detailed Procedures"


📚 Language-Specific Details

For detailed refactoring patterns specific to each language, see:

  • REFERENCE.md - Comprehensive language-specific guides
  • FORMS.md - Refactoring templates and checklists

To check file size quickly:

# Use the helper script
bash ~/.claude/plugins/marketplaces/custom-skills/code-refactoring/scripts/check-size.sh [filename]

✅ Success Criteria

Refactoring is successful when:

  1. ✅ Main file within target size for language
  2. ✅ All extracted files well-organized
  3. ✅ No broken imports or references
  4. ✅ All tests pass
  5. ✅ Functionality unchanged
  6. ✅ Code more maintainable and readable
  7. ✅ Clear separation of concerns
  8. ✅ Documentation updated

Remember: Prevention > Cure

This skill prevents "caught by accident" scenarios by:

  • Checking BEFORE editing (preventive)
  • Alerting DURING creation (proactive)
  • Suggesting AFTER reading (reactive)
  • Enforcing patterns automatically

The goal: Never again discover an oversized, complex file by accident.

Multi-language support: Works across JavaScript/TypeScript, Python, and general codebases with language-specific patterns.

平台分布

Codex

34.55%
按下载量换算25

Claude

32.15%
按下载量换算23

Cursor

21.01%
按下载量换算15

Gemini CLI

9.63%
按下载量换算7

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

可写文件

该 Skill 可能写入或修改本地文件,使用前需要确认目标目录和修改范围。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills