What problem does it solve?
Removing code patterns (like instrumentation or debugging code) from multiple files can be dangerous. Aggressive scripts might accidentally delete functional code, leaving files gutted and requiring manual restoration from backups. This Skill prevents such catastrophic damage.
Core Features & Use Cases
- Mandatory Backup: Always creates a timestamped backup before any removal operation, ensuring a safe rollback point.
- Per-File Validation: Crucially, validates each file individually after removal (syntax, size, integrity) to ensure it remains functional and not accidentally gutted.
- Precise Pattern Matching: Emphasizes using exact, tested patterns to avoid unintended deletions.
- Functional Testing: Recommends running build and tests after all removals to verify overall system integrity.
- Use Case: When you need to remove timing instrumentation from 47 hook scripts, use this Skill. It will create a backup, remove the patterns, and then validate each hook to ensure it's still functional, preventing the accidental destruction of critical system components.
Quick Start
First, identify precise patterns to remove and test them.
Then, execute the removal script:
/workspace/main/.claude/scripts/safe-remove-code.sh
--files "*.sh"
--patterns "HOOK_START=
log_timing()
trap.*timing.*exit"
--test-command "bash -n {}"