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, .log files (root), .tmp files.
- 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, app.py) as they are rarely imported but essential.
- 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
find: For empty directories (find . -type d -empty).
fd / find: For pattern matching junk files.
grep / ripgrep: For checking imports.
- Heuristic: To check if
OldButton.tsx is used, search for OldButton string in the whole src/ directory. If count is 1 (the definition itself), it's likely unused.
Safety Rules
- Never delete
node_modules/, .git/, .next/, build/ manually. (Use standard clean commands for those).
- Always respect
.gitignore.
- Backup Strategy: If the user is unsure, offer to move files to a
_deprecated/ folder instead of permanent deletion.
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 (
page.tsx) or API route. THESE ARE NEVER IMPORTED. Whitelist them.
- "Am I about to delete a configuration file?" -> Whitelist
*.config.js, Dockerfile, .env*.
1---2name: cleaning-project3description: 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.4---5
6# Project Cleaner & Janitor
7
8## When to use this skill
9- When the user explicitly asks to "clean up unused files" or "delete dead code".
10- Post-refactoring, to remove old implementations.
11- When the project feels "bloated" with temporary files.
12
13## Workflow
14
15### 1. The Scan (Dry Run)
16**Do not delete anything yet.**
171. **Junk Pattern Scan**: Look for common temporary/system files:
18 - `.DS_Store`, `Thumbs.db`, `.log` files (root), `.tmp` files.
19 - **Empty Directories**: Find folders with no content.
202. **Orphan File Scan (Static Analysis)**:
21 - Identify all source files (ts, js, dart, py).
22 - Checks if each file is imported by *at least one* other file in the project.
23 - *Exclusion*: Ignore "entry points" (e.g., `main.tsx`, `page.tsx`, `index.js`, `app.py`) as they are rarely imported but essential.
243. **Dead Code Scan**:
25 - Identify exported functions/constants that are never imported.
26 - *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.
27
28### 2. The Report
29Present the findings to the user in a clear list:
30```markdown
31### 🧹 Cleaning Report
32**Junk Files (Safe to delete):**
33- `.DS_Store`
34- `npm-debug.log`
35
36**Orphan Files (No imports found):**
37- `src/components/OldButton.tsx` (CAUTION: Is this an entry point?)
38- `utils/unused_helper.js`
39
40**Empty Folders:**
41- `src/features/old_feature/`
42```
43
44### 3. The Confirmation
45Ask: *"Do you want me to proceed with deleting the Junk Files? What about the Orphan Files?"*
46
47### 4. The Action
48Only after receiving "Yes" or specific instructions (e.g., "Delete junk, keep orphans"):
491. Run the deletion commands.
502. (Optional) If it was dead code removal within a file, edit the file to remove the unused block.
51
52## Instructions
53
54### Tools to Use
55- **`find`**: For empty directories (`find . -type d -empty`).
56- **`fd` / `find`**: For pattern matching junk files.
57- **`grep` / `ripgrep`**: For checking imports.
58 - *Heuristic*: To check if `OldButton.tsx` is used, search for `OldButton` string in the whole `src/` directory. If count is 1 (the definition itself), it's likely unused.
59
60### Safety Rules
611. **Never delete `node_modules/`, `.git/`, `.next/`, `build/`** manually. (Use standard clean commands for those).
622. **Always respect `.gitignore`**.
633. **Backup Strategy**: If the user is unsure, offer to move files to a `_deprecated/` folder instead of permanent deletion.
64
65## Self-Correction Checklist
661. "Did I assume this file is unused just because I didn't see an import?" -> Check if it's a Next.js Page (`page.tsx`) or API route. THESE ARE NEVER IMPORTED. **Whitelist them.**
672. "Am I about to delete a configuration file?" -> Whitelist `*.config.js`, `Dockerfile`, `.env*`.