Package Exports
- vibe-janitor
- vibe-janitor/dist/cli/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vibe-janitor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vibe-janitor ๐งน
Keep your vibe-coded JavaScript/TypeScript projects clean and smart
๐ Overview
When you build with tools like ChatGPT, GitHub Copilot, Claude, Cursor IDE, or Windsurf AI: LLMs can't see your whole project at once. Because of their limited context window, they might read and modify irrelevant or unused codeโespecially leftovers from past experiments.
This not only creates bugs but also wastes your time and money. vibe-janitor helps you stay in control. It automatically finds and removes unused imports, variables, functions, files, and dependenciesโso your codebase stays clean, minimal, and AI-friendly.
If you're into prompt-based development, conversational coding, or just vibing with AIโthis tool has your back.
โจ Features
- ๐งน Smart Code Cleanup: Automatically detect and remove unused imports, variables, and functions left behind by AI tools like ChatGPT or Copilot. Keep only the code that actually matters.
- ๐ผ๏ธ Asset Scanner: Finds forgotten static files (images, fonts, CSS, etc.) that are no longer used. Great after a few wild rounds of prompt-based design changes.
- ๐ Complexity Analyzer: Flags overly complex functions and deeply nested codeโoften the result of AI overthinking your prompts.
- ๐ฆ Dependency Checker: Detects unused npm packages and even circular dependencies introduced during AI-assisted coding sessions.
- ๐ Dry Run Mode: See what vibe-janitor would clean up without actually changing anything. Ideal for cautious coders and curious minds.
- ๐ Insightful Reports: Generates human-readable and JSON reports of all cleanup actions. Perfect for reviewing the output of your AI-generated projects.
๐ Installation
Global Installation
npm install -g vibe-janitor
Local Project Installation
npm install --save-dev vibe-janitor
Quick Try with npx
npx vibe-janitor
๐ป Usage
Interactive Mode
By default, vibe-janitor runs in interactive mode when no options are provided:
npx vibe-janitor
This will prompt you with questions to configure the cleanup process:
- Clean up unused imports and code automatically? (Y/n)
- Show detailed information about issues found? (Y/n)
- Generate detailed reports? (y/N)
- Run advanced cleanup for assets, variables, and functions? (y/N)
- Analyze package dependencies? (y/N)
- Check for circular dependencies? (y/N)
To skip interactive mode, use the --no-interactive
flag or provide specific options.
Basic Usage
# Analyze current directory without making changes
vibe-janitor --dry-run
# Get detailed list of unused imports and other issues
vibe-janitor --list
# Remove unused imports and code
vibe-janitor --remove-unused
# Clean a specific directory
vibe-janitor ./path/to/project --remove-unused
Command Options
--deep-scrub Run all available cleanup routines
--dry-run Show what would be removed without deleting anything
--remove-unused Remove unused files, components, and imports
--list List detailed information about unused imports and other issues
--report [path] Generate detailed reports (JSON and Markdown)
--analyze-complexity Analyze code complexity
--analyze-dependencies Analyze package dependencies
--check-circular Check for circular dependencies
--generate-graph Generate dependency graph visualization
--log Output detailed cleanup logs
--quiet No console output, just do the job
--no-progress Disable progress bars
Using in package.json scripts
{
"scripts": {
"clean": "vibe-janitor --list",
"clean:fix": "vibe-janitor --remove-unused",
"clean:deep": "vibe-janitor --deep-scrub --remove-unused"
}
}
Detailed Mode Output
With the new --list
option, you get detailed information about what needs to be cleaned:
๐ Cleanup Summary:
- Unused imports: 33 across 22 files
๐ Unused imports details:
- components/Header.tsx (2 unused):
โข useState
โข useEffect
- pages/index.tsx (3 unused):
โข Image
โข Head
โข styles
...
๐ก To fix these issues, run: npx vibe-janitor --remove-unused
๐๏ธ Generated Reports
Using the --report
option generates detailed markdown and JSON reports:
vibe-janitor --report
This creates reports in the vibe-janitor-report/
directory:
vibe-janitor-report-main.md
: Human-readable reportvibe-janitor-report-main.json
: Machine-readable reportvibe-janitor-report-dependencies.md
: Dependency analysisvibe-janitor-report-circular.md
: Circular dependency analysis
๐ ๏ธ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the LICENSE file for details.
This license ensures that while the software remains open source, any derivative works must also be distributed under the same license terms, giving you as the original author more control over how your work is used and modified.
๐ Acknowledgments
Big thanks to the open-source tools that make vibe-janitor possible:
- ๐ง TypeScript โ for the powerful Compiler API that lets us deeply understand your code
- ๐งฌ ts-morph โ for making AST manipulation feel almost natural
- ๐งฐ depcheck โ for digging through dependencies like a true janitor