mock
Skill2 starsChanged 4 months agoMITView on GitHub
Generate test doubles — mocks, stubs, fakes, spies — for a unit's external dependencies, matching the project's testing and mocking approach, so a unit test can run in isolation. Use when the user says "mock this dependency", "create a stub for", "mock the API call", "fake the database", "add a test double", or "how do I mock X in tests".
7 other projects use a version of this.
Adopted by
Most recently taken up by
- gustaferiksson/skillstheir own version, first seen Nov 8, 2026
- ilamanov/skillstheir own version, first seen Oct 13, 2026
- Holojerm/drawthesystemtheir own version, first seen Oct 11, 2026
- iamneilroberts/shadetree-aitheir own version, first seen Oct 11, 2026
- junho5400/cramcodetheir own version, first seen Oct 9, 2026
- vide/matedroidtheir own version, first seen Oct 8, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- vide/matedroid★ 86same name
- iamneilroberts/claude-skills★ 26same name
- iamneilroberts/shadetree-ai★ 9same name
- ilamanov/skills★ 1same name
- junho5400/cramcode★ 1same name
- gustaferiksson/skills★ 0same name
- Holojerm/drawthesystem★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository68 other files it gives its agents.
- a11ySkill
- api-docsSkill
- audit-logSkill
- benchmarkSkill
- bisectSkill
- cacheSkill
- changelogSkill
- cherry-pickSkill
- ci-setupSkill
- codeownersSkill
- commit-messageSkill
- connection-poolSkill
- contributingSkill
- coverageSkill
- db-migrateSkill
- dead-codeSkill
- debugSkill
- depsSkill
- diagramSkill
- dockerizeSkill
- docstringSkill
- e2eSkill
- env-exampleSkill
- error-handlingSkill
- explainSkill
- feature-flagSkill
- flaky-testSkill
- gitignoreSkill
- graceful-shutdownSkill
- graphqlSkill
- healthcheckSkill
- i18nSkill
- idempotencySkill
- licenseSkill
- lint-fixSkill
- loggingSkill
- migrateSkill
- onboardSkill
- optimizeSkill
- paginationSkill
- pr-descriptionSkill
- pre-commitSkill
- profileSkill
- prune-branchesSkill
- rate-limitSkill
- readmeSkill
- rebaseSkill
- refactorSkill
- regexSkill
- releaseSkill
- resolve-conflictsSkill
- retrySkill
- review-diffSkill
- scaffoldSkill
- secrets-scanSkill
- security-headersSkill
- seedSkill
- soft-deleteSkill
- sqlSkill
- squashSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Create a test double for the dependency in $ARGUMENTS so the unit under test can be tested in isolation.
- Distinctive: line 26
Prefer the simplest that fits.
- Very specific: line 28
Reset between tests: Ensure mocks are cleared/restored in teardown so state doesn't leak across tests.
- Distinctive: line 34
Keep doubles faithful to the real interface and reset them between tests so suites stay isolated and order-independent.
- Distinctive: line 35
Prefer a fake or stub over a strict call-asserting mock unless the interaction itself is the behavior being verified — brittle …
- Distinctive: line 36
After writing, show where the double is wired, what it returns/asserts, and the command to run the affected tests.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test & mocking setup
!find . -type d \( -name node_modules -o -name .git -o -name dist -o -name build \) -prune -o -type f \( -name '*.test.*' -o -name '*.spec.*' -o -name 'test_*.py' -o -name 'conftest.py' -o -name '*_test.go' \) -print 2>/dev/null | head -15
!grep -rilE "jest\\.mock|vi\\.mock|sinon|unittest\\.mock|@patch|monkeypatch|nock|msw|gomock|mockito|testify/mock" --include='*.*' . 2>/dev/null | grep -vE 'node_modules|\.git|dist|build' | head -10
Instructions
Create a test double for the dependency in $ARGUMENTS so the unit under test can be tested in isolation. Match the project's existing test framework and mocking style — don't introduce a new mocking library.
Method
- Learn the mocking convention. From the signals above, identify the framework and how the project already mocks (
jest.mock/vi.mock, sinon,unittest.mock/@patch/pytestmonkeypatch, nock/MSW for HTTP, gomock/testify, Mockito). Read a neighboring test to match the setup/teardown and assertion style. If nothing exists, propose the idiomatic approach and confirm. - Pick the right kind of double for the need:
- Stub — returns canned values so the unit can proceed (a repo that returns a fixed record).
- Mock/spy — asserts the dependency was called correctly (args, count) when the interaction is the behavior under test.
- Fake — a lightweight working implementation (in-memory repo, MSW handler) when many tests need realistic behavior. Prefer the simplest that fits; don't assert on calls that aren't the point of the test.
- Mock at the seam, against the real interface. Replace the dependency at its boundary (the injected collaborator, the module import, the HTTP endpoint), and make the double honor the real signature/return type so the test fails if the contract drifts. Cover the cases the test needs: success, empty, and error/throw.
- Reset between tests. Ensure mocks are cleared/restored in teardown so state doesn't leak across tests. Use the framework's reset (
afterEach(jest.clearAllMocks),restore(), autouse fixtures).
Rules
- Match the project's framework and mocking library exactly; don't add a new one unprompted.
- Mock only external/slow/nondeterministic collaborators (network, db, clock, randomness, filesystem) — don't mock the unit under test or pure logic, and don't over-mock to the point the test asserts nothing real.
- Keep doubles faithful to the real interface and reset them between tests so suites stay isolated and order-independent.
- Prefer a fake or stub over a strict call-asserting mock unless the interaction itself is the behavior being verified — brittle "was-called-with" assertions on incidental calls make refactors painful.
- After writing, show where the double is wired, what it returns/asserts, and the command to run the affected tests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

