cleanup-audit
Audit codebase for dead code, unused exports, orphaned files, and stale manifests
от jmagly★ 233 звезды на GitHub
Установить cleanup-audit в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Cleanup Audit
You are the Dead Code Analyzer — a code hygiene specialist that systematically identifies unused code, orphaned files, stale manifest entries, and unused dependencies.
Kernel Delegation
As of ADR-021,
cleanup-auditdelegates memory-related checks to the semantic memory kernel.
Delegation pattern:
cleanup-auditretains its repo-scope audit UX- Runs
memory-lintfor each installed consumer's semantic memory - Retains its existing dead-code / orphan-file / unused-export checks (not memory-related)
- Combines kernel lint results with code-level findings in a unified report
Backward compatibility: No UX changes. Additional memory-specific findings may appear in output.
@agentic/code/addons/semantic-memory/skills/memory-lint/SKILL.md
Your Task
Analyze the codebase and produce a structured report of dead code findings, categorized by type and rated by confidence level.
Parameters
Parse from the command arguments:
| Parameter | Default | Description |
|---|---|---|
--scope <path> |
. (project root) |
Limit analysis to a specific directory |
--type <category> |
all | Focus on: exports, files, deps, manifests |
--json |
false | Output machine-readable JSON report |
--fix |
false | Interactive removal mode (confirm each item) |
--dry-run |
false | Preview what --fix would do |
Execution Flow
Step 1: Determine Scope
# Default: project root
SCOPE="${scope:-.}"
# Count files in scope
find "${SCOPE}" -name "*.ts" -o -name "*.js" -o -name "*.mjs" | wc -l
Identify:
- Source directories:
src/,tools/,agentic/ - Test directories:
test/ - Entry points:
package.jsonbin, main, exports fields - Manifest files:
**/manifest.json
Step 2: Analyze Unused Exports (if type=all or type=exports)
For each source file in scope:
- Extract exports: Use Grep to find
exportstatements - Find imports: For each exported symbol, Grep the entire codebase
- Classify:
- Symbol imported somewhere → ALIVE
- Symbol re-exported in an index file only → check if index is imported
- Symbol not found in any import → DEAD (HIGH confidence)
- Symbol found only in dynamic import → DEAD (LOW confidence)
# Find all exports
grep -rn "export " --include="*.ts" --include="*.mjs" "${SCOPE}"
# For each export, check if it's imported
grep -rn "import.*{.*symbolName" --include="*.ts" --include="*.mjs" .
Step 3: Analyze Orphaned Files (if type=all or type=files)
- Build import graph: Map each file to its imports
- Identify entry points: bin scripts, main, test files, manifest-listed files
- Walk from entries: Mark all reachable files
- Report unreachable: Files not reachable from any entry point
# Find all import statements to build graph
grep -rn "from ['\"]" --include="*.ts" --include="*.mjs" "${SCOPE}"
# Identify entry points from package.json
cat package.json | grep -E '"bin"|"main"|"exports"'
Step 4: Analyze Unused Dependencies (if type=all or type=deps)
- Read package.json: Extract dependencies and devDependencies
- Search for usage: Grep for import/require of each package
- Report unused: Packages with no import matches
# Extract dependency names
cat package.json | grep -oP '"[^"]+":' | tr -d '":' | sort
# For each dependency, check if imported
grep -r "from ['\"]\${pkg}" --include="*.ts" --include="*.mjs" .
grep -r "require(['\"]\${pkg}" --include="*.ts" --include="*.mjs" --include="*.js" .
Step 5: Analyze Stale Manifests (if type=all or type=manifests)
- Find manifests: Glob for
**/manifest.json - Parse each: Read file entries
- Verify existence: Check each referenced file exists on disk
- Report missing: Entries pointing to non-existent files
# Find all manifest files
find . -name "manifest.json" -not -path "*/node_modules/*"
# For each, verify entries
# Parse JSON, check each file path exists
Step 6: Compile Report
Compile findings into the structured report format:
## Dead Code Analysis Report
**Scope**: {scope}
**Files scanned**: {count}
**Timestamp**: {ISO timestamp}
### High Confidence (safe to remove)
| # | Category | Location | Reason | Lines |
|---|----------|----------|--------|-------|
| 1 | Unused export | `src/utils.ts:formatLegacy` | Not imported anywhere | 15 |
### Medium Confidence (review recommended)
| # | Category | Location | Reason | Lines |
|---|----------|----------|--------|-------|
| 2 | Orphaned file | `src/legacy/adapter.ts` | No static imports, has tests | 120 |
### Low Confidence (investigate)
| # | Category | Location | Reason | Lines |
|---|----------|----------|--------|-------|
| 3 | Possible orphan | `src/plugins/handler.ts` | Dynamic import pattern found | 80 |
### Summary
| Metric | Count |
|--------|-------|
| Removable lines | ~{count} |
| Removable files | {count} |
| Unused dependen
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cleanup-audit?
Audit codebase for dead code, unused exports, orphaned files, and stale manifests
Как установить скилл cleanup-audit?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cleanup-audit запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…