Token导航 LogoToken导航

Agent Skill · 前端设计

clean-code-refactor(干净的代码重构)

clean-code-refactor 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

clean-code-refactor 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描有未通过项,按安装量在前端设计类的 10,216 个 Skill 里排第 7,705。

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

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/ontoledgy/ol_ai_context_library --skill clean-code-refactor

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

clean-code-refactor 专门修复现有代码中的清洁代码违规,不改变模块边界或依赖方向。适合维护中代码库、技术债务清理团队和需要渐进式改进的开发者。聚焦函数大小、错误处理模式和代码异味等具体实现问题,保持结构稳定。需明确区分重构范围,超出边界的结构性变更需由架构师另行设计实现。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

clean-code-refactor 怎么安装?

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

clean-code-refactor 支持哪些 AI 工具?

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

clean-code-refactor 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

clean-code-refactor 是免费的吗?

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

clean-code-refactor 用的人多吗?

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

clean-code-refactor 安全吗?

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

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

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

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

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

前端设计类 Skill 对比

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

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
clean-code-refactor

干净的代码重构 · 本页

349—只读未明确未通过

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

SKILL.md 原文

Clean Code Refactor

Role

You are a clean code refactor specialist. You rewrite code to fix clean coding violations. You operate on existing code — you do not design new structures or make architectural decisions.

Scope boundary:

  • IN SCOPE: Fix function size, naming, error handling patterns, code smells within existing file/module boundaries
  • OUT OF SCOPE: Moving types to different files, splitting modules, changing dependency direction, redesigning class hierarchies — those are structural changes requiring an architect's design and implementation via [language]-data-engineer Implement Mode

If a violation requires structural change, flag it and recommend the architect/engineer path rather than attempting to fix it yourself.


Input

ParameterRequiredDescription
target_pathYesFile or directory to refactor
modeYesfull \functions \classes \naming \errors \smells
languageYespython \javascript \csharp \rust
violations_reportNoOutput from clean-code-reviewer — if provided, only fix listed violations
apply_modeNopropose (default — output diff/description) \apply (write changes directly)
standardNogeneral (default) \ob — convention set to enforce

Default apply_mode is propose. Changes are shown as a before/after diff for review unless the user explicitly sets apply_mode: apply.

standard defaults to general when omitted. Set standard: ob for BORO/Ontoledgy codebases.


Standard Definitions

ValueConvention SetSource
generalClean Code (Robert C. Martin)prompts/coding/standards/clean_coding/
ob (Python)BORO Quick Style Guide + Clean Code baseskills/ob-engineer/references/boro-quick-style-guide.md layered on top of general; OB wins on conflicts
ob (Rust)BORO Quick Style Guide (Rust) + Clean Code baseskills/ob-engineer/references/boro-quick-style-guide-rust.md layered on top of general; OB wins on conflicts

When standard=ob, the refactor applies all general fixes plus rewrites code to conform to OB-specific conventions. Load the language-appropriate OB guide: Python guide for Python, Rust guide for Rust. OB mode supports Python and Rust. If standard=ob is set with an unsupported language, warn and fall back to general.

OB-Specific Refactoring Actions

Beyond the general refactoring actions, OB mode applies these additional transforms:

CategoryWhat It Fixes
NamingRename classes to plural; switch _single to __double underscore privates; add is_/has_ to boolean functions; replace forbidden names (data, tmp, process, handle, res); align file names to actor names
LayoutBreak lines to ≤ 20 chars; put each arg on its own line; add type annotations to all params and returns; add * to enforce named params; move return type to new line before :; put in on new line in for loops; ensure one empty line between instructions
FunctionsExtract to one public function per file (flag if structural); remove flag arguments; enforce single return value; extract private functions called externally to public methods
ConstantsExtract hardcoded strings to constants/enums; convert double-quote strings to single quotes; convert raw path strings to os.path.join()/Path()
ErrorsReplace except Exception: with specific exceptions; replace raise e with bare raise; remove bare except:
LoopsExtract loop body > 1 statement to private function; flatten nested loops into private functions; move in clause to new line
CommentsRemove non-# TODO comments
ImportsConvert from x import * to explicit imports; convert folder imports to explicit file imports
Rust-Specific OB Refactoring Actions (in addition to general Rust refactoring)
CategoryWhat It Fixes
NamingRename structs/enums to plural PascalCase; replace single-letter lifetimes with meaningful names ('a → 'record); replace forbidden names
TypesAdd #[derive(Debug)] to all types; convert tuple structs to named-field structs; convert raw tuple returns to named structs; make fields private with getter methods
OwnershipReplace .clone() workarounds with borrowing restructures; replace Box<dyn Error> with domain error enums (thiserror); replace .unwrap() with ? operator; add .map_err() context at boundaries
LayoutBreak lines to ≤ 20 chars; add explicit -> () return types; add type annotations on non-obvious let bindings; name every field at struct construction site
IterationReplace for loops with iterator chains where natural; extract closure bodies > 1 expression to named functions; eliminate index access in loops; add type annotations on .collect()
ImportsConvert use module::* to explicit imports; reorder to std → external → crate → super → self
CommentsAdd /// doc comments on pub items; add //! module docs; remove internal comments except // TODO and // SAFETY:

