Token导航 LogoToken导航

Agent Skill · 研究检索

code-refactor(代码重构)

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

code-refactor 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证为 MIT,暂无第三方扫描结果,按安装量在研究检索类的 73,675 个 Skill 里排第 61,604。

总安装 349周安装 14GitHub Stars 公开资料未说明下载 113核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

AgentSkills.tonpx skills
npx skills add zpankz/mcp-skillset --skill "code-refactor"

这个 Skill 是做什么的

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

用于查找、检索和筛选相关信息,帮助 Agent 快速定位候选结果。适合在需要根据关键词或任务场景进行信息筛选时使用。可结合来源仓库和 README 继续核验具体用法。安装前建议确认权限范围、维护状态及是否触发联网或文件读写。安装方式:github;适用宿主:Codex、Claude、Cursor、Gemini CLI。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add zpankz/mcp-skillset --skill "code-refactor";命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

code-refactor 怎么安装?

在终端执行 npx skills add zpankz/mcp-skillset --skill "code-refactor"。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

code-refactor 支持哪些 AI 工具?

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

code-refactor 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

code-refactor 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

code-refactor 用的人多吗?

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

code-refactor 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 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-refactor

代码重构 · 本页

349—调用外部服务MIT未收录

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

SKILL.md 原文

name
code-refactor
description
Perform bulk code refactoring operations like renaming variables/functions across files, replacing patterns, and updating API calls. Use when users request renaming identifiers, replacing deprecated code patterns, updating method calls, or making consistent changes across multiple locations. Activates on phrases like "rename all instances", "replace X with Y everywhere", "refactor to use", or "update all calls to".

Code Refactor

Overview

Perform systematic code refactoring operations across files using pattern-based search and replace. This skill focuses on bulk transformations that maintain code functionality while improving structure, naming, or updating APIs.

When to Use This Skill

Activate this skill when users request:

  • Rename variables/functions: "Rename getUserData to fetchUserData everywhere"
  • Replace deprecated patterns: "Replace all var declarations with let or const"
  • Update API calls: "Update all calls to the old authentication API"
  • Refactor patterns: "Convert all callbacks to async/await"
  • Standardize code: "Make all import statements use absolute paths"

Activation phrases:

  • "rename [identifier] to [new_name]"
  • "replace all [pattern] with [replacement]"
  • "refactor to use [new_pattern]"
  • "update all calls to [function/API]"
  • "convert [old_pattern] to [new_pattern]"
  • "standardize [aspect] across the codebase"

Core Capabilities

1. Find All Occurrences

Before refactoring, locate all instances of the pattern to understand scope and impact.

Search for exact matches:

Grep(pattern="getUserData", output_mode="files_with_matches")

Search with context to verify usage:

Grep(pattern="getUserData", output_mode="content", -n=true, -B=2, -A=2)

Case-insensitive search:

Grep(pattern="getuserdata", -i=true, output_mode="files_with_matches")

Regex patterns:

Grep(pattern="get\\w+Data", output_mode="content")

2. Replace All Instances

Use the Edit tool with replace_all=true for bulk replacements:

Simple replacement:

Edit(
  file_path="src/api.js",
  old_string="getUserData",
  new_string="fetchUserData",
  replace_all=true
)

Multi-line replacement:

Edit(
  file_path="src/auth.js",
  old_string="function authenticate(user) {\\n  return user.valid;\\n}",
  new_string="async function authenticate(user) {\\n  return await validateUser(user);\\n}",
  replace_all=true
)

3. Targeted Replacement

For single occurrences or when context matters, use Edit without replace_all:

Edit(
  file_path="src/config.js",
  old_string="const API_URL = 'http://old-api.com'",
  new_string="const API_URL = 'https://new-api.com'"
)

Workflow Examples

Example 1: Rename Function Across Codebase

User: "Rename getUserData to fetchUserData everywhere"

