Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Ll Find Dead Code

ASecurity

Analyze codebase for deprecated, unused, or dead code that can be safely removed

6 stars
0 votes
0 copies
0 views
Added 10/6/2026
ai-agentsgobashgitapi

Works with

api

Security Analysis

A100/100

Scanned 10/6/2026

$npx -y skills add BrennonTWilliams/little-loops --skill ll-find-dead-code --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ll Find Dead Code?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Ll Find Dead Code
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/brennontwilliams-ll-find-dead-code/badge)](https://www.skillsdirectory.com/skills/brennontwilliams-ll-find-dead-code)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: ll-find-dead-code
description: Analyze codebase for deprecated, unused, or dead code that can be safely removed
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Bash(ruff:*)
---

# Find Dead Code

You are tasked with analyzing the codebase to identify deprecated, unused, or dead code that can be safely removed.

## Configuration

This command uses project configuration from `.ll/ll-config.json`:
- **Source directory**: `{{config.project.src_dir}}`
- **Focus directories**: `{{config.scan.focus_dirs}}`
- **Exclude patterns**: `{{config.scan.exclude_patterns}}`

## Process

### 1. Initial Scan

Analyze the codebase for potential dead code in these categories:

#### Unused Imports
```bash
# Use ruff or similar to find unused imports
ruff check {{config.project.src_dir}} --select F401 --output-format text
```

#### Unused Variables
```bash
# Find unused local variables
ruff check {{config.project.src_dir}} --select F841 --output-format text
```

#### Unused Functions/Methods
Look for functions that are:
- Never called within the codebase
- Not exported via `__all__`
- Not used as callbacks or handlers
- Not part of a public API

#### Unreachable Code
Look for:
- Code after return/raise statements
- Conditions that are always True/False
- Deprecated branches guarded by version checks

### 2. Cross-Reference Analysis

For each potential dead code item:

1. **Search for usages** across the entire codebase
2. **Check for dynamic usage** (string-based imports, getattr, etc.)
3. **Verify not part of public API** (documented, exported, type stubs)
4. **Check for test coverage** (tests may be the only users)

### 3. Categorize Findings

Group findings by confidence level:

#### High Confidence (Safe to Remove)
- Unused imports with no side effects
- Unreachable code after return
- Variables assigned but never used
- Private functions with zero callers

#### Medium Confidence (Needs Review)
- Functions only called in tests
- Deprecated code with removal date passed
- Code guarded by feature flags that are always False

#### Low Confidence (Manual Verification Required)
- Potentially used via dynamic imports
- Callback handlers registered elsewhere
- API functions that may have external callers

### 4. Output Format

```markdown
# Dead Code Analysis Report

## Summary
- **Files scanned**: X
- **High confidence items**: Y
- **Medium confidence items**: Z
- **Low confidence items**: W

## High Confidence (Safe to Remove)

### Unused Imports

| File | Line | Import | Reason |
|------|------|--------|--------|
| path/to/file.py | 5 | `from x import y` | Never used |

### Unused Functions

| File | Line | Function | Reason |
|------|------|----------|--------|
| path/to/file.py | 42 | `_helper()` | Zero callers |

### Unreachable Code

| File | Lines | Description |
|------|-------|-------------|
| path/to/file.py | 100-105 | Code after return |

## Medium Confidence (Review Needed)

[Similar tables with additional context]

## Low Confidence (Manual Check)

[Similar tables with investigation notes]

## Recommended Actions

1. Run `/ll:check-code` after removals
2. Run `/ll:run-tests all` to verify no regressions
3. Consider deprecation warnings before removing public APIs
```

### 5. Issue Creation (Optional)

After generating the report, offer to create enhancement issues for tracking dead code cleanup tasks.

#### Issue Type and Priority

All dead code findings create **ENH** (enhancement) issues:

| Finding Confidence | Priority | Rationale |
|-------------------|----------|-----------|
| High confidence (safe to remove) | P4 | Low-risk cleanup |
| Medium confidence (needs review) | P5 | Requires investigation |
| Low confidence | Skip | Manual verification first |

**Note**: Low confidence findings do NOT create issues automatically - they require human verification before tracking.

#### Grouping Strategy

Group related findings into single issues to avoid issue spam:

| Dead Code Type | Grouping Strategy | Example Title |
|----------------|-------------------|---------------|
| Unused imports (same file) | Per file | "Remove 5 unused imports from `module.py`" |
| Unused imports (same package) | Per package | "Clean up unused imports in `utils/` package" |
| Unused private functions | Per file | "Remove unused private functions in `helpers.py`" |
| Unused public functions | Individual | "Consider removing unused function `calculate_legacy()`" |
| Unreachable code | Individual | "Remove unreachable code after return in `parser.py:142`" |

#### Issue File Format

Created issues follow the standard format with audit metadata:

```markdown
---
discovered_commit: [GIT_HASH]
discovered_branch: [BRANCH_NAME]
discovered_date: [ISO_TIMESTAMP]
discovered_by: find-dead-code
confidence: [high|medium]
---

# ENH-XXX: [Title based on grouping]

## Summary

Dead code cleanup task identified by `/ll:find-dead-code`.

## Location

- **File**: `path/to/file.py`
- **Line(s)**: 42-45

## Findings

| Item | Type | Confidence | Reason |
|------|------|------------|--------|
| `unused_import` | Import | High | Never referenced |
| `_old_helper()` | Function | High | Zero callers |

## Proposed Solution

Remove the identified dead code items.

## Verification

After removal:
1. Run `/ll:check-code all`
2. Run `/ll:run-tests`

## Impact

- **Severity**: Low
- **Effort**: Small
- **Risk**: Low (high confidence items)

## Labels

`enhancement`, `cleanup`, `dead-code`, `auto-generated`

---

## Status

**Open** | Created: [DATE] | Priority: P4
```

### 6. User Approval

Before creating issues, present a summary for user approval:

```markdown
## Proposed Issue Creation

Based on dead code analysis, the following ENH issues will be created:

### Issues to Create (N)

| Priority | Title | Findings | Files |
|----------|-------|----------|-------|
| P4 | Remove unused imports from `utils.py` | 5 imports | 1 |
| P4 | Remove unused function `_legacy_calc()` | 1 function | 1 |
| P5 | Review potentially unused `api_handler()` | 1 function | 1 |

### Skipped (Low Confidence)

The following findings require manual verification and will NOT create issues:
- `dynamic_loader()` in `plugins.py` - may be used via getattr
- `callback_handler()` in `events.py` - registered externally

---

**Create these enhancement issues?**
- [y] Create all listed issues
- [n] Skip issue creation, keep report only
- [s] Select specific issues to create
```

Wait for user confirmation before writing any issue files.

### 7. Create Issue Files

After user approval:

1. **Get next issue number** (globally unique across ALL types):
   ```bash
   ll-issues next-id
   ```

2. **Generate filenames** using the pattern: `P[4-5]-ENH-[NNN]-[slug].md`

3. **Write files** to `.issues/enhancements/`

4. **Stage for commit**: stage only the files written in step 3, by their explicit paths.
   Do **not** `git add .issues/enhancements/` — a directory-level stage sweeps in unrelated
   untracked/modified files (BUG-1976).
   ```bash
   git add "<each written issue-file-path>"   # repeat per file from step 3
   ```

5. **Output summary**:
   ```
   Created N enhancement issues:
   - P4-ENH-015-remove-unused-imports-utils.md
   - P4-ENH-016-remove-unused-function-legacy-calc.md
   - P5-ENH-017-review-api-handler.md

   Run `/ll:commit` to commit these issues.
   ```

---

## Examples

```bash
# Find all dead code
/ll:find-dead-code

# After review, remove high-confidence items
# Then run verification:
/ll:check-code all
/ll:run-tests all
```

---

## Integration

After finding dead code:
1. Review the report carefully
2. **Create ENH issues** for tracking (optional, requires approval)
3. Start with high-confidence items
4. Run tests after each batch of removals
5. Consider deprecation for public APIs
6. Use `/ll:commit` to save changes

Works well with:
- `/ll:scan-codebase` - May find overlapping issues
- `/ll:check-code` - Verify code quality after removals
- `/ll:run-tests` - Ensure no regressions

Attribution

BrennonTWilliamsBrennonTWilliams
View sourceSee grades on GitHubMore from BrennonTWilliams →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →