Use when refactoring TypeScript code whose tests require monkey-patching modules, swapping globals, or stubbing imports (vi.mock, jest.mock, sinon) because collaborators (database, HTTP client, clock, RNG, env, logger) are hardcoded inside the unit. Trigger on requests like "I can't test this without mocking the…
Use when refactoring TypeScript code that is hard to read because intent is buried - deeply nested conditionals, complex boolean expressions, magic numbers, long functions whose sections are labeled by comments, or mixed levels of abstraction in one body. Trigger on requests like "this function is unreadable"…
Use when refactoring TypeScript code that mixes business decisions with I/O, state, time, or randomness into a pure functional core plus a thin imperative shell. Trigger on requests like "this is hard to test without mocks", "extract the pure logic", "separate business rules from the database", or "split decisions…