🦀 ClawHub
RedHat Code Refactor Engine
by @mzfshark
Refactor code safely without changing behavior.
TERMINAL
clawhub install axodus-refactor-engine📖 About This Skill
name: refactor-engine description: Refactor code safely without changing behavior. metadata: author: RedHat Dev version: 1.0.0 owner: RedHat Dev Agent category: core
SKILL: refactor-engine
Purpose
Improve existing code structure (readability, modularity, maintainability) while preserving behavior.When to Use
Inputs
target_area (required, string): file(s)/module(s) to refactor.refactor_goal (required, string): what improves (e.g., reduce duplication, isolate side effects).constraints (optional, string[]): behavior must not change; performance bounds; compatibility.validation_commands (optional, string[]): tests/build/lint to run before/after.Steps
1. Establish a baseline: - run existing tests (or add a minimal characterization test) 2. Identify refactor seam(s): - extract pure functions - isolate I/O - reduce global state 3. Apply refactor in small commits/patches: - one transformation per step - keep diffs readable 4. Re-run validations after each meaningful transformation. 5. If behavior changes, revert that change and adjust approach.Validation
Output
refactor_summaryfiles_changedbehavior_guards (tests added/used)validation_resultsSafety Rules
Example
Goal: “Extract request validation from controller intovalidators/ and add unit tests.â€
Validation: pnpm test after each extraction step.
⚡ When to Use
💡 Examples
Goal: “Extract request validation from controller into validators/ and add unit tests.â€
Validation: pnpm test after each extraction step.