mcpbeat Sign in

Size Check Agent Skill

>- 代码简化与文件行数检查。当用户描述"简化代码"、"检查文件大小"、"代码瘦身"时触发。 审查变更代码的复用性、质量和效率;扫描项目文件行数是否超限并给出拆分建议。

826 tokens
context cost
SKILL.md, read when the skill is used
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
1 027
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/doccker/cc-use-exp --skill size-check

The instruction itself

6 sections, as written by the author

Size Check - 代码简化与文件行数检查

功能 1:代码简化

审查变更代码的复用性、质量和效率,修复发现的问题。

检查项

| 检查项 | 说明 |

|--------|------|

| 重复代码 | 提取公共方法/组件 |

| 过度抽象 | 简化不必要的设计模式 |

| 冗余逻辑 | 合并可简化的条件分支 |

| 未使用代码 | 删除死代码、无用 import |


功能 2:文件行数扫描

行数阈值

| 语言 | 上限 | 拆分方式 |

|------|------|---------|

| Java | 300 | Service 拆分职责、提取 Helper/Converter |

| Go | 400 | 按功能拆分同包文件 |

| Vue | 200 | 提取子组件、composables |

| TSX/JSX | 200 | 提取子组件 |

| TypeScript/JS | 300 | 提取工具函数、常量、类型 |

| Python | 300 | 按职责拆分模块 |

执行流程

全项目扫描模式(用户未指定文件时):

1. 扫描项目所有代码文件(排除 node_modules、vendor、dist、build、.git)
2. 统计每个文件行数,对照阈值标记超限文件
3. 检测 Markdown 文件中的重复章节
4. 输出超限清单 + 拆分建议

输出格式

## 文件行数扫描结果

### 超限文件

| 文件 | 行数 | 阈值 | 超限 | 建议 |
|------|------|------|------|------|
| path/to/file.py | 450 | 300 | +150 | 按职责拆分为 xxx.py 和 yyy.py |

### 总结

- 扫描文件数:N
- 超限文件数:N
- 建议操作:[具体建议]

功能 3:CSS 提取检查

| 检查项 | 条件 | 建议 |

|--------|------|------|

| 内联样式过长 | <style> 块超过 30 行 | 提取公共样式到 assets/styles/ |

| 非 scoped 全局样式 | Vue SFC 中存在 <style>(无 scoped) | 移到 assets/styles/common.scss |


修复流程

扫描完毕后,如发现超限文件或 CSS 提取建议,执行以下流程:

1. 用户确认

询问用户是否修复。

2. 执行修复

逐文件修复,每个文件:

  • 阅读完整文件,理解上下文和调用关系
  • 检查是否涉及重构:
  • 如果涉及表格列、数据结构、条件分支的修改,触发 refactor-safety 规则
  • 完整读取原始代码(不凭记忆或推测)
  • 制作对比清单(列/字段/配置项)
  • 逐项验证一致性(数量/顺序/命名)
  • 按扫描建议拆分/提取:
  • 行数超限 → 拆分文件
  • CSS → 提取到 assets/styles/
  • 确保拆分后的入口文件保持原有导出/接口不变
  • 优先处理超限最严重的文件

重构安全检查:

  • ✅ 表格重构:列数、列名、列顺序与原始代码一致
  • ✅ 数据结构重构:字段完整,没有遗漏
  • ✅ 条件分支重构:所有 if/else/switch 分支都已处理

安全原则

  • 先报告,确认后修复 — 扫描结果需用户确认才执行修复
  • 不改变现有行为 — 拆分后的入口文件保持原有接口
  • 渐进式处理 — 优先处理超限最严重的文件

How to use it

Copy the folder

Take doccker/cc-use-exp-.cursor-size-check from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.