What problem does it solve? Tests that rely on unittest.mock.patch and MagicMock are brittle, tightly coupled to implementation details, and hard to maintain. This Skill guides a structured refactoring that replaces mocks with injectable gateway abstractions and configurable fakes, making tests more robust and intention-revealing. ## Core Features & Use Cases - Mock Auditing: Systematically catalogs every patch() call in a test file, grouping mocks by the system boundary (tool or service) they simulate. - Gateway Discovery: Searches existing gateway ABCs and fakes at the right abstraction level, avoiding low-level wrappers around subprocess.run. - Source Injection & Test Rewriting: Adds constructor or Click-context injection of gateways to source code, then rewrites tests to use fakes with pre-canned responses and call-tracking assertions. - Use Case: A test patches shutil.which and subprocess.run to simulate the Claude CLI. The Skill identifies PromptExecutor as the correct gateway, injects it into the class under test, and rewrites the test using FakePromptExecutor with configured PromptResult values. ## Quick Start Ask the agent to refactor the tests in a given test file that use unittest.mock.patch into the gateway-based fake pattern.