Xpersona
B

bloat-detector

CLAWHUB · Unverified

Detects codebase bloat via dead code, duplication, complexity, and doc bloat scans Skill: bloat-detector Owner: athola Summary: Detects codebase bloat via dead code, duplication, complexity, and doc bloat scans Tags: latest:1.9.19 Version history: v1.9.19 | 2026-08-26T13:09:25.175Z | user Release v1.9.19 v1.9.17 | 2026-07-30T05:31:57.564Z | user Release v1.9.17 v1.9.16 | 2026-07-14T19:48:46.997Z | user Release v1.9.16 v1.9.15 | 2026-07-04T21:22:21.079Z | user Release v1.9.15 v1.9.14 | 2026-06-30T17

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-conserve-bloat-detector
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-athola-nm-conserve-bloat-detector/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

146,733 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: bloat-detector
description: |
  Detects codebase bloat via dead code, duplication, complexity, and doc bloat scans
version: 1.9.8
triggers:
  - bloat
  - cleanup
  - static-analysis
  - technical-debt
  - optimization
  - codebase feels large or before a release
metadata: {"openclaw": {"homepage": "https://github.com/athola/claude-night-market/tree/master/plugins/conserve", "emoji": "\ud83e\udd9e"}}
source: claude-night-market
source_plugin: conserve
---

> **Night Market Skill** — ported from [claude-night-market/conserve](https://github.com/athola/claude-night-market/tree/master/plugins/conserve). For the full experience with agents, hooks, and commands, install the Claude Code plugin.


# 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 |

## 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

| 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) |

## When NOT To Use

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

## Confidence Levels

| Level | Confidence | Action |
|-------|------------|--------|
| HIGH | 90-100% | Safe to remove |
| MEDIUM | 70-89% | Review first |
| LOW | 50-69% | Investigate |

## Prioritization

```
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
- See `modules/growth-analysis.md` - Growth velocity, forecasts, threshold alerts

**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/stat

_meta.json

{
  "ownerId": "kn7d107jg9jv602h9ytsegydq184a42s",
  "slug": "nm-conserve-bloat-detector",
  "version": "1.9.19",
  "publishedAt": 1787749765175
}

modules/ai-generated-bloat.md

---
module: ai-generated-bloat
category: tier-2
dependencies: [Bash, Grep, Read]
estimated_tokens: 200
---

# AI-Generated Bloat Detection Module

Detect bloat patterns specific to AI-assisted coding: vibe coding artifacts, slop patterns, and agent psychosis indicators.

## Why This Module Exists

AI coding has created qualitatively different bloat than traditional development:
- **2024**: First year copy/pasted lines exceeded refactored lines (GitClear)
- **Refactoring**: Dropped from 25% (2021) to <10% (2024), predicted 3% (2025)
- **Duplication**: 8x increase in 5+ line code blocks

## AI Bloat Patterns

### 1. Tab-Completion Bloat (Repetitive Logic)

**Definition**: Same pattern repeated 3+ times instead of abstracted into shared function.

```bash
# Detect similar code blocks (built-in, no external deps)
python3 plugins/conserve/scripts/detect_duplicates.py . --min-lines 5

# JSON output for CI integration
python3 plugins/conserve/scripts/detect_duplicates.py . --format json --threshold 15

# Heuristic: functions with near-identical signatures
grep -rn "^def " --include="*.py" . | cut -d: -f2 | sort | uniq -c | sort -rn | head -10
```

**Confidence**: HIGH (85%)
**Action**: REFACTOR - extract to shared utility
**Rationale**: AI suggests new implementations rather than reusing existing code

### 2. Massive Single Commits (Vibe Coding Signature)

**Definition**: Commits with >500 insertions, especially without proportional tests.

```bash
# Find vibe coding commits
git log --oneline --shortstat | grep -E "[0-9]{3,} insertion" | head -20

