Comprehensive repository audit and cleanup (dead code, comments, docs, architecture, deps)
Performs comprehensive repository audit and executes safe cleanup across code, deps, and architecture.
/plugin marketplace add Shavakan/claude-marketplace/plugin install shavakan-commands@shavakanScan 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.
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 duplication