Skip to content
cccskills
FreePublished on GitHub

size-check

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

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md3.2 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

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

功能 1:代码简化

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

检查项

检查项说明
重复代码提取公共方法/组件
过度抽象简化不必要的设计模式
冗余逻辑合并可简化的条件分支
未使用代码删除死代码、无用 import

功能 2:文件行数扫描

行数阈值

语言上限拆分方式
Java300Service 拆分职责、提取 Helper/Converter
Go400按功能拆分同包文件
Vue200提取子组件、composables
TSX/JSX200提取子组件
TypeScript/JS300提取工具函数、常量、类型
Python300按职责拆分模块

执行流程

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

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. 执行修复

逐文件修复,每个文件:

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

重构安全检查:

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

安全原则

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

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

当设计或修改 REST API 响应结构、处理 API 返回值时触发。防止 API 设计缺陷导致的字段错位、类型歧义等问题。

The English summary is being prepared. Showing the original description.

doccker/cc-use-exp1.1KUpdated Aug 26, 2026

当设计或修改 REST API 响应结构、处理 API 返回值,或生成 Excel/CSV/PDF/对账文件等下游产物时触发。防止 API 设计缺陷导致的字段错位、类型歧义,以及生成产物时关键字段缺失但静默成功的问题。

The English summary is being prepared. Showing the original description.

doccker/cc-use-exp1.1KUpdated Aug 26, 2026

网关/代理/WAF/CDN 中间件的安全关键词匹配实现规范,防止纯子串匹配误判正常响应内容中的技术术语(如 Cloudflare、502、error)

The English summary is being prepared. Showing the original description.

doccker/cc-use-exp1.1KUpdated Aug 26, 2026

当 API/任务可能执行超过 10 秒(批量数据处理、远程 API 批量调用、全表扫描、跨租户聚合)时触发。防止同步接口被网关 30s 超时切断、用户重复点击触发并发、状态缓存内存泄漏等问题。提供异步任务状态机标准模板。

The English summary is being prepared. Showing the original description.

doccker/cc-use-exp1.1KUpdated Aug 26, 2026

Bash 编写规范。当用户操作 .sh、Dockerfile、Makefile、.yml、.yaml 文件, 或在 Markdown 中编写 bash/shell 代码块时触发。 包含注释规范、文件写入方式、Heredoc 引号规则、权限路径、脚本规范等。

The English summary is being prepared. Showing the original description.

doccker/cc-use-exp1.1KUpdated Aug 26, 2026

当用户操作 .sh、Dockerfile、Makefile、.yml、.yaml 文件,或在 Markdown 中编写 bash 代码块时触发。提供 Bash 编写规范。

The English summary is being prepared. Showing the original description.

doccker/cc-use-exp1.1KUpdated Aug 26, 2026

See all skills by doccker

Report a problem with this skill