Skip to content
Agentmart
Submit a tool

dead-code-cleanup

Safely find and remove dead code from Swift files using an isolated git worktree.

Skill by bzellman

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/bzellman-dead-code-cleanup

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

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.

Use cases: documents

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/dead-code-cleanup

What's inside

Skill name
dead-code-cleanup
Description
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.
License
MIT
Instructions
140 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

---
name: dead-code-cleanup
description: 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.
---

# Dead Code Cleanup Skill

Safely removes dead code from Swift files using git worktree isolation.

## What This Does

1. Creates an isolated git worktree OUTSIDE the main repo (avoids IDE indexer conflicts)
2. Spawns a Dead Code Agent to scan and remove dead code
3. Verifies with builds after each removal
4. Generates a comprehensive report
5. Presents results for your review and merge decision

## Usage

```
/dead-code-cleanup [scope]
```

### Examples

```
/dead-code-cleanup                    # Full <YOUR_APP>/<YOUR_APP>/ directory
/dead-code-cleanup Features           # Only Features/ subdirectory
/dead-code-cleanup Core/Services      # Only Core/Services/
```

## What Gets Removed

| 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 |

### Test-Only Functions

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.

## What Gets Skipped

- `@objc` functions (selector calls)
- Protocol conformance methods
- `Codable`/`Decodable` types
- `@IBAction`/`@IBOutlet` connections
- `override` functions
- View `body` properties (SwiftUI requirement)
- PreviewProvider structs (Xcode previews)

## Workflow

```
┌─────────────────────────────────────────────────────────────┐
│  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                                            │
└─────────────────────────────────────────────────────────────┘
```

## After Completion

### To Merge
```bash
git checkout main
git merge dead-code-cleanup-YYYYMMDD
git worktree remove ../.worktrees/dead-code-TIMESTAMP
git branch -d dead-code-cleanup-YYYYMMDD
```

### To Discard
```bash
git worktree remove ../.worktrees/dead-code-TIMESTAMP --force
git branch -D dead-code-cleanup-YYYYMMDD
```

## Implementation Notes (for Claude)

When this skill is invoked:

### Step 1: Create Worktree
```bash
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)"

From bzellman/earp-kit, MIT.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Apr 7, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

Same skill elsewhere

Copies of this SKILL.md published by others; search shows only one of them.

More from bzellman

Cite this page

dead-code-cleanup skill. Agent Mart. https://agentmart.dev/skills/bzellman-dead-code-cleanup (last updated 2026-10-24)