refactor-code-principles
Principle-Driven Structural Engine — refactor-chain · general lane / final pass
Bundle: refactor-chain (self-diagnosing, self-healing fix-it pipeline).
Phase: do-the-work (general lane), and the default final consolidating step of every lane · Prerequisite: a green baseline (refactor-safety-net) when run inside a chain; standalone otherwise · Next: the review gate.
Adaptivity / conditional: repo-agnostic — the principle set adapts to the detected stack via the registry.
Purpose
Take code that already exists and already works, and restructure it so the next person finds it obvious — guided not by one fixed doctrine but by an explicit, user-approved set of engineering principles. The engine detects what the codebase is (via the diagnose harness), asks the principles registry what normally fits that stack, and then — this is the heart of the skill — opens a decision window where the human picks the principle set before a single line moves. The chosen principles become the diagnostic lens and the transform plan. Behavior is the one thing that never changes.
When to use
- Working code with tangled structure: one unit doing several jobs, logic welded to I/O, duplication, deep coupling, conditionals that grow with every new variant.
- Trigger phrases: "refactor this", "clean this up", "apply SOLID", "split this class", "decouple X from Y", "this file does too much", "introduce DI", "restructure into layers".
- Automatically, appended by the orchestrator as the final consolidating pass after any other lane (backend, web, ui) finishes.
- NOT for: new features, bug fixes, or building test suites. If the code doesn't work yet, this is the wrong skill.