mockable-code
mockable-code
Write, edit, refactor, and review code so dependencies can be replaced by mocks, stubs, fakes, or in-memory implementations without distorting production design.
Passive Trigger
Load this skill in the background whenever the task involves source code and any behavior depends on collaborators, I/O, time, randomness, persistence, configuration, network calls, queues, SDKs, process state, or framework context. Keep it lightweight for tiny edits: apply the core rules silently, then mention only the mockability decisions that affect the final implementation.
Decision Tree
What are you doing?
-
Adding code that calls a dependency: Accept the dependency from the caller when practical. Keep domain policy separate from construction, configuration, and transport.
-
Refactoring hard-to-test code: Read
references/boundaries.md. Move side effects behind the smallest useful boundary before changing behavior.