# Commits with high insertion:deletion ratio (adding without cleanup)
git log --shortstat --pretty=format:"%h %s" | awk '/insertion|deletion/ {
  ins=$4; del=$6;
  if (ins > 200 && (del == "" || ins/del > 10)) print prev, ins, del
} {prev=$0}'
```

**Confidence**: MEDIUM (70%)
**Action**: INVESTIGATE - review for understanding gaps
**Rationale**: Large additions without refactoring indicate Tab-driven development

### 3. Hallucinated Dependencies

**Definition**: Imports referencing non-existent packages (AI hallucination).

```bash
# Python: Check for uninstallable packages
pip freeze > /tmp/installed.txt
grep -rh "^import \|^from " --include="*.py" . | \
  sed 's/^import //;s/^from //;s/ import.*//' | \
  sort -u | while read pkg; do
    root=$(echo $pkg | cut -d. -f1)
    grep -q "^$root" /tmp/installed.txt || echo "HALLUCINATED?: $pkg"
  done

# JavaScript: Check for phantom packages
jq -r '.dependencies // {} | keys[]' package.json | while read pkg; do
  npm view $pkg version 2>/dev/null || echo "HALLUCINATED?: $pkg"
done
```

**Confidence**: HIGH (95%)
**Action**: DELETE or REPLACE
**Rationale**: AI invents plausible-sounding packages (slopsquatting risk)

### 4. Happy Path Only (Test Coverage Gap)

**Definition**: Code >200 lines with no corresponding tests, or tests without error assertions.

```bash
# Files without test coverage
find . -name "*.py" ! -path "*/test*" \
  -not -path "*/.venv/*" -not -pa

modules/code-bloat-patterns.md

---
module: code-bloat-patterns
category: tier-2
dependencies: [Bash, Grep, Read]
estimated_tokens: 150
---

# Code Bloat Patterns Module

Detect anti-patterns using pattern recognition and heuristics. Works without external tools.

> **Tool Preference (Claude Code 2.1.31+)**: The bash snippets in this module are reference implementations for external script execution or CI pipelines. When performing these analyses directly within Claude Code, prefer native tools: use Grep instead of `grep`, Glob instead of `find`, and Read instead of `cat`/`sed`.

## Anti-Patterns

### 1. God Class
**Definition:** Single class with > 500 lines, > 10 methods, multiple responsibilities.

```bash
# Quick detection
find . -name "*.py" \
  -not -path "*/.venv/*" -not -path "*/__pycache__/*" \
  -not -path "*/node_modules/*" -not -path "*/.git/*" \
  -exec sh -c 'lines=$(wc -l < "$1"); [ $lines -gt 500 ] && echo "GOD_CLASS: $1 - $lines lines"' _ {} \;
```
**Confidence:** HIGH (85%) | **Action:** REFACTOR into focused modules

### 2. Lava Flow
**Definition:** Ancient untouched code - commented blocks, old TODOs.

```bash
# Find files with >20% commented code
grep -rn "^#\|^//" --include="*.py" . | cut -d: -f1 | sort | uniq -c | sort -rn | head -10
```
**Confidence:** HIGH (90%) | **Action:** DELETE commented code

### 3. Dead Code
**Detection:** Use static analysis (Vulture/Knip) or fallback heuristic:
```bash
# Heuristic: find functions with 0 calls
grep -rn "^def " --include="*.py" . | while read line; do
  func=$(echo $line | awk '{print $2}' | cut -d'(' -f1)
  [ $(git grep -c "$func(" 2>/dev/null || echo 0) -eq 1 ] && echo "DEAD: $func"
done
```
**Confidence:** MEDIUM (70%) heuristic, HIGH (90%) with tools | **Action:** DELETE

### 4. Import Bloat
```bash
# Star imports (block tree-shaking)
grep -rn "^from .* import \*" --include="*.py" .

# Unused imports (requires autoflake)
autoflake --check --remove-all-unused-imports -r .
```
**Confidence:** HIGH (95%) | **Action:** Fix imports

