bloat-detector
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTable of Contents
目录
Bloat Detector
代码膨胀检测器
Systematically detect and eliminate codebase bloat through progressive analysis tiers.
通过渐进式分析层级,系统性地检测并消除代码库膨胀问题。
Bloat Categories
代码膨胀类别
| Category | Examples |
|---|---|
| Code | Dead code, God classes, Lava flow, duplication |
| AI-Generated | Tab-completion bloat, vibe coding, hallucinated deps |
| Documentation | Redundancy, verbosity, stale content, slop |
| Dependencies | Unused imports, dependency bloat, phantom packages |
| Git History | Stale files, low-churn code, massive single commits |
| 类别 | 示例 |
|---|---|
| 代码类 | Dead code, God classes, Lava flow, 代码重复 |
| AI生成类 | 自动补全冗余、Vibe coding、幻觉依赖 |
| 文档类 | 文档冗余、冗长表述、过时内容、Slop |
| 依赖类 | 未使用的导入、依赖膨胀、幽灵包 |
| Git历史类 | 陈旧文件、低变更频率代码、超大单次提交 |
Quick Start
快速开始
Tier 1: Quick Scan (2-5 min, no tools)
Tier 1: 快速扫描(2-5分钟,无需工具)
bash
/bloat-scanDetects: Large files, stale code, old TODOs, commented blocks, basic duplication
bash
/bloat-scan检测内容:大文件、陈旧代码、过时TODO、注释代码块、基础代码重复
Tier 2: Targeted Analysis (10-20 min, optional tools)
Tier 2: 定向分析(10-20分钟,可选工具)
bash
/bloat-scan --level 2 --focus code # or docs, depsAdds: Static analysis (Vulture/Knip), git churn hotspots, doc similarity
bash
/bloat-scan --level 2 --focus code # or docs, deps新增检测:静态分析(Vulture/Knip)、Git变更热点、文档相似度
Tier 3: Deep Audit (30-60 min, full tooling)
Tier 3: 深度审计(30-60分钟,完整工具链)
bash
/bloat-scan --level 3 --report audit.mdAdds: Cross-file redundancy, dependency graphs, readability metrics
bash
/bloat-scan --level 3 --report audit.md新增检测:跨文件冗余、依赖图谱、可读性指标
When To Use
适用场景
| Do | Don't |
|---|---|
| Context usage > 30% | Active feature development |
| Quarterly maintenance | Time-sensitive bugs |
| Pre-release cleanup | Codebase < 1000 lines |
| Before major refactoring | Tools unavailable (Tier 2/3) |
| 适用 | 不适用 |
|---|---|
| 上下文使用率 > 30% | 功能开发活跃期 |
| 季度维护 | 处理时间敏感型Bug |
| 发布前清理 | 代码库规模 < 1000行 |
| 重大重构前 | 工具不可用(Tier 2/3) |
When NOT To Use
不适用场景
- Active feature development
- Time-sensitive bugs
- Codebase < 1000 lines
- 功能开发活跃期
- 处理时间敏感型Bug
- 代码库规模 < 1000行
Confidence Levels
置信度等级
| Level | Confidence | Action |
|---|---|---|
| HIGH | 90-100% | Safe to remove |
| MEDIUM | 70-89% | Review first |
| LOW | 50-69% | Investigate |
| 等级 | 置信度 | 操作建议 |
|---|---|---|
| 高 | 90-100% | 可安全移除 |
| 中 | 70-89% | 先进行评审 |
| 低 | 50-69% | 深入调查 |
Prioritization
优先级计算
Priority = (Token_Savings × 0.4) + (Maintenance × 0.3) + (Confidence × 0.2) + (Ease × 0.1)Priority = (Token_Savings × 0.4) + (Maintenance × 0.3) + (Confidence × 0.2) + (Ease × 0.1)Module Architecture
模块架构
Tier 1 (always available):
- See - Heuristics, no tools
modules/quick-scan.md - See - Staleness, churn, vibe coding signatures
modules/git-history-analysis.md
Tier 2 (optional tools):
- See - Anti-patterns (God class, Lava flow)
modules/code-bloat-patterns.md - See - AI-specific patterns (Tab bloat, hallucinations)
modules/ai-generated-bloat.md - See - Redundancy, readability, slop detection
modules/documentation-bloat.md - See - Vulture, Knip
modules/static-analysis-integration.md
Shared:
- See - DELETE, REFACTOR, CONSOLIDATE, ARCHIVE
modules/remediation-types.md
Tier 1(始终可用):
- 查看 - 启发式分析,无需工具
modules/quick-scan.md - 查看 - 代码陈旧度、变更频率、Vibe coding特征
modules/git-history-analysis.md
Tier 2(可选工具):
- 查看 - 反模式(God class, Lava flow)
modules/code-bloat-patterns.md - 查看 - AI专属膨胀模式(自动补全冗余、幻觉依赖)
modules/ai-generated-bloat.md - 查看 - 文档冗余、可读性、Slop检测
modules/documentation-bloat.md - 查看 - Vulture, Knip
modules/static-analysis-integration.md
通用模块:
- 查看 - DELETE、REFACTOR、CONSOLIDATE、ARCHIVE
modules/remediation-types.md
Auto-Exclusions
自动排除项
Always excludes: , , , , , ,
.venv__pycache__.gitnode_modulesdistbuildvendorAlso respects: ,
.gitignore.bloat-ignore默认排除目录:, , , , , ,
.venv__pycache__.gitnode_modulesdistbuildvendor同时遵循:, 配置规则
.gitignore.bloat-ignoreSafety
安全保障
- Never auto-delete - all changes require approval
- Dry-run support - for previews
--dry-run - Backup branches - created before bulk changes
- 绝不自动删除 - 所有变更需人工审批
- 支持试运行 - 使用 参数预览变更效果
--dry-run - 备份分支 - 批量变更前自动创建备份分支
Related
相关工具
- agent - Executes scans
bloat-auditor - agent - Safe remediation
unbloat-remediator - skill - MECW principles
context-optimization
- agent - 执行扫描任务
bloat-auditor - agent - 安全修复代码膨胀
unbloat-remediator - skill - 遵循MECW原则
context-optimization