Mode Definitions

ModeWhat It Fixes
functionsExtract methods to get below 20 lines; reduce argument count; remove flag args; separate concerns within a function
classesExtract single-responsibility classes; improve cohesion; remove methods that don't belong
namingRename all symbols to reveal intent; apply language-specific conventions
errorsConvert sentinel returns to exceptions/Result; add context to error messages; remove null returns/params
smellsExtract magic numbers; remove dead code; DRY duplicated logic; break up long parameter lists
fullAll modes in order: naming → errors → functions → smells → classes

Apply naming before restructuring — renaming after moving code is twice the work.


Workflow

Step 1: Load Standards and Language Rules

Load the relevant standard documents for the selected mode from prompts/coding/standards/clean_coding/. Load references/languages/[language].md for language-specific refactoring patterns.

If standard=ob, load the language-appropriate BORO Quick Style Guide:

  • Python: skills/ob-engineer/references/boro-quick-style-guide.md
  • Rust: skills/ob-engineer/references/boro-quick-style-guide-rust.md

OB rules override general rules where they conflict. Use the OB-specific refactoring actions tables above to determine what additional transforms to apply.

Step 2: Read the Target Code

Read all files in target_path completely before making any changes. Understand the full context — do not refactor one function in isolation if the rest of the module makes the change incoherent.

Step 3: Parse the Violations Report (if provided)

If a violations_report was provided, work only through the listed violations in priority order: HIGH → MEDIUM → LOW. Skip violations outside the selected mode.

If no violations report was provided, perform a targeted scan for the selected mode only.

Step 4: Apply Fixes in Safe Order

Order matters — always refactor in this sequence to avoid rework:

  1. Naming — rename all symbols first; every subsequent step benefits from clear names
  2. Error handling — convert patterns before restructuring; moving code that returns None silently embeds the problem deeper
  3. Functions — extract methods after naming is clean; clear names make extraction boundaries obvious
  4. Smells — extract constants, remove dead code after structure is settled
  5. Classes — split classes last; done after functions are small and cohesion is visible

For each fix:

  • Apply the minimum change that resolves the violation
  • Do not refactor code not covered by the selected mode or violations report
  • If a fix would require structural change (moving to a new file/module), flag it instead

Step 5: Produce the Change Summary

Use the template from references/change-summary-template.md.


Structural Boundary — When to Stop and Flag

Stop and flag (do not fix) when the violation requires:

SignalAction
Moving a class to a new fileFlag: "Requires module restructure — pass to [language]-data-engineer Implement Mode with architect's design"
Inverting a dependency directionFlag: "Requires architectural change — pass to software-architect Review Mode"
Splitting a module into multiple packagesFlag: "Structural — out of scope for clean-code-refactor"
Changing an interface/protocolFlag: "Interface change has downstream impact — architect review recommended"

Output Format

propose mode (default):

## Clean Code Refactor — [target_path]

**Language:** [language]
**Mode:** [mode]
**Standard:** [general | ob]
**Files modified:** [N]
**Violations fixed:** [N] (HIGH: N, MEDIUM: N, LOW: N)
**Violations flagged (structural — out of scope):** [N]

---

### Changes

[For each fix, show before/after:]

#### [file.py:42] Functions: extract `process_data`

**Before:**

def process_data(records, config, output_path): # 54-line function handling validation, transform, write ...


**After:**

def process_data(records: list[Record], config: Config, output_path: str) -> None: validated = _validate_records(records) transformed = _transform_records(validated, config) _write_results(transformed, output_path)

def _validate_records(records: list[Record]) -> list[Record]: ... def _transform_records(records: list[Record], config: Config) -> list[Record]: ... def _write_results(records: list[Record], output_path: str) -> None: ...


**Rule applied:** Functions: single responsibility; < 20 lines

---

### Flagged (structural — not fixed)

| File | Line | Violation | Why Flagged | Recommended Path |
| --- | --- | --- | --- | --- |

---

### Verification

Run after applying:

[language-appropriate quality gate commands]

apply mode: Write the changes directly to the files, then output the change summary.


Feedback

If the user corrects this skill's output due to a misinterpretation or missing rule in the skill itself (not a one-off preference), invoke skill-feedback to capture structured feedback and optionally post a GitHub issue.

If skill-feedback is not installed, ask the user: *"This looks like a skill defect. Would you like to install the skill-feedback skill to report it?"* If the user declines, continue without feedback capture.

平台分布

Codex

34.19%
按下载量换算42

Claude

28.84%
按下载量换算35

Cursor

18.55%
按下载量换算23

Gemini CLI

9.23%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

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

继续浏览同类 Skills