skills/system/dead-code-cleanup/SKILL.md
Safely find and remove dead code from Swift files using an isolated git worktree. Creates a branch, runs analysis with build verification, and generates a report for review before merge.
npx skillsauth add bzellman/earp-kit dead-code-cleanupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Safely removes dead code from Swift files using git worktree isolation.
/dead-code-cleanup [scope]
/dead-code-cleanup # Full <YOUR_APP>/<YOUR_APP>/ directory
/dead-code-cleanup Features # Only Features/ subdirectory
/dead-code-cleanup Core/Services # Only Core/Services/
| Category | Risk | Verification | |----------|------|--------------| | Unused imports | Low | Build only | | Commented-out code blocks | Low | Build only | | Unused private variables | Low | Build only | | Unused private functions | Medium | Build + Test | | Unreachable code | Medium | Build + Test | | Test-only functions | High | Build + Test | | Unused internal/public functions | High | Build + Test |
Functions that are ONLY called from test files (not production code) are dead code. The tests are testing dead code paths. Both the function and its tests should be removed.
@objc functions (selector calls)Codable/Decodable types@IBAction/@IBOutlet connectionsoverride functionsbody properties (SwiftUI requirement)┌─────────────────────────────────────────────────────────────┐
│ Step 1: Create Isolated Worktree │
│ - Location: ../.worktrees/dead-code-TIMESTAMP │
│ - Branch: dead-code-cleanup-YYYYMMDD │
│ - OUTSIDE main repo to avoid Xcode indexer conflicts │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 2: Run Dead Code Agent │
│ - Scans .swift files in scope │
│ - Distinguishes production vs test usage │
│ - Removes confirmed dead code │
│ - Verifies with builds │
│ - Commits changes │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 3: Report & Review │
│ - Generates DEAD_CODE_REPORT.md │
│ - Shows summary of removals │
│ - User decides: merge / discard │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 4: Cleanup │
│ - Merge to main (if approved) │
│ - Remove worktree │
│ - Delete branch │
└─────────────────────────────────────────────────────────────┘
git checkout main
git merge dead-code-cleanup-YYYYMMDD
git worktree remove ../.worktrees/dead-code-TIMESTAMP
git branch -d dead-code-cleanup-YYYYMMDD
git worktree remove ../.worktrees/dead-code-TIMESTAMP --force
git branch -D dead-code-cleanup-YYYYMMDD
When this skill is invoked:
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
# Create worktree OUTSIDE the main repo to avoid IDE indexer confusion
WORKTREE_PATH="../.worktrees/dead-code-$TIMESTAMP"
BRANCH_NAME="dead-code-cleanup-$(date +%Y%m%d)"
# Ensure parent directory exists
mkdir -p ../.worktrees
# Create worktree from main
git worktree add "$WORKTREE_PATH" -b "$BRANCH_NAME" main
Use the Task tool with subagent_type: general-purpose and model: haiku.
Provide agent prompt from .claude/agents./dead-code-agent.md with:
{{WORKTREE_PATH}} replaced with absolute pathDEAD_CODE_REPORT.mdgit checkout main && git merge $BRANCH_NAMEgit worktree remove $WORKTREE_PATH && git branch -d/-D $BRANCH_NAMEdevops
Use when running 2+ /prd-to-pr or /bug-to-pr pipelines simultaneously, when user says "run these in parallel", "batch these PRDs/bugs", "orchestrate these workflows", or has multiple work items to ship end-to-end concurrently
business
Generate a report about a video
development
Use when the user provides multiple loosely-described items (bugs, features, ideas, fixes) in a single message and wants each researched against the codebase, classified, and turned into a GitHub issue. Handles batch input of mixed-type work items.
development
Comprehensive software architecture skill for designing scalable, maintainable systems across web, mobile, and backend stacks (React, Next.js, Node/Express, React Native, Swift, Kotlin, Flutter, Postgres, GraphQL, Go, Python). Use when designing system architecture, making technical decisions, creating architecture diagrams, evaluating trade-offs, or defining integration patterns.