Investigate and remove unused code, files, and dependencies to keep the codebase clean and maintainable. Use this when you want to "remove unused code", "clean up dependencies", "find dead code", or "optimize project size".
Install
npx skillscat add hrdtbs/agent-skills/cleanup Install via the SkillsCat registry.
Cleanup
A skill for identifying and removing unused code, dead files, and unnecessary dependencies. This helps reduce technical debt, improve build times, and make the codebase easier to navigate.
Workflow
Phase 1: Investigation
Identify potential candidates for removal using automated tools or manual inspection.
Unused Dependencies
Check for packages listed in project metadata (e.g., package.json, requirements.txt, go.mod) that are not actually imported or used in the source code.
- Node.js: Use
depcheckorknip. - Python: Use
pip-check-reqsordeptry. - Go: Use
go mod tidy.
Unused Code & Files
Check for functions, classes, variables, or entire files that are defined but never referenced.
- Node.js/TypeScript: Use
kniports-prune. - Python: Use
vulture. - Go: Use
unused(fromstaticcheck). - General: Use
greporripgrepto search for references across the project.
Phase 2: Verification
Before deleting anything, perform a thorough check to avoid breaking the application.
- Check Dynamic Usage: Look for strings used in reflection, dynamic imports, or runtime lookups that might not be caught by static analysis tools.
- Check Configuration: Ensure the item is not used by build tools, CI/CD pipelines, or configuration files (e.g., ESLint plugins, Tailwind CSS content paths).
- Public API Check: If the repository is a library, verify if the "unused" code is part of the public API intended for external users.
Phase 3: Removal & Testing
- Minimal Removal: Remove one component at a time if possible.
- Run Tests: Execute the test suite to ensure no functional regressions.
- Run Build: Perform a full build to verify that dependencies are still intact and no compilation errors were introduced.
Usage Examples
Finding unused Node.js dependencies
npx depcheckFinding dead Python code
pip install vulture
vulture .Cleaning up Go modules
go mod tidySearching for references manually
grep -r "my_function_name" .Presentation to User
When presenting findings to the user, use the following format:
Candidates for Removal
- Type: [Dependency | Code | File]
- Item: [Name or Path]
- Evidence: [Tool output or reason why it's believed to be unused]
- Proposed Action: [Remove | Investigate further]
Troubleshooting
- False Positives: Automated tools often miss dynamic references. Always verify with
grepbefore removal. - Hidden Dependencies: Some dependencies are used implicitly by frameworks or tools. Check configuration files if a tool breaks after removing a "unused" dependency.
- Peer Dependencies: Be careful when removing packages that might be required by other packages but not directly imported.