code-refactor
Skill1 starsChanged 8 months agoMITView on GitHub
代码重构与优化助手。扫描代码库识别重复模式、冗余逻辑和可优化片段,提取为通用组件、接口或模块。触发场景:(1) 用户要求重构代码或优化代码结构,(2) 用户说"帮我整理代码"、"代码太乱了"、"有很多重复",(3) 用户要求提取公共组件、抽象接口、DRY优化,(4) 用户上传代码文件要求分析和改进
16 other projects use a version of this.
Adopted by
Most recently taken up by
- u9401066/zotero-keepertheir own version, first seen Nov 8, 2026
- OpenxIntelligence/Coding-Agent-Skillstheir own version, first seen Nov 1, 2026
- hellyguo/self-ai-spectheir own version, first seen Oct 26, 2026
- I-Onlabs/claude-code-skillstheir own version, first seen Oct 25, 2026
- u9401066/pubmed-search-mcptheir own version, first seen Oct 20, 2026
- nek1987/auto-agent-harnesstheir own version, first seen Oct 11, 2026
Used with
Projects with it also use git-doc-updater, git-precommit and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
u9401066Skillgit-doc-updater
Auto-check and update key documentation before Git commits to keep docs in sync with code. Triggers: docs, 文檔, 更新文檔, sync docs, release, 發布.
Also in 5 projects that use this
u9401066Skillgit-precommit
Orchestrate pre-commit workflow including Memory Bank sync, README/CHANGELOG/ROADMAP updates. Triggers: GIT, gc, push, commit, 提交, 準備 commit, 要提交了, git commit, pre-commit, 推送.
Also in 5 projects that use this
klauswgSkillreadme-i18n
Use when the user wants to translate a repository README, make a repo multilingual, localize docs, add a language switcher, internationalize the README, or update localized README variants in a GitHub-style repository.
Also in 5 projects that use this
GoogleSkillcode-reviewer
Also in 5 projects that use this
- +8 more from u9401066
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- u9401066/pubmed-search-mcp★ 28same name
- nilecui/SkillsBase★ 27same name
- ZeroPointRepo/CRHQ-PRDs★ 22same name
- hellyguo/self-ai-spec★ 8same name
- u9401066/zotero-keeper★ 7same name
- arnabdeypolimi/claude_code_setup★ 4same name
- I-Onlabs/claude-code-skills★ 4same name
- nek1987/auto-agent-harness★ 4same name
- OpenxIntelligence/Coding-Agent-Skills★ 4same name
- rm2thaddeus/Aitor_Skills★ 4same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- commitSkill
- dev-brainstormSkill
The file
Files
Code Refactor Skill
扫描代码、识别重复、提取抽象、输出优化后的通用组件。
核心工作流程
1. 扫描分析 → 识别代码文件和结构
2. 模式检测 → 找出重复代码、相似逻辑
3. 抽象设计 → 设计通用接口/组件
4. 重构输出 → 生成优化后的代码
5. 验证检查 → 确保功能等价性重复模式检测
检测目标
| 类型 | 示例 | 重构方向 |
| 代码克隆 | 多处相同/相似代码块 | 提取函数/方法 |
| 相似逻辑 | 结构相同但参数不同 | 泛型/模板方法 |
| 重复模式 | 相同的异常处理/验证 | 装饰器/中间件 |
| 数据转换 | 多处相似的 map/filter | 通用转换器 |
| 配置散落 | 硬编码值散布各处 | 配置中心化 |
检测策略
1. 结构相似度:AST 级别的代码结构对比
2. 语义相似度:功能等价但写法不同的代码
3. 命名模式:相似命名暗示的重复逻辑
4. 调用链分析:重复的函数调用序列重构策略(按语言)
Python
- 重复函数 → 提取到
utils/或创建基类 - 相似类 → 抽象基类 (ABC) + 模板方法
- 重复装饰逻辑 → 自定义装饰器
- 数据处理 → 通用 pipeline 函数
JavaScript/TypeScript
- 重复组件逻辑 → Custom Hooks (React) 或 Composables (Vue)
- 相似 API 调用 → 通用 API 客户端
- 重复验证 → Schema 验证库 (zod/yup)
- 工具函数 →
utils/模块导出
Java/Kotlin
- 重复代码 → 抽象类 + 模板方法模式
- 相似接口实现 → 泛型接口
- 重复配置 → Builder 模式或配置类
Go
- 重复逻辑 → 提取到独立包
- 相似结构体方法 → 接口抽象
- 错误处理 → 统一错误处理函数
输出规范
重构报告格式
## 📊 代码分析报告
### 发现的重复/优化点
1. [位置] - [问题描述] - [严重程度: 高/中/低]
### 重构建议
| 编号 | 当前问题 | 建议方案 | 预期收益 |
|------|----------|----------|----------|
### 提取的通用组件
- 组件名: [描述]
- 适用场景: [说明]重构代码输出
每个重构后的组件/模块应包含:
- 清晰的文件头注释说明用途
- 类型定义(如适用)
- 使用示例
- 原代码位置的替换说明
质量检查清单
重构完成后验证:
- 功能等价:重构后行为与原代码一致
- 测试覆盖:关键路径有测试
- 命名清晰:抽象后的名称表意准确
- 文档完整:使用方式有说明
- 依赖合理:不引入循环依赖
常见重构模式示例
详细示例见 references/patterns.md
使用提示
- 小范围重构:直接分析并输出优化代码
- 大型代码库:先输出分析报告,确认后再逐步重构
- 优先处理高频重复和高影响区域
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

