Get the FREE Ultimate OpenClaw Setup Guide →

Orphan File Finder

Scanned
npx machina-cli add skill dcs-soni/awesome-claude-skills/orphan-file-finder --openclaw
Files (1)
SKILL.md
2.7 KB

Orphan File Finder

Detects "orphan" source files—those with no inbound references—to surface potentially unused code.

Why This Matters

  • Reduce Technical Debt: Unused files rot over time and mislead developers.
  • Shrink Bundle Size: Dead code might still be bundled or deployed.
  • Security: Forgotten endpoints or scripts can be attack vectors.

Quick Start

Orphan File Cleanup:
- [ ] Step 1: Scan codebase for orphans
- [ ] Step 2: Review and whitelist entry points
- [ ] Step 3: Archive or delete verified dead files

Workflow

Step 1: Scan for Orphans

Analyze the dependency graph to find files with 0 inbound imports:

python scripts/find_orphans.py <directory>

What it does:

  1. Indexes all source files (.js, .ts, .py).
  2. Parses imports to build a directed graph.
  3. Reports files that no other file imports.

Step 2: Review & Verify

The script output splits findings into:

  • Potential Orphans: Files with no imports.
  • Likely Entry Points: Files matching patterns like index.js, main.py, server.ts.

Example output:

Found 12 potential orphan files.

Likely Entry Points (whitelist these?):
- src/index.ts
- src/cli.ts

Potential True Orphans:
- src/legacy/OldHelper.ts
- src/utils/Deprecated.js

Step 3: Archive or Delete

Once verified:

  1. Move to a _archive/ folder if unsure.
  2. Or delete: rm src/legacy/OldHelper.ts

Configuration

Auto-Whitelisted Patterns:

  • index.js/ts/jsx/tsx
  • main.py/js/ts
  • server.js/ts
  • app.js/ts
  • cli.js/py
  • setup.py
  • manage.py (Django)
  • vite.config.*, webpack.config.*

Supported Import Styles:

  • JS/TS: import ... from, require(...), export ... from
  • Python: import module, from module import ...

Utility Scripts

ScriptPurpose
find_orphans.pyBuilds dependency graph and identifies disconnected nodes

Related Skills

  • stale-todo-finder — Clean up old comments while cleaning up old files.
  • codebase-onboarding — Understanding the graph helps with onboarding.

Source

git clone https://github.com/dcs-soni/awesome-claude-skills/blob/main/orphan-file-finder/SKILL.mdView on GitHub

Overview

Orphan File Finder identifies source files with zero inbound imports, surfacing unused code to reduce technical debt and shrink bundle size. It analyzes dependencies across JS, TS, and Python projects to help you spot dead code, forgotten endpoints, and scripts.

How This Skill Works

It indexes all source files (.js, .ts, .py), parses imports to build a directed dependency graph, and reports files that no other file imports. It also flags likely entry points (e.g., index.js, main.py, server.ts) to prevent accidental deletion of essential files.

When to Use It

  • When you notice dead code or unused files in the codebase
  • During a dependency audit to reduce bundle size
  • Before a refactor or code cleanup to minimize risk
  • When security concerns arise from forgotten endpoints or scripts
  • During maintenance to shrink technical debt

Quick Start

  1. Step 1: Scan codebase for orphans
  2. Step 2: Review and whitelist entry points
  3. Step 3: Archive or delete verified dead files

Best Practices

  • Scan the repository to build the dependency graph
  • Review Potential Orphans and whitelist Likely Entry Points first
  • Archive to _archive/ or delete only after verification
  • Run tests and build to ensure nothing breaks
  • Document whitelisting decisions for future audits

Example Use Cases

  • Found 12 potential orphan files in a React project and archived unused utilities
  • Identified and whitelisted index.ts and server.ts to avoid false positives
  • Removed deprecated scripts under src/legacy to shrink bundle size
  • Security audit revealed forgotten cleanup scripts which were archived
  • Dependency graph clarified dead modules in Python backend, reducing install time

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers