Guidelines
akash-network/node
Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.
“重构顾问 - 识别代码坏味道并提供重构方案”
$ npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh refactor-advisor --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/refactor-advisor .claude/skills/refactor-advisor && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "refactor-advisor" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisor into .claude/skills/refactor-advisor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor-advisor", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisorType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh refactor-advisor --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/refactor-advisor .agents/skills/refactor-advisor && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "refactor-advisor" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisor into .agents/skills/refactor-advisor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor-advisor", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh refactor-advisor --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/refactor-advisor .cursor/skills/refactor-advisor && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "refactor-advisor" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisor into .cursor/skills/refactor-advisor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor-advisor", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/laolaoshiren/claude-code-skills-zh.git --path skills/refactor-advisor--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh refactor-advisor --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/refactor-advisor .gemini/skills/refactor-advisor && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "refactor-advisor" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisor into .gemini/skills/refactor-advisor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor-advisor", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install laolaoshiren/claude-code-skills-zh refactor-advisorInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/refactor-advisor .github/skills/refactor-advisor && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "refactor-advisor" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisor into .github/skills/refactor-advisor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor-advisor", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh refactor-advisor --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/refactor-advisor .opencode/skills/refactor-advisor && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "refactor-advisor" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/refactor-advisor into .opencode/skills/refactor-advisor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor-advisor", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
refactor-advisorRefactor Advisor is a skill in laolaoshiren/claude-code-skills-zh (879 stars). Its SKILL.md is about 456 tokens. Licence: MIT.
3 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 633f21c. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown and typescript).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Refactor Advisor loads about 456 tokens when it runs. Until then it costs about 10 tokens; SKILL.md has 119 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from laolaoshiren/claude-code-skills-zh at commit 633f21c, republished under its MIT licence (© laolaoshiren). 119 words, ~456 tokens.
.claude/skills/refactor-advisor/SKILL.md (or your agent's skills folder).当用户要求重构代码、优化代码结构、改善代码质量、消除技术债务时激活此技能。
grep/rg 扫描目标目录,识别潜在坏味道按严重程度分类发现的问题:
| 等级 | 含义 | 说明 |
|---|---|---|
| 🔴 严重 | 必须立即修复 | 影响可维护性和稳定性 |
| 🟡 中等 | 建议尽快修复 | 降低代码可读性 |
| 🟢 轻微 | 可择机优化 | 不影响功能但有改进空间 |
按以下维度综合排序:
| 坏味道 | 特征 | 重构手法 | 等级 |
|---|---|---|---|
| 长方法 | 函数超过 50 行 | 提取方法 (Extract Method) | 🔴 |
| 大类 | 类超过 300 行 | 提取类 (Extract Class) | 🔴 |
| 重复代码 | 相似代码块出现 3+ 次 | 提取公共方法 | 🔴 |
| 过长参数 | 函数参数超过 4 个 | 引入参数对象 | 🟡 |
| 嵌套过深 | if/for 嵌套 3+ 层 | 卫语句 (Guard Clause) | 🟡 |
| 魔法数字 | 硬编码的数字 | 提取为常量 | 🟢 |
| 过长链式调用 | a.b.c.d.e | 提取中间变量 | 🟢 |
| 全局可变状态 | 全局变量被多处修改 | 封装为模块/引入依赖注入 | 🔴 |
| 过度耦合 | 模块间相互依赖 | 依赖反转、引入接口 | 🟡 |
# 代码重构报告
## 概要
- 扫描文件数:XXX
- 发现问题数:XX(🔴 X / 🟡 X / 🟢 X)
- 预估工作量:X 天
## 问题列表
### 问题 1:[问题标题]
- **📍 位置**:`src/services/user.ts:45-120`
- **🔍 问题**:该函数长达 75 行,包含 3 层嵌套,职责不单一
- **🛠️ 重构方案**:
- 提取 `validateUserData()` 方法
- 提取 `saveToDatabase()` 方法
- 使用卫语句替代嵌套 if
- **⚠️ 风险评估**:
- 该函数被 12 处调用,需全面回归测试
- 建议先添加单元测试再重构
- **Before**:
```typescript
function processUser(data) { /* 75行... */ }function processUser(data) {
const validated = validateUserData(data);
return saveToDatabase(validated);
}| 阶段 | 内容 | 优先级 | 预估 |
|---|---|---|---|
| P1 | 修复 🔴 严重问题 | 高 | 2天 |
| P2 | 处理 🟡 中等问题 | 中 | 3天 |
| P3 | 优化 🟢 轻微问题 | 低 | 1天 |
## 注意事项
- 重构前确保有足够的测试覆盖
- 每次重构尽量小步提交,便于回滚
- 重构不应改变外部行为(行为保持)
- 大规模重构建议分阶段进行,每阶段独立可验证
- 关注重构过程中的性能回退风险© laolaoshiren, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in skills/refactor-advisor of laolaoshiren/claude-code-skills-zh.
Open the folder on GitHubat commit 633f21c
Refactor Advisor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Refactor Advisor this skilllaolaoshiren/claude-code-skills-zh | 879 | — | ~456 | Automated safety check: Pass | MIT | |
| Guidelinesakash-network/node | 1.1k | 20 repos | ~577 | Automated safety check: Pass | MIT | |
| Component Refactoringlangflow-ai/langflow | 155k | — | ~3.5k | Automated safety check: Pass | MIT | |
| Migrate Core Code to Submodulestinyhumansai/openhuman | 42k | — | ~2.6k | Automated safety check: Pass | GPL-3.0 | |
| ast-grep Structural Searchcode-yeongyu/oh-my-openagent | 70k | — | ~3.3k | Automated safety check: Pass | MIT | |
| Systematic Code Refactoringluongnv89/claude-howto | 42k | — | ~3k | Automated safety check: Pass | MIT |
akash-network/node
Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.
langflow-ai/langflow
Refactor high-complexity React components in Langflow frontend.
tinyhumansai/openhuman
Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.
code-yeongyu/oh-my-openagent
Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.
luongnv89/claude-howto
Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.
skills-directory/skill-codex
A skill your agent uses when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing
laolaoshiren/claude-code-skills-zh
依据真实 OpenAPI、路由实现和现有测试生成并验证 API 测试。用于用户要求测试接口、补集成测试、验证 API 契约、生成回归用例或排查接口兼容性时;区分“生成测试”和“执行请求”的授权,不猜测状态码、响应结构或 SLA,不在未确认环境中发送写请求。
laolaoshiren/claude-code-skills-zh
审计 Node.js、Python、Go、Rust、JVM、Ruby 项目的依赖漏洞、版本健康度与许可证事实;当用户要求检查 package.json、lockfile、requirements、go.mod、Cargo.toml、pom.xml、Gemfile.lock,或生成不改依赖的中文审计报告时使用
laolaoshiren/claude-code-skills-zh
安全诊断并修复 ESLint error、warning 和配置兼容问题。用于用户要求运行 lint、解释 ESLint 报错、限定范围自动修复或迁移 ESLint 配置时;优先使用项目锁定的包管理器与版本,先预检再修改,不自动下载最新版或批量改写无关源码。
laolaoshiren/claude-code-skills-zh
安全处理 Git 状态检查、提交信息、commit、分支、push、PR 和 rebase。用于用户要求检查改动、生成或创建提交、管理分支、推送、发起 PR 或整理历史时;严格区分每个动作的授权,并保护工作树中已有和无关的修改。
laolaoshiren/claude-code-skills-zh
分析真实项目并生成或修订安全、可验证的 GitHub Actions workflow;当用户要求创建 CI、测试矩阵、构建、Release、部署、缓存、Secrets、OIDC、PR 自动化或排查 workflow 配置时使用
laolaoshiren/claude-code-skills-zh
中文 Skill 收录评估器。用于核验 GitHub 上的 Claude Code、Codex、Agent Skills、Plugin、MCP、CLI 或 Agent 工作流是否值得加入精选列表;检查真实资产、安装方式、活跃度、重复项和安全边界,并生成分类、中文描述与可追溯证据。
Categories
Run `npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a claude-code`. Or copy the skill folder (skills/refactor-advisor in laolaoshiren/claude-code-skills-zh) into .claude/skills/refactor-advisor in your project. Claude Code loads it when a task matches its description.
Run `npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a codex`. Or copy the skill folder (skills/refactor-advisor in laolaoshiren/claude-code-skills-zh) into .agents/skills/refactor-advisor in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor-advisor, .gemini/skills/refactor-advisor, .github/skills/refactor-advisor and .opencode/skills/refactor-advisor in your project.
SKILL.md names no scripts, command-line tools or credentials: Refactor Advisor is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Refactor Advisor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 456 tokens (SKILL.md is roughly 1.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Refactor Advisor: Guidelines (akash-network/node, 1.1k stars), Component Refactoring (langflow-ai/langflow, 155k stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 42k stars) and ast-grep Structural Search (code-yeongyu/oh-my-openagent, 70k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
laolaoshiren (a GitHub user) maintains it in laolaoshiren/claude-code-skills-zh, which has 879 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 5, 2026.
Source: laolaoshiren/claude-code-skills-zh on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.