clean-code
Installation
SKILL.md
Code Cleanup
Clean up code files by removing dead code, simplifying structure, and eliminating redundancy while preserving exact behavior. Language-agnostic. Applies project conventions when available.
When invoked with arguments, clean the files specified by $ARGUMENTS. When invoked without arguments, clean files changed in the current git working tree.
Workflow
- Resolve targets: Determine the set of files to clean
- File paths or glob patterns: expand and validate each path exists
git:staged: clean files in the git staging areagit:branch: clean files changed on the current branch vs the base branch- No arguments: run
git diff --name-onlyandgit diff --cached --name-onlyto collect modified files - Skip binary files, generated files (lock files, build output,
.min.*), and vendored dependencies
- Load context: Read project conventions from
CLAUDE.md,.editorconfig, linter configs, and formatter configs in the project root. These override any default assumptions - Read and analyze: For each target file, read the full contents and identify cleanup opportunities from the catalog below
- Apply cleanup: Edit each file, applying all applicable cleanup passes. Preserve all existing behavior
- Validate: Run the project's existing linter and test commands if configured. If validation fails, revert the change that caused the failure and continue with remaining files
- Report: Summarize changes per file using the output format below