Claude-skill-registry cleaning-project
Scans the codebase for unused files, dead code, and common junk patterns. Always performs a "Dry Run" first to list candidates for deletion and requires explicit user confirmation.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/cleaning-project" ~/.claude/skills/majiayu000-claude-skill-registry-cleaning-project && rm -rf "$T"
manifest:
skills/data/cleaning-project/SKILL.mdsource content
Project Cleaner & Janitor
When to use this skill
- When the user explicitly asks to "clean up unused files" or "delete dead code".
- Post-refactoring, to remove old implementations.
- When the project feels "bloated" with temporary files.
Workflow
1. The Scan (Dry Run)
Do not delete anything yet.
- Junk Pattern Scan: Look for common temporary/system files:
,.DS_Store
,Thumbs.db
files (root),.log
files..tmp- Empty Directories: Find folders with no content.
- Orphan File Scan (Static Analysis):
- Identify all source files (ts, js, dart, py).
- Checks if each file is imported by at least one other file in the project.
- Exclusion: Ignore "entry points" (e.g.,
,main.tsx
,page.tsx
,index.js
) as they are rarely imported but essential.app.py
- Dead Code Scan:
- Identify exported functions/constants that are never imported.
- Note: This is complex to do perfectly with regex. If using a language server (LSP) is possible, use it. Otherwise, rely on reliable grep/ripgrep searches.
2. The Report
Present the findings to the user in a clear list:
### 🧹 Cleaning Report **Junk Files (Safe to delete):** - `.DS_Store` - `npm-debug.log` **Orphan Files (No imports found):** - `src/components/OldButton.tsx` (CAUTION: Is this an entry point?) - `utils/unused_helper.js` **Empty Folders:** - `src/features/old_feature/`
3. The Confirmation
Ask: "Do you want me to proceed with deleting the Junk Files? What about the Orphan Files?"
4. The Action
Only after receiving "Yes" or specific instructions (e.g., "Delete junk, keep orphans"):
- Run the deletion commands.
- (Optional) If it was dead code removal within a file, edit the file to remove the unused block.
Instructions
Tools to Use
: For empty directories (find
).find . -type d -empty
/fd
: For pattern matching junk files.find
/grep
: For checking imports.ripgrep- Heuristic: To check if
is used, search forOldButton.tsx
string in the wholeOldButton
directory. If count is 1 (the definition itself), it's likely unused.src/
- Heuristic: To check if
Safety Rules
- Never delete
,node_modules/
,.git/
,.next/
manually. (Use standard clean commands for those).build/ - Always respect
..gitignore - Backup Strategy: If the user is unsure, offer to move files to a
folder instead of permanent deletion._deprecated/
Self-Correction Checklist
- "Did I assume this file is unused just because I didn't see an import?" -> Check if it's a Next.js Page (
) or API route. THESE ARE NEVER IMPORTED. Whitelist them.page.tsx - "Am I about to delete a configuration file?" -> Whitelist
,*.config.js
,Dockerfile
..env*