技术债清理
ln-512-tech-debt-cleaner
by levnikolaevich
读取 codebase audit 或 ln-511 输出,按置信度≥90% 自动清理低风险技术债,如未使用导入、死代码、注释块和废弃别名,并生成单个总结 commit。
帮团队自动清掉无用导入、死代码等低风险技术债,90%+置信度才出手,还会汇总成一次提交,省时也更安心
安装
claude skill add --url github.com/levnikolaevich/claude-code-skills/tree/master/ln-512-tech-debt-cleaner文档
Paths: File paths (
shared/,references/,../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
Tech Debt Cleaner (L3 Worker)
Automated cleanup of safe, low-risk tech debt findings from codebase audits.
Purpose & Scope
- Consume audit findings from
docs/project/codebase_audit.md(ln-620 output) or ln-511 code quality output - Filter to auto-fixable findings with confidence >=90%
- Apply safe fixes: remove unused imports, delete dead code, clean commented-out blocks, remove deprecated aliases
- Never touch business logic, complex refactoring, or architectural changes
- Create single commit with structured summary of all changes
- Invocable from ln-510 quality coordinator pipeline or standalone
Auto-Fixable Categories
| Category | Source Prefix | Risk | Auto-Fix Action |
|---|---|---|---|
| Unused imports | MNT-DC- | LOW | Delete import line |
| Unused variables | MNT-DC- | LOW | Delete declaration |
| Unused functions (unexported) | MNT-DC- | LOW | Delete function block |
| Commented-out code (>5 lines) | MNT-DC- | LOW | Delete comment block |
| Backward-compat shims (>6 months) | MNT-DC- | MEDIUM | Delete shim + update re-exports |
| Deprecated aliases | MNT-DC- | LOW | Delete alias line |
| Trailing whitespace / empty lines | MNT- | LOW | Trim / collapse |
NOT Auto-Fixable (skip always)
| Category | Reason |
|---|---|
| DRY violations (MNT-DRY-) | Requires architectural decision on where to extract |
| God classes (MNT-GOD-) | Requires domain knowledge for splitting |
| Security issues (SEC-) | Requires context-specific fix |
| Architecture violations (ARCH-*) | Requires design decision |
| Performance issues (PERF-*) | Requires benchmarking |
| Any finding with effort M or L | Too complex for auto-fix |
When to Use
- Invoked by ln-510-quality-coordinator Phase 3 (after ln-511 code quality check)
- Standalone: After
ln-620codebase audit completes (user triggers manually) - Scheduled: As periodic "garbage collection" for codebase hygiene
Inputs
- Pipeline mode (ln-510): findings from ln-511 code quality output (passed via coordinator context)
- Standalone mode:
docs/project/codebase_audit.md(ln-620 output)
Workflow
-
Load findings: Read
docs/project/codebase_audit.md. Parse findings from Dead Code section (ln-626 results) and Code Quality section (ln-624 results). -
Filter to auto-fixable:
- Category must be in Auto-Fixable table above
- Severity must be LOW or MEDIUM (no HIGH/CRITICAL)
- Effort must be S (small)
- Skip files in:
node_modules/,vendor/,dist/,build/,*.min.*, generated code, test fixtures
-
Verify each finding (confidence check): MANDATORY READ:
shared/references/clean_code_checklist.mdFor each candidate fix: a) Read the target file at specified location b) Confirm the finding still exists (file may have changed since audit) c) Confirm removal is safe:- For unused imports: grep codebase for usage (must have 0 references)
- For unused functions: grep for function name (must have 0 call sites)
- For commented-out code: verify block is code, not documentation
- For deprecated aliases: verify no consumers remain d) Assign confidence score (0-100). Only proceed if confidence >=90
-
Apply fixes (bottom-up within each file):
- Sort fixes by line number descending (bottom-up prevents line shift issues)
- Apply each fix using Edit tool
- Track: file, lines removed, category, original finding ID
-
Verify build integrity: Per
shared/references/ci_tool_detection.mddiscovery hierarchy: detect and run lint + typecheck commands.- If ANY check fails: revert ALL changes (
git checkout .), report failure - If no lint/type commands detected: skip verification with warning
- If ANY check fails: revert ALL changes (
-
Create commit:
- Stage only modified files (explicit
git addper file, notgit add .) - Commit message format:
code
chore: automated tech debt cleanup Removed {N} auto-fixable findings from codebase audit: - {count} unused imports - {count} dead functions - {count} commented-out code blocks - {count} deprecated aliases Source: docs/project/codebase_audit.md Confidence threshold: >=90%
- Stage only modified files (explicit
-
Update audit report:
- Add "Last Cleanup" section to
docs/project/codebase_audit.md:markdown## Last Automated Cleanup **Date:** YYYY-MM-DD **Findings fixed:** N of M auto-fixable **Skipped:** K (confidence <90% or verification failed) **Build check:** PASSED / SKIPPED
- Add "Last Cleanup" section to
Output Format
verdict: CLEANED | NOTHING_TO_CLEAN | BUILD_FAILED
stats:
total_findings: {from audit}
auto_fixable: {filtered count}
applied: {actually fixed}
skipped: {confidence <90 or stale}
reverted: {if build failed, all}
fixes:
- file: "src/utils/helpers.ts"
line: 45
category: "unused_function"
removed: "formatDate()"
finding_id: "MNT-DC-003"
- file: "src/api/v1/auth.ts"
line: 12
category: "deprecated_alias"
removed: "export { newAuth as oldAuth }"
finding_id: "MNT-DC-007"
build_check: PASSED | SKIPPED | FAILED
commit_sha: "abc1234" | null
Critical Rules
- Safety first: Never fix if confidence <90%. When in doubt, skip.
- Bottom-up editing: Always apply fixes from bottom to top of file to avoid line number shifts.
- Build verification: If linter/type-checker fails after fixes, revert ALL changes immediately.
- No business logic: Never modify function bodies, conditionals, or control flow.
- Explicit staging: Stage files by name, never
git add .orgit add -A. - Idempotent: Running twice produces no changes if audit report unchanged.
- Git-aware: Only operate on tracked files. Skip untracked or ignored files.
- Exclusions: Skip generated code, vendor directories, minified files, test fixtures.
Definition of Done
- Audit report loaded and parsed
- Findings filtered to auto-fixable categories
- Each finding verified with confidence >=90%
- Fixes applied bottom-up per file
- Build integrity verified (lint + type check) or skipped with warning
- Single commit created with structured message (or all reverted on build failure)
- Audit report updated with "Last Automated Cleanup" section
- Output YAML returned to caller
Reference Files
- Clean code checklist:
shared/references/clean_code_checklist.md - Audit output schema:
shared/references/audit_output_schema.md - Audit report template:
shared/templates/codebase_audit_template.md
Version: 1.0.0 Last Updated: 2026-02-15
相关 Skills
PPT处理
by anthropics
处理 .pptx 全流程:创建演示文稿、提取和解析幻灯片内容、批量修改现有文件,支持模板套用、合并拆分、备注评论与版式调整。
✎ 涉及PPTX的创建、解析、修改到合并拆分都能一站搞定,连备注、模板和评论也能处理,做演示文稿特别省心。
技能工坊
by anthropics
覆盖 Skill 从创建到迭代优化全流程:起草能力、补测试提示、跑评测与基准方差分析,并持续改写内容和描述,提升效果与触发准确率。
✎ 技能工坊把技能从创建、迭代到评测串成闭环,方差分析加描述优化,特别适合把触发准确率打磨得更稳。
Word文档
by anthropics
覆盖Word/.docx文档的创建、读取、编辑与重排,适合生成报告、备忘录、信函和模板,也能处理目录、页眉页脚、页码、图片替换、查找替换、修订批注及内容提取整理。
✎ 搞定 .docx 的创建、改写与精排版,目录、批量替换、批注修订和图片更新都能自动化,做正式文档尤其省心。
相关 MCP 服务
文件系统
编辑精选by Anthropic
Filesystem 是 MCP 官方参考服务器,让 LLM 安全读写本地文件系统。
✎ 这个服务器解决了让 Claude 直接操作本地文件的痛点,比如自动整理文档或生成代码文件。适合需要自动化文件处理的开发者,但注意它只是参考实现,生产环境需自行加固安全。
by wonderwhy-er
Desktop Commander 是让 AI 直接执行终端命令、管理文件和进程的 MCP 服务器。
✎ 这工具解决了 AI 无法直接操作本地环境的痛点,适合需要自动化脚本调试或文件批量处理的开发者。它能让你用自然语言指挥终端,但权限控制需谨慎,毕竟让 AI 执行 rm -rf 可不是闹着玩的。
EdgarTools
编辑精选by dgunning
EdgarTools 是无需 API 密钥即可解析 SEC EDGAR 财报的开源 Python 库。
✎ 这个工具解决了金融数据获取的痛点——直接让 AI 读取结构化财报,比如让 Claude 分析苹果的 10-K 文件。适合量化分析师或金融开发者快速构建数据管道。但注意,它依赖 SEC 网站稳定性,高峰期可能延迟。