/shavakan-commands:cleanupfrom shavakan-commands
Comprehensive repository audit and cleanup (dead code, comments, docs, architecture, deps)
Ships in shavakan-commands. Installing the plugin adds it to Claude Code.
Scan the codebase for cleanup opportunities across all categories. Generate comprehensive report, then execute improvements based on user priorities.
Safety requirements:
Run prerequisite check:
PLUGIN_ROOT="$HOME/.claude/plugins/marketplaces/shavakan"
if [[ ! "$PLUGIN_ROOT" =~ ^"$HOME"/.* ]]; then
echo "ERROR: Invalid plugin root path"
exit 1
fi
PREREQ_SCRIPT="$PLUGIN_ROOT/commands/cleanup/scripts/check-prerequisites.sh"
if [[ ! -f "$PREREQ_SCRIPT" ]]; then
echo "ERROR: Prerequisites script not found"
exit 1
fi
PREREQ_OUTPUT=$(mktemp)
if "$PREREQ_SCRIPT" > "$PREREQ_OUTPUT" 2>&1; then
source "$PREREQ_OUTPUT"
rm "$PREREQ_OUTPUT"
else
cat "$PREREQ_OUTPUT"
rm "$PREREQ_OUTPUT"
exit 1
fi
This exports: TEST_CMD, BACKUP_BRANCH, LOG_FILE
$ARGUMENTS
Perform comprehensive audit of codebase for cleanup opportunities across all categories, then execute selected improvements systematically.
Before scanning, build a capability matrix and surface it in the audit header so the user knows the confidence floor.
Run the bundled probe:
"$CLAUDE_PLUGIN_ROOT/cleanup/scripts/probe-tooling.sh" --pretty
The probe emits JSON with languages, linters, type_check, structural, complexity, test_cmd. Capture it and reference fields in subsequent phases.
Cross-reference with LSP MCP availability (the probe can't see this — it lives in your tool inventory, not the shell). Probe for tools exposing find_references, document_symbols, workspace_symbols, call_hierarchy_*, or diagnostics. If present, downstream subcommands (cleanup-dead-code, cleanup-architecture, cleanup-duplication, cleanup-deps) prefer LSP over grep.
Audit header format:
Detection: LSP MCP ✓ (typescript-language-server) | linters: eslint, ruff | structural: madge | confidence: high
If neither LSP MCP nor linters are available, mark dead-code/architecture findings as confidence: grep-only so the user weights them appropriately.
Scan entire codebase for cleanup opportunities across all categories. For each category, identify issues with location, severity, and estimated impact.
Present audit findings grouped by category with counts. Include priority assessment:
Gate: User must review full audit before proceeding.
Present cleanup options with impact assessment:
Execute cleanup operations?
□ Critical only - Security fixes + blocking issues
□ Safe cleanups - Dead code + unused imports + obvious comments
□ Structural - Architecture + dead code + duplication
□ Full cleanup - All categories (comprehensive)
□ Custom - Select specific categories
□ Cancel
Gate: Get user approval on which categories to clean.
IMPORTANT: This command orchestrates by invoking specialized subcommands. Do not implement cleanup logic directly - use the subcommands:
/shavakan-commands:cleanup-deps/shavakan-commands:cleanup-architecture/shavakan-commands:cleanup-dead-code/shavakan-commands:cleanup-comments/shavakan-commands:cleanup-duplication/shavakan-commands:cleanup-docsExecution order: Security first, then structural improvements, then code quality, then documentation/maintenance.
Between each subcommand: Verify tests pass. If passing, proceed to next. If failing, rollback and report issue. User can cancel at any point.
Gate: Tests must pass after each subcommand before proceeding.
Summarize metrics (lines reduced, files removed, issues resolved), what was cleaned (by category with counts), impact analysis (code coverage maintained, build size reduced, maintainability improved).
Delete the backup branch after successful completion:
git branch -D "$BACKUP_BRANCH"
Note: All commits granular and revertable.
For safe automated fixes, execute:
Each fix tested independently. Rollback on any test failure. Commit each fix type separately.
CRITICAL:
Error handling: If cleanup fails, report which categories completed successfully (with commits), which category failed (with error), and offer options: skip failed category and continue, stop to investigate, or rollback all changes.
Review with code-reviewer agent before pushing:
Use shavakan-agents:code-reviewer to verify all changes.
Final verification: Run full test suite, check build succeeds, review commits, update CHANGELOG if significant changes.
/shavakan-commands:cleanup-dead-code - Remove unused code/shavakan-commands:cleanup-deps - Manage dependencies/shavakan-commands:cleanup-comments - Clean up comments/shavakan-commands:cleanup-docs - Fix documentation/shavakan-commands:cleanup-architecture - Refactor structure/shavakan-commands:cleanup-duplication - Remove duplicationWhat the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
12 commands in this plugin
/cleanup-architectureRefactor ArchitectureRefactor structure - split god objects, break circular deps, improve separation of concerns/cleanup-commentsRemove Comment NoiseRemove obvious comments, commented code, outdated TODOs - keep 'why' explanations/cleanup-dead-codeRemove Dead CodeRemove unused imports, functions, variables, commented blocks, unreachable codenpx claudepluginhub shavakan/claude-marketplace --plugin shavakan-commandsOther plugins' commands for the same job