AgentSkillsCN

bloat-detector

通过渐进式分析检测代码库的冗余:包括死代码、代码重复、复杂度攀升以及文档膨胀。适用于上下文使用率较高、季度性维护、发布前清理,或在重构之前使用。切勿在活跃功能开发期间、面对时间敏感的Bug,或当代码库规模不足1000行时使用此技能。

SKILL.md
--- frontmatter
name: bloat-detector
description: 'Detect codebase bloat through progressive analysis: dead code, duplication,
  complexity, documentation bloat. Use when context usage high, quarterly maintenance,
  pre-release cleanup, before refactoring. Do not use when active feature development,
  time-sensitive bugs, codebase < 1000 lines.'
category: conservation
tags:
- bloat
- cleanup
- static-analysis
- technical-debt
- optimization
tools:
- Bash
- Grep
- Glob
- Read
modules:
- quick-scan
- git-history-analysis
- code-bloat-patterns
- ai-generated-bloat
- documentation-bloat
- static-analysis-integration
- remediation-types
progressive_loading: true
estimated_tokens: 400
version: 1.4.0

Table of Contents

Bloat Detector

Systematically detect and eliminate codebase bloat through progressive analysis tiers.

Bloat Categories

CategoryExamples
CodeDead code, God classes, Lava flow, duplication
AI-GeneratedTab-completion bloat, vibe coding, hallucinated deps
DocumentationRedundancy, verbosity, stale content, slop
DependenciesUnused imports, dependency bloat, phantom packages
Git HistoryStale files, low-churn code, massive single commits

Quick Start

Tier 1: Quick Scan (2-5 min, no tools)

bash
/bloat-scan

Detects: Large files, stale code, old TODOs, commented blocks, basic duplication

Tier 2: Targeted Analysis (10-20 min, optional tools)

bash
/bloat-scan --level 2 --focus code   # or docs, deps

Adds: Static analysis (Vulture/Knip), git churn hotspots, doc similarity

Tier 3: Deep Audit (30-60 min, full tooling)

bash
/bloat-scan --level 3 --report audit.md

Adds: Cross-file redundancy, dependency graphs, readability metrics

When To Use

DoDon't
Context usage > 30%Active feature development
Quarterly maintenanceTime-sensitive bugs
Pre-release cleanupCodebase < 1000 lines
Before major refactoringTools unavailable (Tier 2/3)

When NOT To Use

  • Active feature development
  • Time-sensitive bugs
  • Codebase < 1000 lines

Confidence Levels

LevelConfidenceAction
HIGH90-100%Safe to remove
MEDIUM70-89%Review first
LOW50-69%Investigate

Prioritization

code
Priority = (Token_Savings × 0.4) + (Maintenance × 0.3) + (Confidence × 0.2) + (Ease × 0.1)

Module Architecture

Tier 1 (always available):

  • See modules/quick-scan.md - Heuristics, no tools
  • See modules/git-history-analysis.md - Staleness, churn, vibe coding signatures

Tier 2 (optional tools):

  • See modules/code-bloat-patterns.md - Anti-patterns (God class, Lava flow)
  • See modules/ai-generated-bloat.md - AI-specific patterns (Tab bloat, hallucinations)
  • See modules/documentation-bloat.md - Redundancy, readability, slop detection
  • See modules/static-analysis-integration.md - Vulture, Knip

Shared:

  • See modules/remediation-types.md - DELETE, REFACTOR, CONSOLIDATE, ARCHIVE

Auto-Exclusions

Always excludes: .venv, __pycache__, .git, node_modules, dist, build, vendor

Also respects: .gitignore, .bloat-ignore

Safety

  • Never auto-delete - all changes require approval
  • Dry-run support - --dry-run for previews
  • Backup branches - created before bulk changes

Related

  • bloat-auditor agent - Executes scans
  • unbloat-remediator agent - Safe remediation
  • context-optimization skill - MECW principles