Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hellyguo-code-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/code-refactor
What's inside
- Skill name
code-refactor- Description
- 该skill没有执行文件,为操作指引:如何重构
- License
- Apache-2.0
- Instructions
- 224 lines in SKILL.md · view on GitHub
Files (5)
- SKILL.md
- analysis-report.md · templates/
- case-studies.md · templates/
- evaluation.md · templates/
- strategy-pattern.md · templates/
SKILL.md (first lines)
# 代码重构方法论 从软件设计本质层面提炼可复用的重构方法论,指导代码质量改进。 ## 适用场景 - 代码出现明确坏味道,需要改善结构 - 技术债累积影响迭代效率 - 重构前需要评估风险与收益 ## 前置条件 1. 已有可执行的测试或可复现的验证手段;没有测试时先补测试再重构。 2. 明确本次重构的目标与边界,不与其他需求混做。 3. 通过 skill `code-review` 或 `code-detect-problem` 获得问题清单。 ## 执行步骤 1. 识别退化信号,确认根因属于类型、数据、行为还是关系退化。 2. 按三问分析法确定目标设计。 3. 选择重构策略,评估影响范围与回滚方式。 4. 小步实施,每一步保持可编译、可测试。 5. 用测试与指标验证效果,记录前后对比。 6. 分步提交,每次提交只包含一个可回退的改动。 ## 一、设计哲学与原理 ### 1.1 代码退化根源 **退化机制**:复制粘贴→知识分裂,快速修复→破坏设计意图,需求变更→补丁叠加,知识遗忘→意图模糊 **退化规律**:所有代码都会退化,重构是必然的维护行为 ### 1.2 类型系统本质 ```text 类型 = 值集合 + 操作集合 + 不变量 ``` **类型退化链条**:强类型→弱类型,枚举→字符串常量→魔法字符串→硬编码,编译检查→运行时判断→运行时错误 **退化信号**:值被用来判断行为、编译期错误变成运行时错误、枚举退化成字符串常量 ### 1.3 多态本质 ```text 多态 = 同一接口 + 不同行为 ``` | 分发方式 | 时机 | 安全性 | | ----------- | ------ | ------------ | | if-else | 运行时 | 低(易遗漏) | | switch | 运行时 | 中 | | 虚方法 | 运行时 | 高 | | 模板/泛型 | 编译期 | 最高 | **本质**:用类型系统分发行为,而非运行时判断 ### 1.4 数据结构本质 ```text 数据结构 = 数据组织方式 + 访问操作 + 复杂度保证 ``` | 访问模式 | 推荐 | 不推荐 | 原因 | | -------- | ----------- | ---------- | -------------| | 顺序遍历 | List/Array | Map | 简单高效 | | Key查找 | Map/HashMap | List | O(1) vs O(n) | | 范围查询 | TreeMap | HashMap | 有序性 | | 去重 | Set | List | 自动去重 | ## 二、方法论体系 ### 2.1 问题识别 ```text 代码异味 → 症状(What) → 根因(Why) → 设计退化(本质) ``` | 退化类型 | 信号 | 根因 | | -------- | ---------- | ------------ | | 类型退化 | 值判断行为 | 类型信息丢失 | | 数据退化 | 嵌套查找 | 结构不匹配 | | 行为退化 | 重复代码 | 缺少抽象 | | 关系退化 | 紧耦合 | 依赖方向错误 | ### 2.2 三问分析法 - Q1: 为什么出现?→ 根因 - Q2: 本质是什么?→ 抽象 - Q3: 正确设计应该是什么?→ 目标 ### 2.3 决策框架 | 问题本质 | 推荐方案 | 收益 | | -------- | --------------- | ---------------- | | 类型退化 | 多态/策略模式 | 类型安全、易扩展 | | 数据退化 | 重建索引/换容器 | 性能提升 | | 行为退化 | 提取抽象 | 减少重复 | | 关系退化 | 解耦/依赖注入 | 降低耦合 | **决策原则**:优先解决根本原因;选择收益/成本比最高方案;小步快跑,持续验证 ### 2.4 执行框架 ```text 识别 → 分析 → 方案 → 小步 → 验证 → 提交 ``` **小步原则**:每次只改一个问题,每次改完可编译,每次提交可回退 ### 2.5 验证框架 | 维度 | 指标 | 方法 | | ---------- | ------------------ | ------------------ | | 性能 | 时间/空间复杂度 | 算法分析、基准测试 | | 质量 | 圈复杂度、重复率 | 静态分析工具 | | 可维护性 | 扩展性、可读性 | 代码审查 |
From hellyguo/self-ai-spec, Apache-2.0.
More from hellyguo/self-ai-spec
- 0.618score
code-review
hellyguo
代码审查框架:通用审查流程 + 语言特定规则引用,支持多语言代码审查
SkillAFreshness: A★ 8Claude Code +9 - 0.614score
code-deconstruct
hellyguo
读取所有源代码,解构为设计图、设计文档、数据库设计; 没有执行文件,请按流程执行
SkillAFreshness: A★ 8Claude Code +9 - 0.592score
gdb-heap-analysis
hellyguo
GDB heap/arena memory analysis for core dump debugging.
SkillBFreshness: B★ 8Claude Code +9 - 0.589score
java-coverage
hellyguo
Strategies and patterns to boost test coverage to 80%+ line or 60%+ branch coverage.
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
java-check-spotbugs
hellyguo
SpotBugs静态分析技能:使用SpotBugs、Find Security Bugs、fb-contrib进行Java代码缺陷和安全分析
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
cpp-tscancode
hellyguo
TscanCode静态分析技能:使用TscanCode(腾讯开源)进行C/C++代码质量分析,检测缺陷、安全漏洞和代码风格问题
SkillBFreshness: B★ 8Claude Code +9 - 0.580score
ast-grep-block
hellyguo
基于 ast-grep 的代码审查门禁:使用 code-checklist 规则集对 Java/C++/ANSI C 项目分级扫描(high/medium/low),输出命中清单与 CI 退出码。仅使用 CLI 模式(run.sh),适用于交互式审查、CI 质量门禁、批量检测
SkillBFreshness: B★ 8Claude Code +9 - 0.578score
java-check-pmd
hellyguo
PMD静态分析技能:使用PMD进行Java代码质量分析,检测代码坏味道、编码规范和安全问题
SkillBFreshness: B★ 8Claude Code +9 - 0.578score
java-env
hellyguo
该skill没有执行文件,为信息输入:Java开发需要的环境信息
SkillBFreshness: B★ 8Claude Code +9 - 0.575score
java-asprof
hellyguo
该skill没有执行文件,为操作指引:采集Java执行情况
SkillBFreshness: B★ 8Claude Code +9 - 0.574score
code-part-modification
hellyguo
局部代码修改技能:最小化修改完成功能,确保无蝴蝶效应,支持独立测试验证和全量关联检查
SkillBFreshness: B★ 8Claude Code +9 - 0.530score
cpp-clang-tidy
hellyguo
Clang-Tidy 静态分析技能:使用 clang-tidy 进行 C/C++ 代码质量检测,支持自定义检查规则和自动修复
SkillCFreshness: C★ 8Claude Code +9
Signals
- Stars
- 8
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 27, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/hellyguo/self-ai-spec
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hellyguo
- 0.618score
code-review
hellyguo
代码审查框架:通用审查流程 + 语言特定规则引用,支持多语言代码审查
SkillAFreshness: A★ 8Claude Code +9 - 0.614score
code-deconstruct
hellyguo
读取所有源代码,解构为设计图、设计文档、数据库设计; 没有执行文件,请按流程执行
SkillAFreshness: A★ 8Claude Code +9 - 0.592score
gdb-heap-analysis
hellyguo
GDB heap/arena memory analysis for core dump debugging.
SkillBFreshness: B★ 8Claude Code +9 - 0.589score
java-coverage
hellyguo
Strategies and patterns to boost test coverage to 80%+ line or 60%+ branch coverage.
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
cpp-tscancode
hellyguo
TscanCode静态分析技能:使用TscanCode(腾讯开源)进行C/C++代码质量分析,检测缺陷、安全漏洞和代码风格问题
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
java-check-spotbugs
hellyguo
SpotBugs静态分析技能:使用SpotBugs、Find Security Bugs、fb-contrib进行Java代码缺陷和安全分析
SkillBFreshness: B★ 8Claude Code +9
Cite this page
code-refactor skill. Agent Mart. https://agentmart.dev/skills/hellyguo-code-refactor (last updated 2026-10-24)