Workflow:

  1. Find all occurrences to understand scope:
   Grep(pattern="getUserData", output_mode="files_with_matches")
  1. Preview changes by viewing context:
   Grep(pattern="getUserData", output_mode="content", -n=true, -B=1, -A=1)
  1. Inform user of scope: "Found 15 occurrences in 5 files"
  1. Replace in each file:
   Edit(file_path="src/api.js", old_string="getUserData", new_string="fetchUserData", replace_all=true)
   Edit(file_path="src/utils.js", old_string="getUserData", new_string="fetchUserData", replace_all=true)
   # ... for each file
  1. Verify changes: Re-run Grep to confirm all instances were replaced
  1. Suggest testing: Recommend running tests to ensure refactoring didn't break functionality

Example 2: Replace Deprecated Pattern

User: "Replace all var declarations with let or const"

Workflow:

  1. Find all var declarations:
   Grep(pattern="\\bvar\\s+\\w+", output_mode="content", -n=true)
  1. Analyze each occurrence to determine whether to use let or const:

- Check if variable is reassigned → use let - Check if variable is constant → use const

  1. Replace systematically:
   Edit(file_path="src/index.js", old_string="var count = 0", new_string="let count = 0", replace_all=false)
   Edit(file_path="src/index.js", old_string="var MAX_SIZE = 100", new_string="const MAX_SIZE = 100", replace_all=false)
  1. Use linter if available to verify syntax:
   npm run lint

Example 3: Update API Calls

User: "Update all authentication API calls to use the new endpoint"

Workflow:

  1. Find all API calls:
   Grep(pattern="/api/auth/login", output_mode="content", -n=true)
  1. Identify variation patterns:

- Look for fetch calls, axios calls, or other HTTP methods - Check for different HTTP methods (GET, POST, etc.)

  1. Replace with updated endpoint:
   Edit(
     file_path="src/auth.js",
     old_string="fetch('/api/auth/login', {",
     new_string="fetch('/api/v2/authentication/login', {",
     replace_all=true
   )
  1. Update any response handling if API contract changed
  1. Recommend integration tests

Example 4: Convert Callbacks to Async/Await

User: "Refactor this file to use async/await instead of callbacks"

Workflow:

  1. Analyze callback patterns:
   Grep(pattern="function\\s*\\([^)]*\\)\\s*{", output_mode="content", -n=true)
  1. Identify callback functions (typically with callback, cb, or done parameters)
  1. Transform each function:
   Edit(
     file_path="src/data.js",
     old_string="function loadData(callback) {\\n  db.query('SELECT *', callback);\\n}",
     new_string="async function loadData() {\\n  return await db.query('SELECT *');\\n}"
   )
  1. Update call sites to use await:
   Edit(
     file_path="src/app.js",
     old_string="loadData((err, data) => {\\n  if (err) throw err;\\n  process(data);\\n});",
     new_string="const data = await loadData();\\nprocess(data);"
   )
  1. Add try-catch for error handling where callbacks had error parameters

Example 5: Standardize Import Paths

User: "Convert all relative imports to absolute imports"

Workflow:

  1. Find all relative imports:
   Grep(pattern="from ['\"]\\.\\.?/", output_mode="content", -n=true)
  1. Calculate absolute path for each import based on project structure
  1. Replace each import:
   Edit(
     file_path="src/components/Button.jsx",
     old_string="import { theme } from '../../utils/theme'",
     new_string="import { theme } from '@/utils/theme'",
     replace_all=true
   )
  1. Verify module resolution works with new paths

Best Practices

Planning Refactoring

Before executing refactoring:

  1. Understand scope: Use Grep to find all affected locations
  2. Assess impact: Review context of each occurrence
  3. Inform user: Report how many files/instances will be changed
  4. Consider edge cases: Look for string literals, comments, documentation

Safe Refactoring Process

