xiaohongshu
xiaohongshu
codebase-health-auditor
Unified dead code detection, AST-based duplicate detection, and cleanup tool combining Legacy Tech Remover + Comprehensive Auditor + Architectural Cleanup with Knip, depcheck, TypeScript, Vue-specific analysis, file size/token limit detection, and AST-powered refactoring suggestions. Use for dead...
Full skill instructions
Comprehensive dead code detection and safe cleanup for Vue 3 + TypeScript projects.
A unified skill that merges the best of Legacy Tech Remover and Comprehensive Auditor while adding modern tooling:
# Full audit (dry-run by default)
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js audit
# Execute safe removals only
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js execute --safe-only
# Single detector
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js detect --detector vue
# CI mode
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js audit --ci
noUnusedLocals/noUnusedParameters were enabledDetects files that exceed token limits for AI editing tools like Claude Code.
Why this matters: Files over ~25,000 tokens become difficult or impossible for AI tools to edit effectively, causing truncation, context loss, and failed edits.
| Level | Tokens | ~Size | Meaning |
|---|---|---|---|
| WARNING | 15,000 | ~60KB | Getting large, monitor |
| CAUTION | 25,000 | ~100KB | Needs attention |
| CRITICAL | 35,000 | ~140KB | Urgent refactoring needed |
| BLOCKED | 50,000 | ~200KB | Blocks AI editing entirely |
# Detect oversized files
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js detect --detector file-size
# Custom threshold (e.g., only 20K+ tokens)
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js detect --detector file-size --min-tokens 20000
# Save report to file
node .claude/skills/codebase-health-auditor/scripts/orchestrator.js detect --detector file-size --output ./audit-reports/file-size.json
📊 File Size Detection Results
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Files scanned: 156
Files over threshold: 3
By Risk Level:
🔴 CRITICAL: 1 files
🟡 CAUTION: 2 files
──────────────────────────────────────────────────
Detailed Findings:
🔴 src/views/CanvasView.vue
Tokens: 38,500 | Lines: 2,847 | Size: 154.2KB
Suggestions:
• 🔴 CRITICAL - High priority refactoring needed
• Extract script logic into composables (src/composables/)
• Split into smaller child components
• URGENT: Major component decomposition needed
• Consider: extract state to Pinia store
🟡 src/stores/canvas.ts
Tokens: 28,200 | Lines: 1,245 | Size: 112.8KB
Suggestions:
• Split store into feature-specific modules
• Extract actions/getters into separate files
The detector provides context-aware suggestions based on file type:
Vue Components (.vue):
TypeScript/JavaScript (.ts/.js):
Each finding is categorized by risk level:
| Category | Score | Meaning | Action |
|---|---|---|---|
| SAFE | < 20 | Zero usage, high confidence | Auto-remove OK |
| CAUTION | 20-60 | Low/uncertain usage | Manual review |
| RISKY | > 60 | Possible indirect use | Migration needed |
| Factor | Weight | Description |
|---|---|---|
| Usage Count | 30% | How many imports reference this |
| Last Modified | 15% | Git history recency |
| Test Coverage | 20% | Is the code tested? |
| Import Depth | 15% | Transitive dependency depth |
| File Type | 10% | Config files riskier than components |
| Tool Agreement | 10% | Multiple tools agree = higher confidence |
┌─────────────────────────────────────────┐
│ PHASE 1: DETECTION │
│ - Run all detectors in parallel │
│ - Deduplicate findings │
│ - Tag source (knip/depcheck/vue/etc) │
└───────────────────┬─────────────────────┘
▼
┌─────────────────────────────────────────┐
│ PHASE 2: ASSESSMENT │
│ - Calculate risk scores │
│ - Build dependency graph │
│ - Categorize: SAFE / CAUTION / RISKY │
└───────────────────┬─────────────────────┘
▼
┌─────────────────────────────────────────┐
│ PHASE 3: ACTION (if --execute) │
│ - Create backup branch │
│ - Remove SAFE items in batches │
│ - Validate build after each batch │
│ - Prompt for CAUTION items │
└───────────────────┬─────────────────────┘
▼
┌─────────────────────────────────────────┐
│ PHASE 4: REPORTING │
│ - Generate JSON report │
│ - Generate Markdown summary │
│ - CI exit codes │
└─────────────────────────────────────────┘
Create .claude/codebase-health-config.yml:
detection:
knip:
enabled: true
ignore: ["**/*.test.ts", "**/*.stories.ts"]
depcheck:
enabled: true
ignoreMatches: ["@types/*"]
typescript:
enabled: true
noUnusedLocals: true
noUnusedParameters: true
vue:
enabled: true
detectUnusedProps: true
detectUnusedEmits: true
detectUnusedComputed: true
detectUnusedWatchers: true
legacy:
enabled: true
minYearsUntouched: 2
assessment:
riskThresholds:
safe: 20
caution: 60
protectedPaths:
- "src/main.ts"
- "src/App.vue"
- "src/stores/**"
protectedPackages:
- "vue"
- "pinia"
- "vue-router"
- "typescript"
actions:
defaultMode: "dry-run"
batchSize: 5
validateAfterBatch: true
gitIntegration:
autoCommit: true
commitPrefix: "[codebase-health]"
createBackupBranch: true
reporting:
formats: ["json", "markdown"]
outputDir: "./audit-reports"
includeBlindSpots: true
Codebase Health Audit Complete
Findings:
SAFE (auto-remove OK): 23 items
CAUTION (review needed): 18 items
RISKY (migration needed): 6 items
By Category:
Unused exports: 15
Unused dependencies: 8
Unused Vue props: 12
Legacy patterns: 6
Orphaned files: 6
Estimated Impact:
Files to remove: 12
Lines of code: 1,847
Bundle savings: ~245KB
Run with --execute --safe-only to remove safe items.
{
"metadata": {
"timestamp": "2026-01-09T...",
"version": "1.0.0",
"executionTime": 45.2
},
"summary": {
"totalFindings": 47,
"byRisk": { "SAFE": 23, "CAUTION": 18, "RISKY": 6 },
"byType": { "unused-export": 15, "unused-dependency": 8 }
},
"findings": [...]
}
--executebackup/health-audit-YYYYMMDD before changesnpm run build after each batch// @codebase-health-ignore: Used dynamically
export const unusedButNeeded = ...;
detection:
ignore:
- "src/utils/polyfills.ts" # Side-effect imports
- "**/*.generated.ts" # Generated code
import(variable) cannot be statically analyzed$attrs, $slots)This skill supersedes:
🧹 legacy-tech-remover (patterns ported)📊 comprehensive-auditor (static analysis integrated)Works alongside:
dev-lint-cleanup - For ESLint-specific fixesdocument-sync - To update docs after removal| Option | Description |
|---|---|
audit | Run full audit (default: dry-run) |
execute | Execute removal plan |
detect --detector <name> | Run single detector |
list | List available detectors |
--path <path> | Project root directory |
--output <file> | Save JSON report to file |
--min-tokens <number> | Minimum tokens to report (file-size detector) |
--safe-only | Only process SAFE items |
--ci | CI mode with exit codes |
--config <path> | Custom config file |
--output-dir <path> | Report output directory |
--format json,markdown | Report formats |
| Detector | Description |
|---|---|
file-size | Detects files exceeding token limits for AI editing |
More detectors coming: unused-exports, unused-deps, vue-dead-code, legacy-patterns
Version: 1.0.0 Author: Claude Code Category: Code Maintenance Created: January 9, 2026
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience