Refactor Prompt — the Behavior Preservation Contract
"Refactor this code" invites silent behavior changes. The refactoring contract preserves business rules, outputs, and side effects — and flags uncertainty instead of deciding it.
View Resource →Build behavior-preserving refactor prompts — goal, risk level, and code context turn into a safe refactoring contract.
"Refactor this code" invites silent behavior changes. The refactoring contract preserves business rules, outputs, and side effects — and flags uncertainty instead of deciding it.
View Resource →For code that ships weekly: a refactoring prompt where regression avoidance outranks improvement depth, log lines stay intact, and every step is rollback-friendly.
View Resource →Generated code duplicates instead of extracting, wraps without deciding, and defends against impossible states. This prompt hunts those exact failure modes — without preserving bugs as behavior.
View Resource →Dependency cycles, leaky modules, misplaced responsibilities — cleaned up within the existing design. Explicitly not an invitation to invent a new architecture.
View Resource →Legacy code has callers you cannot see and assumptions nobody wrote down. This refactoring prompt treats every public surface as load-bearing and changes in small, verified steps.
View Resource →Pattern matching, records, nullable annotations, async done right — a C# modernization scope with the rule that matters: modern equivalents are rarely exact equivalents.
View Resource →var to const, callback pyramids to async/await, || guards to ?? — with the trap called out by name: || treats 0 and empty string as missing, ?? does not.
View Resource →Code a new hire cannot follow is a cost on every future change. This prompt renames for intent, extracts nameable steps, and replaces cleverness with clarity — semantics untouched.
View Resource →Deep nesting and tangled branching make code unreasonable. This prompt flattens control flow with guard clauses and collapses duplicate decisions — with every branch still routing the same way.
View Resource →Three near-identical functions, one future bug fixed in only two of them. This prompt consolidates duplication into shared logic — and knows when near-duplicates should stay separate.
View Resource →