mocking-stubbing

mocking-stubbing is a skill for Claude Code, Codex from aj-geddes/useful-ai-prompts. It costs 47 tokens per session (696 once invoked), scanned A, original, MIT.

A testing technique that replaces real dependencies, such as databases, APIs, or file systems, with controlled test versions. Mocks can record calls, stubs can return chosen results, and spies can observe interactions.

In plain words
What is it for?
Use it to isolate units of code, simulate errors and edge cases, verify interactions, and test behaviour involving time, randomness, networks, or databases.
Why use it?
It keeps unit tests focused and fast without relying on slow, costly, unavailable, or unpredictable external systems.

Skill for Claude CodeCodex

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

Good fit Use it to isolate units of code, simulate errors and edge cases, verify interactions, and test behaviour involving time, randomness, networks, or databases.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/aj-geddes/useful-ai-prompts/mocking-stubbing
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 aj-geddes/useful-ai-prompts --skill mocking-stubbing
Clone the repo
git clone --depth 1 https://github.com/aj-geddes/useful-ai-prompts

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-stubbing

README.md
[![agentmods](https://agentmods.dev/badge/skills/aj-geddes/useful-ai-prompts/mocking-stubbing/github.svg)](https://agentmods.dev/skills/aj-geddes/useful-ai-prompts/mocking-stubbing)
Your own site
<a href="https://agentmods.dev/skills/aj-geddes/useful-ai-prompts/mocking-stubbing"><img src="https://agentmods.dev/badge/skills/aj-geddes/useful-ai-prompts/mocking-stubbing/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-stubbing

Your own site · 80×15
<a href="https://agentmods.dev/skills/aj-geddes/useful-ai-prompts/mocking-stubbing"><img src="https://agentmods.dev/badge/skills/aj-geddes/useful-ai-prompts/mocking-stubbing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 696 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
  • Socket pass 18 Mar 2026
  • Snyk pass 4 Mar 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.00047 $0.00696
Opus 5 $0.00023 $0.00348
Sonnet 5 $0.00009 $0.00139
Haiku 4.5 $0.00005 $0.00070

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

Security

Grade A, and why

mocking-stubbing 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.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/scaffold-tests.sh, templates/test-template.js), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/mocking-stubbing/SKILL.md · 100 lines

How it starts

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

Mocking and Stubbing

Table of Contents

Overview

Mocking and stubbing are essential techniques for isolating units of code during testing by replacing dependencies with controlled test doubles. This enables fast, reliable, and focused unit tests that don't depend on external systems like databases, APIs, or file systems.

When to Use

  • Isolating unit tests from external dependencies
  • Testing code that depends on slow operations (DB, network)
  • Simulating error conditions and edge cases
  • Verifying interactions between objects
  • Testing code with non-deterministic behavior (time, randomness)
  • Avoiding expensive operations in tests
  • Testing error handling without triggering real failures

Quick Start

Minimal working example:

// services/UserService.ts
import { UserRepository } from "./UserRepository";
import { EmailService } from "./EmailService";

export class UserService {
  constructor(
    private userRepository: UserRepository,
    private emailService: EmailService,
  ) {}

  async createUser(userData: CreateUserDto) {
    const user = await this.userRepository.create(userData);
    await this.emailService.sendWelcomeEmail(user.email, user.name);
    return user;
  }

  async getUserStats(userId: string) {
    const user = await this.userRepository.findById(userId);
    if (!user) throw new Error("User not found");

    const orderCount = await this.userRepository.getOrderCount(userId);
    return { ...user, orderCount };
  }
}

// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

Guide Contents
Jest Mocking (JavaScript/TypeScript) Jest Mocking (JavaScript/TypeScript)
Python Mocking with unittest.mock Python Mocking with unittest.mock
Mockito for Java Mockito for Java
Advanced Mocking Patterns Advanced Mocking Patterns

Read the full file on GitHub · 100 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 100 lines · 47 tokens per session scan A dcff21893ca5

Subscribe to this mod's changes

mocking-stubbing is a skill published in the GitHub repository aj-geddes/useful-ai-prompts (338 stars, last pushed 6mo ago), licensed MIT. It adds 47 tokens to every session and 696 once invoked, about $0.0002 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-09-03.