safe-remove-code

Remove code patterns from files with backups and per-file validation.

4|Updated Sep 25, 2025
One-click install
npx skills add https://github.com/cowwoc/styler --skill safe-remove-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safe-remove-code
Source: https://github.com/cowwoc/styler/tree/main/.claude/skills/safe-remove-code
Command: npx skills add https://github.com/cowwoc/styler --skill safe-remove-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

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 {}"

Frequently Asked Questions about safe-remove-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely remove code patterns from multiple files without breaking functionality?

Safe code removal uses mandatory backups, per-file validation, and syntax checks to prevent accidental damage. Create a timestamped backup first, apply precise patterns to target files, then validate each file individually and run functional tests to confirm the system still works.

What validation happens after removing code from files?

Per-file validation checks syntax integrity, file size changes, and functional correctness after removal. This prevents gutting files by detecting when too much code was deleted or syntax became invalid, triggering rollback if any file fails validation.

Can I remove instrumentation and debugging statements from shell scripts safely?

Yes. The Skill removes instrumentation, debugging statements, and deprecated patterns from shell and script files using precise pattern matching, per-file validation, and syntax checks via bash -n or equivalent, ensuring hooks and critical scripts remain functional.

How do I identify and test patterns before removing them from my codebase?

Test patterns locally against a small file set first to verify they match only intended code. Use exact, tested patterns rather than aggressive regex to avoid unintended deletions, then run the removal script with a test-command flag to validate syntax before committing changes.

What happens if code removal damages a file during the operation?

Timestamped backups enable safe rollback if validation fails or removal goes wrong. Per-file validation detects damage immediately, allowing you to restore from backup and adjust patterns without data loss or manual restoration.

Do I need to run tests after removing code from multiple files?

Yes. Functional testing after all removals verifies overall system integrity across your entire codebase. This catches edge cases where individual file validation passed but removal broke interdependent components or workflows.