### 5. Duplication
**Intra-file:** Hash-based block detection (5+ line matches)
**Cross-file:** Function signature matching
**Semantic:** AST comparison (80%+ similarity)

**Confidence:** HIGH (85%) | **Action:** EXTRACT to shared utility

## Language-Specific

### Python
- Circular imports: Files with 20+ imports
- Deep nesting: > 4 indentation levels

### JavaScript/TypeScript
- Barrel files: `export * from` breaks tree-shaking
- CommonJS in ESM: `module.exports`/`require()` blocks bundler optimization

## AI-Amplified Patterns

These traditional patterns are amplified by AI coding tools:

### 6. Tab-Completion Duplication
**Definition:** AI suggests similar code blocks instead of reusing existing functions.
**2024 Data:** 8x increase in 5+ line duplicated blocks (GitClear)

```bash
# Quick detection: near-identical function signatures
grep -rn "^def " --include="*.py" . | awk -F'def ' '{print $2}' | \
  cut -d'(' -f1 | sort | uniq -c | sort -rn | awk '$1 > 1'
```
**Confidence:** HIG

modules/documentation-bloat.md

---
module: documentation-bloat
category: tier-2
dependencies: [Bash, Grep, Read]
estimated_tokens: 120
---

# Documentation Bloat Module

Detect documentation redundancy, verbosity, and poor readability.

## Detection Categories

### 1. Duplicate Documentation

#### Cross-File (Jaccard Similarity)
```bash
# Quick similarity check between two files
words1=$(tr '[:space:]' '\n' < file1.md | sort -u)
words2=$(tr '[:space:]' '\n' < file2.md | sort -u)
# > 70% overlap = potential duplication
```

| Similarity | Confidence | Action |
|------------|------------|--------|
| > 90% | HIGH (95%) | DELETE one, keep recent |
| 70-90% | MEDIUM (80%) | MERGE, preserve unique |
| 50-70% | LOW (60%) | CROSS-LINK |

#### Intra-File (Section Hashing)
Hash each `##` section's normalized content. Duplicates = repeated sections.

**Confidence:** HIGH (85%)

### 2. Excessive Verbosity

| Metric | Threshold | Action |
|--------|-----------|--------|
| Word count | > 500 words/section | Condense |
| Sentence length | > 25 words avg | Simplify |
| Passive voice | > 30% | Rewrite active |
| Readability | Flesch < 40 | Simplify |

```bash
# Quick verbosity check
wc -w file.md  # Total words
rg -c '\.' file.md  # Approximate sentences (or grep -c)
```

### 3. Stale Documentation

| Signal | Confidence | Action |
|--------|------------|--------|
| Unchanged 12+ months | HIGH (85%) | Review/Archive |
| References deleted code | HIGH (90%) | Update/Delete |
| No git activity | MEDIUM (75%) | Investigate |

```bash
# Find stale docs
git log -1 --format="%ar" -- docs/*.md | rg -E "year|months"
# fallback: grep -E "year|months"
```

### 4. Missing/Outdated References

- Broken internal links: `rg -oP '\[.*?\]\((?!http).*?\)' *.md` (or `grep -oP`)
- References to deleted files
- Outdated API examples

**Confidence:** HIGH (90%) for broken links

## Scoring

```python
def doc_bloat_score(metrics):
    score = 0
    if metrics['duplicate_ratio'] > 0.3: score += 30
    if metrics['avg_words_per_section'] > 500: score += 20
    if metrics['readability'] < 40: score += 15
    if metrics['stale_months'] > 12: score += 25
    return min(100, score)
```

## Output Format

```yaml
file: docs/old-guide.md
bloat_type: [duplicate, verbose, stale]
bloat_score: 72/100
confidence: HIGH
token_estimate: ~1,200
similar_to: docs/guide.md (87%)
action: MERGE
```

## Related
- `quick-scan` - Tier 1 stale detection
- `git-history-analysis` - Activity signals

Sponsored

Ads related to bloat-detector and adjacent AI workflows.