My-Skills/code-shorters/SKILL.md
自动化代码模块化重构工具。用于检测、分类和重构超过130行的代码文件。支持 Rust, Python, C++, JavaScript, Markdown。使用 Git 策略管理版本,自动串行调用语言专项子skill,一键完成所有重构任务。
npx skillsauth add develata/deve-skills code-shortersInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
自动化代码模块化重构工具,用于将大型代码文件拆分为符合"130行铁律"的模块化结构。
此 Skill 是一个主调度器,负责:
当用户需要:
首先验证 Git 仓库状态,确保版本安全:
# 执行 Git 检查
python scripts/git_checker.py
检查规则:
.git 目录)git status --porcelain 检测)扫描指定目录(默认当前目录),识别所有代码文件:
# 执行扫描
python scripts/main_analyzer.py --path . --recursive
扫描支持的语言后缀:
.rs.py.cpp, .h, .hpp.js, .ts, .jsx, .tsx.md计算每个文件的总行数,包含注释行和代码行:
语言特定注释规则:
//, /* */#, """""//, /* *///, /* */<!-- -->集成多语言 lint 工具计算复杂度:
| 语言 | Lint 工具 | 命令 |
|------|-----------|-------|
| Rust | cargo clippy | cargo clippy --message-format=json |
| Python | pylint | pylint --output-format=json |
| C++ | cpplint | cpplint --output-format=json5 |
| JavaScript | eslint | eslint --format=json |
优先级评分公式:
Priority Score = (行数 × 0.4) + (复杂度 × 0.3) + (嵌套深度 × 0.2) + (函数数量 × 0.1)
生成 JSON 格式的分类报告:
{
"warning_files": [
{"path": "src/parser.rs", "language": "rust", "lines": 145, "priority": 58.0},
{"path": "lib/database.rs", "language": "rust", "lines": 189, "priority": 75.6}
],
"critical_files": [
{"path": "src/main.rs", "language": "rust", "lines": 320, "priority": 128.0},
{"path": "server/handler.rs", "language": "rust", "lines": 412, "priority": 164.8}
],
"statistics": {
"total_files": 5,
"warning_count": 2,
"critical_count": 2
}
}
按照优先级顺序,自动调用对应的语言专项子skill:
# 批处理模式(方案 B)
python scripts/batch_refactor.py
当 code-shorters 主 Skill 调用此 Skill 时:
| 检测到的语言 | 调用的子 Skill | 子 Skill 路径 |
|--------------|---------------|--------------|
| Rust (.rs) | rust-shorter | code-shorters/rust-shorter/ |
| Python (.py) | python-shorter | code-shorters/python-shorter/ |
| C++ (.cpp/.h) | cpp-shorter | code-shorters/cpp-shorter/ |
| JS/TS (.js/.ts) | js-shorter | code-shorters/js-shorter/ |
| Markdown (.md) | md-shorter | code-shorters/md-shorter/ |
Git 环境检查工具。
多层级语言检测工具。
精确的行数统计工具(包含注释)。
多语言复杂度检测工具。
可视化报告生成器。
批处理重构调度器。
主入口脚本。
--path <directory> # 指定扫描路径(默认当前目录)
--recursive # 递归扫描子目录
--exclude <pattern> # 排除文件/目录
--include-only <lang> # 只扫描指定语言
--no-complexity # 跳过复杂度检测
--linter-path <path> # 指定 lint 工具路径
--output-dir <directory> # 输出报告目录
--report-format <format> # 报告格式:markdown 或 html
A: 显示警告信息并继续执行,仅按行数排序。
A: 每个子skill都会在重构后自动验证。
A: 重构前检查 Git 状态,重构后自动提交。
tools
Collect and audit Codex token usage with a bundled Python CLI and optional Windows batch launchers. Use this skill when the user asks to check Codex token usage, generate daily token audit logs, calculate monthly CostUSD totals, review Codex spending, or run Codex token usage scripts on Windows, Bash, WSL, or Linux.
tools
Use when giving the user an INLINE reply that carries a trade-off, a decision, a verdict, or a non-trivial finding (decision brief / round verdict / failure root-cause). NOT for "done"/status confirmations, one-line answers, or pure data dumps. Forces a compact decision-brief shape and blocks internal tool-name / file-path bleed into user-facing text.
development
Use for cross-file or cross-chapter terminology audits and corpus-wide term unification in thesis/paper sources — extract candidate term drift, build a decision queue, classify each occurrence, apply accepted replacements safely, and verify counts/build. Trigger on "术语审计", "术语统一", "术语一致性", "逐词审", "这个词全文怎么用", "把 X 全文改成 Y", "terminology audit", or "unify term X". Do NOT use for ordinary prose drafting or a single known-location edit; use academic-writing for prose quality and claim-boundary judgment.
tools
Use for ANY codex CLI dispatch via dispatch wrapper (no time threshold; presence-of-risk triggers, not estimated wall — stdin-EOF stalls occur at <60s). Combines internal log-inactivity watchdog wrapper + external Claude-session cron probe + sentinel hook enforcement. Detects stalls in ≤60-270s vs hours-without-detection failure mode.