A single variable (often named `temp`, `result`, `value`) reassigned multiple times to hold conceptually distinct values — perimeter, then area; current iteration result, then accumulator.
The agent finds a variable reassigned with values of conceptually different types or domains; reasoning about any expression involving it requires knowing which role is currently active.
Each variable has one role; reassignment patterns reflect distinct purposes rather than reused storage.
Each variable holds one role with a stable name; the agent reasons about names without tracking reassignment timeline.
Before the refactoring
let temp = 2 * (height + width);console.log(temp);temp = height * width;console.log(temp);
After the refactoring
const perimeter = 2 * (height + width);console.log(perimeter);const area = height * width;console.log(area);
The reader must track which role the variable currently holds; bugs hide where one role's update accidentally clobbers another; refactoring either use is impossible without disentangling.
The agent must trace through reassignments to know what any reference currently means; type-narrowing in unions becomes guesswork at every read site.
If the two uses were actually coupled — shared init or synchronized update — splitting them invites drift the single mutation kept in sync.
If the two uses were actually coupled (shared init, synchronized update), splitting forces the agent to re-derive the coupling across two variables.
Names match purpose; the type system can narrow each role; refactoring each use becomes local.
The agent reasons about each variable as a stable name; the type system can narrow each role; each use becomes independently refactorable.
Splitting variables whose uses were genuinely coupled — accumulator that depends on a previous-iteration version of itself — fragments coherent state into separate variables that have to re-establish the coupling.
Splitting variables whose uses genuinely shared state forces the agent to re-establish the coupling outside the variable, complicating the original logic.