Clean dependencies - remove unused, fix security issues, update outdated, deduplicate
Removes unused packages, fixes security vulnerabilities, updates outdated dependencies, and eliminates duplicates.
/plugin marketplace add Shavakan/claude-marketplace/plugin install shavakan-commands@shavakanRemove unused packages, fix security vulnerabilities, update outdated packages, eliminate duplicate versions.
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
Clean up project dependencies across four categories:
Unused dependencies - Installed but never imported, dev deps not used in build/test
Security vulnerabilities - Packages with known CVEs (critical/high priority)
Outdated dependencies - Packages with newer stable versions, major updates available
Duplicates - Same package at multiple versions, conflicting peer dependencies
Identify package manager (npm/pnpm/yarn/pip/cargo/go) from lockfiles.
Scan dependencies for all four categories. Present findings grouped by category with counts and severity:
Gate: User must see full audit before proceeding.
Present findings with risk assessment:
Offer update strategies:
Choose cleanup strategy:
□ Conservative - Patch only, critical security fixes
□ Moderate - Minor + patch, all security fixes
□ Aggressive - All major updates (extensive testing required)
□ Custom - Select specific categories
□ Cancel
Gate: Get user approval on which categories and strategy level.
For each approved category:
Security vulnerabilities:
Unused dependencies:
Outdated packages:
Duplicates:
Critical safety constraint: One change at a time. Test after each. Commit on success, rollback on failure.
Gate: Tests must pass before moving to next category.
Summarize: vulnerabilities fixed (by severity), unused removed, packages updated (major/minor/patch), duplicates resolved, overall security/maintenance improvement.
Delete the backup branch after successful completion:
git branch -D "$BACKUP_BRANCH"
CRITICAL:
If tests fail: Rollback, check if jumping too many versions, try intermediate version, review release notes for breaking changes.
Review with code-reviewer agent before pushing:
Use shavakan-agents:code-reviewer to verify changes don't introduce issues.
/shavakan-commands:cleanup - Full repository audit/shavakan-commands:cleanup-dead-code - Remove unused code/shavakan-commands:cleanup-architecture - Refactor structure