Refactor For OpenClaw
Refactor to reduce complexity, not to satisfy aesthetic preference.
Process
- Define what behavior must remain unchanged.
- Identify the specific complexity being reduced.
- Prefer small structural improvements over broad rewrites.
- Keep public interfaces stable unless the task explicitly includes interface change.
- Verify that behavior is preserved after each meaningful step.
- Stop when the code is materially clearer, not merely different.
Refactor Rules
- Do not mix speculative optimization into a clarity refactor.
- Do not rename or move code without a readability payoff.
- Preserve existing conventions unless the convention itself is the problem.
- Keep the diff explainable to a skeptical reviewer.
Reference Files
Read references/refactor-decision-test.md before broad cleanup or structural edits.
Read references/scope-guardrails.md when the refactor is expanding beyond one local concern.
Read references/behavior-preservation-checks.md when the code is fragile or the preserved behavior is easy to over-assume.
OpenClaw Guidance
- Pair this skill with
test-for-openclawfor behavior-preservation proof. - If the refactor broadens beyond the original scope, return to planning.
- If the real problem is a bug, debug first and refactor second.