The refactoring workflow should be:

  1. Search → Find all instances
  2. Analyze → Verify each match is appropriate to change
  3. Inform → Tell user the scope
  4. Execute → Make the changes
  5. Verify → Confirm changes were applied correctly
  6. Test → Suggest running tests

Handling Special Cases

String literals and comments:

  • Ask user if they want to update strings/comments containing the identifier
  • Usually rename in code only, not in user-facing strings

Exported APIs:

  • Warn if renaming exported functions (breaking change for consumers)
  • Suggest deprecation warnings or maintaining aliases

Case sensitivity:

  • Be explicit about case-sensitive vs case-insensitive replacements
  • Use -i flag in Grep for case-insensitive when appropriate

Verification

After refactoring:

  1. Re-run Grep to verify all instances were updated
  2. Check syntax: Use linter or language-specific checker
  3. Read affected files: Spot-check critical files
  4. Recommend testing: Suggest running test suite

Error Handling

Common Issues and Solutions

Issue: "Replacement created syntax errors"

  • Solution: Ensure old_string and new_string maintain proper syntax
  • Prevention: Include sufficient context in old_string to ensure valid replacement points

Issue: "Not all instances were replaced"

  • Solution: Check for variations in whitespace, quotes, or formatting
  • Alternative: Use regex patterns in Grep to find variations, then handle each

Issue: "Replaced instances in comments/strings unintentionally"

  • Solution: Be more specific with old_string context
  • Consider: Use language-aware tools if available (parsers, AST tools)

Issue: "Replace broke tests"

  • Solution: Review test files separately, update test expectations
  • Prevention: Preview test file changes before applying

Tool Usage Reference

Edit Tool Parameters

Required:

  • file_path: File to modify
  • old_string: Exact string to find
  • new_string: Replacement string

Optional:

  • replace_all: Boolean (default: false)

- true: Replace all occurrences in file - false: Replace only first occurrence (or fail if multiple matches)

Important notes:

  • old_string must match EXACTLY (including whitespace, quotes)
  • If multiple matches exist without replace_all=true, Edit will fail
  • Use replace_all=true for bulk refactoring

Grep for Refactoring

Useful Grep options for refactoring:

  • -n=true: Show line numbers (helps locate changes)
  • -B=N, -A=N: Show context (verify match is correct)
  • -i=true: Case-insensitive (find variations)
  • output_mode="content": See actual code
  • output_mode="count": Count occurrences per file
  • type: Filter by file type (e.g., type="py")

Integration with Other Tools

Working with Claude's Native Tools

  • Grep: Find patterns across codebase
  • Read: Analyze files before refactoring
  • Edit: Execute replacements (with replace_all)
  • Bash: Run linters, formatters, tests after refactoring
  • Glob: Find files by pattern for targeted refactoring

Working with Other Skills

  • test-fixing: Fix tests broken by refactoring
  • code-transfer: Move refactored code to better locations
  • feature-planning: Plan large-scale refactoring efforts

Language-Specific Patterns

JavaScript/TypeScript

Common refactoring patterns:

  • var → let/const
  • Callbacks → Promises/async-await
  • require() → import statements
  • CommonJS → ES modules
  • Class components → Function components (React)

Python

Common refactoring patterns:

  • Old string formatting → f-strings
  • % formatting → .format() or f-strings
  • Dict access → .get() with defaults
  • Type hints additions

General

Universal refactoring patterns:

  • Function/variable renaming
  • API endpoint updates
  • Library version migrations
  • Naming convention standardization
  • Import path updates

平台分布

OpenCode

28.32%
按下载量换算32

Claude Code

21.41%
按下载量换算24

windsurf

15.71%
按下载量换算18

Codex

12.82%
按下载量换算14

kiro-cli

8.27%
按下载量换算9

mcpjam

3.43%
按下载量换算4

安全审计

暂无安全审计结果可展示。

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

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

继续浏览同类 Skills