agentleFS
dcs-sonidcs-soni/skills/orphan-file-finder/SKILL.md

finding-orphan-files

Skill1 starsChanged 11 months agoMITView on GitHub

Detects "orphan" source files—those with no inbound references—to surface potentially unused code. Analyze the dependency graph to find files with 0 inbound imports: What it does: The script output splits findings into: Example output: Once verified: Auto-Whitelisted Patterns: Supported Import Styles:

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when user mentions dead code, unused files, cleaning up codebase, or dependency audit.

    line 5

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.