mocking-strategies

mocking-strategies is a skill for Claude Code, Codex from vladkesler/initrunner. It costs 27 tokens per session (671 once invoked), scanned A, original, Apache-2.0.

A guide to mock, patch, fake, and stub techniques for replacing outside dependencies in Python and JavaScript tests.

In plain words
What is it for?
Use it to replace dependencies temporarily, simulate return values or errors, and write focused tests with tools such as pytest, unittest.mock, Jest, or Vitest.
Why use it?
It lets tests isolate the code being checked from databases, APIs, files, time, or randomness, making failures easier to understand.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to replace dependencies temporarily, simulate return values or errors, and write focused tests with tools such as pytest, unittest.mock, Jest, or Vitest.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vladkesler/initrunner/mocking-strategies
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add vladkesler/initrunner --skill mocking-strategies
Clone the repo
git clone --depth 1 https://github.com/vladkesler/initrunner

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mocking-strategies

README.md
[![agentmods](https://agentmods.dev/badge/skills/vladkesler/initrunner/mocking-strategies/github.svg)](https://agentmods.dev/skills/vladkesler/initrunner/mocking-strategies)
Your own site
<a href="https://agentmods.dev/skills/vladkesler/initrunner/mocking-strategies"><img src="https://agentmods.dev/badge/skills/vladkesler/initrunner/mocking-strategies/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mocking-strategies

Your own site · 80×15
<a href="https://agentmods.dev/skills/vladkesler/initrunner/mocking-strategies"><img src="https://agentmods.dev/badge/skills/vladkesler/initrunner/mocking-strategies.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 671 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.00671
Opus 5 $0.00014 $0.00336
Sonnet 5 $0.00005 $0.00134
Haiku 4.5 $0.00003 $0.00067

Measured 9d ago against content hash 400e1c1fdf6c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

mocking-strategies scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/roles/unit-tester/skills/mocking-strategies/SKILL.md · 79 lines

How it starts

The opening of the file, as written. The whole thing — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Mocking strategies for isolating external dependencies in tests.

When to activate

Use this skill when tests need to isolate external dependencies such as databases, APIs, filesystems, time, or randomness.

Python mocking

  • unittest.mock.patch("module.path.ClassName") -- replace an object for the duration of a test. Use as a decorator or context manager.
  • patch.object(obj, "attr") -- patch a specific attribute on a live object.
  • MagicMock(spec=RealClass) -- create a mock that mirrors the real class API; accessing non-existent attributes raises AttributeError.
  • side_effect -- set to a function for dynamic return values, or to an exception class to simulate errors.
  • return_value -- set the fixed return value of the mock.
  • monkeypatch (pytest built-in) -- set attributes, environment variables, or dict items for the duration of a test without import-path gymnastics.

JavaScript mocking

  • jest.mock("module") / vi.mock("module") -- auto-mock an entire module. Provide a factory function for custom behavior.
  • Manual mocks in __mocks__/ -- place a file next to node_modules or the real module to override it project-wide.
  • Dependency injection -- pass dependencies as constructor or function arguments to make them trivially replaceable in tests.
  • msw (Mock Service Worker) -- intercept HTTP at the network level for realistic API mocking without changing application code.

When to mock

  • External HTTP services and APIs.
  • Time and dates (datetime.now, Date.now).
  • Filesystem reads and writes.
  • Network sockets and connections.
  • Databases and data stores.
  • Random number generators and entropy sources.

When NOT to mock

  • Pure functions with no side effects -- just call them directly.
  • Data transformations and mapping logic.
  • Simple utility functions.
  • The system under test itself -- that makes the test tautological.

Mock verification

  • Python: mock.assert_called_once_with(arg1, arg2), mock.call_count, mock.call_args_list.
  • JavaScript: expect(fn).toHaveBeenCalledTimes(1), expect(fn).toHaveBeenCalledWith(arg1, arg2).

Read the full file on GitHub · 79 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 79 lines · 27 tokens per session scan A 400e1c1fdf6c

Subscribe to this mod's changes

mocking-strategies is a skill published in the GitHub repository vladkesler/initrunner (41 stars, last pushed today), licensed Apache-2.0. It adds 27 tokens to every session and 671 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.