diff --git a/agents/refactorer.md b/agents/refactorer.md index 067256e..dceb723 100644 --- a/agents/refactorer.md +++ b/agents/refactorer.md @@ -19,9 +19,18 @@ Improve code without ever changing its external behavior. 1. Analyze the target — list ALL violations 2. Produce the report BEFORE touching anything -3. Check that tests exist (if not — report before modifying) +3. Check that tests exist covering the target. + 🛑 **STOP — no tests**: emit the PRE-REPORT with `TESTS PRESENT: no` and + end WITHOUT editing. Zero-behavioral-regression is unverifiable without + tests; the dispatcher arbitrates. Proceed on a no-test target ONLY when + the dispatch prompt carries the explicit token `GO-WITHOUT-TESTS`. + (Inline-load inside code-cleaner: the orchestrator's APPROVED scope is + that token — note `TESTS PRESENT: no` in the output, don't stop.) 4. Refactor function by function -5. Verify tests pass after each modification +5. Run the tests after each modification. + Test fails → revert THAT modification, record it under + `VIOLATIONS NOT FIXED` (reason: "test regression on refactor"), continue + with the next violation. Never leave the suite red between steps. --- @@ -60,6 +69,7 @@ TESTS PRESENT: yes / no - Zero behavioral regression - Existing tests must pass +- No tests on the target → PRE-REPORT + STOP (unless dispatched with `GO-WITHOUT-TESTS`) - Do not modify business logic under the guise of refactoring - Do not refactor unrelated parts diff --git a/skills/refactor/SKILL.md b/skills/refactor/SKILL.md index 005202a..e0ae675 100644 --- a/skills/refactor/SKILL.md +++ b/skills/refactor/SKILL.md @@ -18,3 +18,9 @@ $ARGUMENTS" If the refactorer agent is unavailable, emit `Refactorer agent missing.` and STOP — never improvise, silent behavior change is unsafe. + +🔴 **No-tests gate**: when the agent returns `TESTS PRESENT: no` and stopped +(its contract on a test-less target), do NOT re-dispatch on your own. Surface +its PRE-REPORT and ask the user: add tests first / proceed anyway / abort. +Only an explicit "proceed" re-dispatches with the `GO-WITHOUT-TESTS` token — +behavior preservation is unverifiable on that path and the user owns that risk.