Skip to content
Automation
Skill

/code-tidy

代码洁癖级整理 — 清除死代码、冗余注释、未用导入;统一排序与结构; 每次写代码后自动触发。MUST trigger when user says: "整理代码", "tidy code", "clean code", "代码洁癖", "清理代码", "整理一下代码", "清理系统", "清理垃圾", "清理残留", or after any significant code edit session, package installation, or file download. Also trigger when the user

From plugin
lihongwei-cn
5200 skills1 agent

Claude Code

$ npx -y skills add LiHongwei-cn/lihongwei-cn --skill code-tidy --agent claude-code

SKILL.md

code-tidy.SKILL.md
name: code-tidy
description: >
  代码洁癖级整理 — 清除死代码、冗余注释、未用导入;统一排序与结构;
  每次写代码后自动触发。MUST trigger when user says: "整理代码", "tidy code",
  "clean code", "代码洁癖", "清理代码", "整理一下代码", "清理系统",
  "清理垃圾", "清理残留", or after any significant code edit session,
  package installation, or file download. Also trigger when the user
  expresses dissatisfaction with code organization or mentions OCD/cleanliness.

代码洁癖

> 代码如房间——所有东西在正确的位置,按顺序排列,不留冗余。

执行流程

第一步:扫描

逐文件扫描当前改动涉及的所有文件:

1. **无用 import**:`grep` 检查每个 import 是否在文件中被使用 2. **死函数**:检查定义了但从未调用的函数/方法 3. **注释掉的代码**:查找被 `//` `#` `/* */` 注释掉的代码块(不是说明性注释) 4. **冗余注释**:函数名已经说明意图的行内注释、`// TODO` 已完成的注释 5. **多余文件**:临时 `.md`、`.txt`、`test_*.tmp`、备份文件

第二步:排序

检查并修正元素顺序:

  • **Imports**:标准库 → 第三方 → 本地模块,组内字母序
  • **JSON keys**:字母序排列
  • **CSS 属性**:定位 → 盒模型 → 排版 → 视觉 → 其他
  • **HTML 属性**:`id` → `class` → `style` → `data-*` → `href/src` → 其他
  • **函数定义**:public → private,同组内按依赖关系排列(被调用者在前)

第三步:清理

实际执行清理操作:

# 删除未使用的 import
# 删除死函数
# 删除注释掉的代码块
# 删除冗余注释
# 删除多余文件
# 排序 imports / keys / attributes

第四步:验证

清理完成后确认:

  • [ ] 代码能正常运行(不因清理而破坏)
  • [ ] 没有引入新的 lint 错误
  • [ ] 文件行数有减无增(或者增的只是必要的逻辑)

特殊规则

不清理的情况

  • 用户明确要求保留的代码
  • 虽然未使用但是 API 导出的一部分(如 `__all__`、`exports`)
  • 文档中引用的示例代码
  • 打算后续使用的 TODO 注释(需有明确的后续计划和日期)

CSS 属性排序参考

1. 定位: position, top, right, bottom, left, z-index
2. 盒模型: display, width, height, margin, padding, border
3. 排版: font-*, text-*, line-height, letter-spacing
4. 视觉: color, background, opacity, box-shadow
5. 其他: cursor, transition, transform, animation

HTML 属性排序参考

1. id
2. class  
3. style
4. data-* (按字母序)
5. href / src / alt
6. type / name / value
7. target / rel / download
8. 事件属性 on*

安装残留清理

每次 `brew install`、`pip install`、`npm install`、文件下载后,执行:

自动清理步骤

# 包管理器缓存
brew cleanup                    # Homebrew 旧版本
pip3 cache purge                # pip 下载缓存
npm cache clean --force         # npm 缓存

# 安装包残留
find ~/Downloads -name "*.dmg" -delete
find ~/Downloads -name "*.pkg" -delete

# 临时目录
find /tmp -maxdepth 1 -user $(whoami) -delete 2>/dev/null

# .DS_Store(项目中)
find . -name ".DS_Store" -delete

# Python 编译缓存
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
find . -name "*.pyc" -delete

清理检查清单

  • [ ] `.dmg` / `.pkg` 安装包已删除
  • [ ] 解压的临时文件夹已删除
  • [ ] `brew cleanup` 已执行
  • [ ] `pip cache` 已清除
  • [ ] 项目内无 `.DS_Store`
  • [ ] 项目内无 `__pycache__` / `*.pyc`
Read more
@lihongwei-cn
Ships withlihongwei-cn

MUNDO - THE EMPEROR. Complete AI orchestration system with 1208 skills, 25 capability modules, self-evolving, collective consciousness. GitHub Actions 24/7 automation.

5200 skills1 agent
Get the whole plugin

Stars on GitHub

Momentum

stars in total
5
Star history of LiHongwei-cn/lihongwei-cn on GitHub, a chart by star-history.com

Other skills on lihongwei-cn.

cheat-on-content

cheat-on-content

给所有想把"感觉"变成可校准预测的内容创作者。**方法论通用**——打分 → 盲预测 → T+3d 复盘 → 进化 rubric 的循环适用任何能被量化(播放 / 阅读 / 收听 / 点击)的内容。**rubric…

cheat-bump

cheat-bump

提议并执行 rubric 或 bucket 升级。两种模式:**完整 rubric bump**(最高风险动作,5 步强制 + 跨模型审核)和 **--bucket-only 轻量重校**(只换 bucket 边界,不动 rubric 公式)。**Phase…

cheat-init

cheat-init

cheat-on-content 的首次 onboarding 与脚手架创建器。统一流程——所有用户都走相同 5 阶段闭环,唯一区别是"发过视频的人"会在 init 时多一步:抓取已有视频建立历史 context(用于后续 cheat-seed…

cheat-migrate

cheat-migrate

把老用户的 .cheat-state.json 升级到当前 schema_version。读 migrations/registry.md 算迁移链,按顺序应用每一步迁移文件。幂等:跑两次结果一样。失败停在中间版本不前进。触发词:"迁移"/"升级…

cheat-persona

cheat-persona

从复盘评论数据派生 / 刷新账号的受众画像,写入 audience.md。这是和 rubric 平行的第二个派生物——rubric 答"怎么打分",persona 答"谁在看"。cheat-seed 选题 / 写稿时读它。**audience.md…

More skills from other plugins.

agent-builder

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, and…

n8n11d209k
@n8n-io@n8n-ioInstall Skill
browser-use

browser-use

Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…

@browser-use@browser-useInstall Skill
agent-browser

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…

@vercel-labs-2@vercel-labs-2Install Skill
add-anydoc

add-anydoc

Add local office-document-to-Markdown conversion to NanoClaw agent containers with the pinned Firecrawl AnyDoc CLI. Use when…

@nanocoai@nanocoaiInstall Skill

Questions about code-tidy.

Which coding agents can use code-tidy?
code-tidy installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.