Refactor engine
Skill Razaib-khan/ForgeWeave/src/forgeweave/templates/claude/.claude/skills/refactor-engine
Behavioral execution framework for AI agents — define deterministic, portable skills & agents across OpenCode, Claude Code, Gemini CLI, and Qwen Code.
npx -y skills add Razaib-khan/ForgeWeave --skill refactor-engineAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Improves existing codebases by restructuring for clarity, performance, and maintainability without changing external behavior
SKILL.md
2.6 KB, as published. Nobody here has run it
Refactor Engine
Purpose
Restructure existing code to improve readability, performance, and maintainability while preserving exact external behavior. Every refactor is verified by ensuring existing tests continue to pass and no observable behavior changes.
When to Use
- Code has duplicated logic that should be extracted
- A function or module is too long or does too many things
- Naming is unclear or inconsistent with project conventions
- Performance can be improved by algorithmic changes
- Dead code, commented-out code, or unused imports need removal
When Not to Use
- The code has a bug — use
debuggerfirst - New features need to be added — use
code-builder - The code works fine and doesn't need changes
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
target | string | Yes | File, module, or code area to refactor |
goal | enum | Yes | clarity, performance, maintainability, or all |
constraints | string | No | What must NOT change (public API, performance bounds) |
Expected Outputs
| Output | Description |
|---|---|
| Refactored code | Restructured code preserving external behavior |
| Diff summary | What changed and why |
| Verification | Test results confirming no behavior change |
Exact Workflow Steps
- Read and understand the target code fully
- Run existing tests to establish baseline
- Identify refactoring opportunities (duplication, complexity, naming)
- Apply one refactoring at a time (small, atomic changes)
- Run tests after each change to confirm no regression
- Repeat until all planned refactorings are applied
Required Checks
- All existing tests pass before and after
- No public API changed unless explicitly requested
- Each change is atomic (one concern per change)
- No dead code or debug artifacts left behind
Failure Modes
| Failure Condition | Response |
|---|---|
| Test fails after refactor | Revert last change and re-approach differently |
| Refactor touches too many files | Break into smaller, focused refactors |
| Goal is unclear | Ask for specific examples of what to improve |
References
| Reference | Path |
|---|---|
| Test Generator skill | ../test-generator/SKILL.md |
| Code Builder skill | ../code-builder/SKILL.md |