Refactor engine
Skill Razaib-khan/ForgeWeave/src/forgeweave/templates/gemini/.gemini/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 |
Gives 4 of the 12 instructions most refactoring skills give
Counted across 521 of the 525 authors here whose files we hold, read 2026-08-06
- run tests after each changehere, and in 59 of 521, across 56 files
- write tests before refactoringin 27 of 521, across 24 files
- preserve external behaviorhere, and in 26 of 521, across 22 files
- remove dead codehere, and in 25 of 521, across 24 files
- make small incremental changesin 20 of 521, across 17 files
- break the implementation into tiny commitsin 18 of 521, across 5 files
- ask the user about alternative optionsin 17 of 521, across 4 files
- create a GitHub issue with the planin 17 of 521, across 4 files
- explore the repository to verify assertionsin 17 of 521, across 4 files
- interview the user about the refactorin 16 of 521, across 3 files
- check the codebase for test coveragein 16 of 521, across 3 files
- refactor one thing at a timehere, and in 16 of 521, across 12 files
Said here and by no other author read
- repeat until all planned refactorings are applied
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.