Agent skill

Generating Test Doubles

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Generate mocks, stubs, spies, and fakes for dependency isolation.

MITAuto-check passedTesting & QA

Install Generating Test Doubles

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-test-doubles -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace generating-test-doubles --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/generating-test-doubles .claude/skills/generating-test-doubles && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
generating-test-doubles
GitHub stars
2.8k
Token cost
~1.3k tokens
SKILL.md length
488 words
Files
6 (incl. scripts, references, assets)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Generate mocks, stubs, spies, and fakes for dependency isolation.

  • Works in 7 steps: Scan the codebase with Glob and Grep to… → Read each module under test and catalog… → Determine the appropriate test double… → …
  • Test isolation fixtures
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 3 more sections
  • Runs Python scripts from its folder; calls tsc

What it does

Generating Test Doubles is an agent skill from jeremylongshore/tons-of-skills-marketplace. Generate mocks, stubs, spies, and fakes for dependency isolation. Use when creating mocks, stubs, or test isolation fixtures. Trigger with phrases like "generate mocks", "create test doubles", or "setup stubs".

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including scripts, reference files and assets (for example `assets/README.md`, `references/README.md` and `scripts/README.md`). Compatibility notes: Designed for Claude Code

It sits in Testing & QA, covering Unit testing and Test generation. It works with Jest. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Test isolation fixtures
  • With phrases like generate mocks
  • Create test doubles

Example prompts

  • “generate mocks”
  • “create test doubles”
  • “setup stubs”
  • “/generating-test-doubles”

Requirements

  • Python 3
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Grep, Glob, Bash(test:doubles-*)

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Scan the codebase with Glob and Grep to identify modules with external dependencies (database clients, HTTP clients, file system access…
  2. Read each module under test and catalog its dependency interfaces -- list every method signature, return type, and side effect.
  3. Determine the appropriate test double type for each dependency
  4. Generate test double files following the project's existing test directory structure (e.g., mocks/, test/doubles/, testutil/).
  5. For each test double, implement
  6. Wire test doubles into existing test files using the framework's dependency injection pattern (jest.mock(), @patch, constructor injection…
  7. Validate all test doubles compile and pass type checks by running tsc --noEmit or equivalent.

What it can do on your machine

Read from SKILL.md and the folder at commit 80f86df. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Grep
    • Glob
    • Bash(test:doubles-*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 3 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • tsc

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • jestjs.io
    • sinonjs.org
    • docs.python.org
    • github.com
    • martinfowler.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Generating Test Doubles loads about 1.3k tokens when it runs, and up to ~1.3k if it reads all its reference files. Until then it costs about 59 tokens; SKILL.md has 488 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~59
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 80f86df, republished under its MIT licence (© jeremylongshore). 488 words, ~1,309 tokens.

Download SKILL.mdSave it as .claude/skills/generating-test-doubles/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
generating-test-doubles
description
Generate mocks, stubs, spies, and fakes for dependency isolation. Use when creating mocks, stubs, or test isolation fixtures. Trigger with phrases like "generate mocks", "create test doubles", or "setup stubs".
allowed-tools
Read, Write, Edit, Grep, Glob, Bash(test:doubles-*)
compatibility
Designed for Claude Code
version
1.22.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
testing, test-doubles

Test Doubles Generator

Overview

Generate mocks, stubs, spies, and fakes to isolate units under test from external dependencies. Supports Jest mocks, Sinon.js stubs, Python unittest.mock, Go interfaces, and testdouble.js patterns.

Prerequisites

  • Testing framework installed (Jest, Vitest, Mocha, pytest, JUnit 5, or Go testing)
  • Mocking library available (Sinon.js, testdouble.js, unittest.mock, Mockito, or gomock)
  • TypeScript strict mode enabled for type-safe mocks (if applicable)
  • Source code with clear interface or class boundaries for dependency injection

Instructions

  1. Scan the codebase with Glob and Grep to identify modules with external dependencies (database clients, HTTP clients, file system access, third-party SDKs).
  2. Read each module under test and catalog its dependency interfaces -- list every method signature, return type, and side effect.
  3. Determine the appropriate test double type for each dependency:
    • Stub: Returns canned data, no behavior verification (use for database queries returning fixed datasets).
    • Mock: Verifies interactions -- call count, argument matching, call order (use for email senders, event emitters).
    • Spy: Wraps real implementation while recording calls (use when partial behavior is needed).
    • Fake: Lightweight working implementation (use for in-memory repositories replacing real databases).
  4. Generate test double files following the project's existing test directory structure (e.g., __mocks__/, test/doubles/, testutil/).
  5. For each test double, implement:
    • Factory function or class matching the dependency interface exactly.
    • Configurable return values via builder pattern or method chaining.
    • Call recording for assertion (arguments, call count, call order).
    • Reset/restore mechanism for cleanup between tests.
  6. Wire test doubles into existing test files using the framework's dependency injection pattern (jest.mock(), @patch, constructor injection, or Go interface substitution).
  7. Validate all test doubles compile and pass type checks by running tsc --noEmit or equivalent.
Show full SKILL.md (216 more words)Show less

Output

  • Test double source files (one per dependency) placed in the project's mock directory
  • Factory functions with TypeScript generics or equivalent type safety
  • Jest __mocks__ auto-mock modules where applicable
  • Updated test files wired to use generated doubles instead of real dependencies
  • Summary listing each double, its type (mock/stub/spy/fake), and the interface it replaces

Error Handling

ErrorCauseSolution
TypeError: X is not a functionMock missing a method from the real interfaceRegenerate the double from the current interface definition; add the missing method
Mock leaking between testsShared mock state not reset in afterEachAdd jest.restoreAllMocks() or sinon.restore() in teardown hooks
Type mismatch on mock return valueReturn type does not match interface contractUse as ReturnType<typeof fn> or update the mock factory to return the correct type
Spy not recording callsSpy created after the function was already boundCreate spies before the module under test imports the dependency
Over-mocking hides real bugsToo many layers replaced with fakesLimit mocks to true external boundaries (I/O, network); let pure logic run unmocked

Examples

Jest mock factory for a UserRepository:

typescript
// __mocks__/userRepository.ts
export const createMockUserRepo = () => ({
  findById: jest.fn().mockResolvedValue({ id: '1', name: 'Test User' }),
  save: jest.fn().mockResolvedValue(undefined),
  delete: jest.fn().mockResolvedValue(true),
});

Python unittest.mock patch for an HTTP client:

python
from unittest.mock import patch, MagicMock

@patch('myapp.client.requests.get')
def test_fetch_data(mock_get):
    mock_get.return_value = MagicMock(status_code=200, json=lambda: {"key": "value"})  # HTTP 200 OK
    result = fetch_data("https://api.example.com/data")
    assert result == {"key": "value"}
    mock_get.assert_called_once()

Go interface-based fake:

go
type FakeStore struct {
    data map[string]string
}
func (f *FakeStore) Get(key string) (string, error) {
    v, ok := f.data[key]
    if !ok { return "", ErrNotFound }
    return v, nil
}

Resources

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (scripts, references, assets) in skills/.curated/generating-test-doubles of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • assets/README.md
  • references/README.md
  • scripts/README.md
  • scripts/dependency_analyzer.py
  • scripts/generate_doubles.py

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Generating Test Doubles next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Generating Test Doubles compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Generating Test Doubles this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.3kAutomated safety check: PassMIT
Write Testsgrafana/synthetic-monitoring-app171—~1.2kAutomated safety check: PassAGPL-3.0
Write Testsopenplayerjs/openplayerjs649—~1.8kAutomated safety check: PassMIT
MoAI TDD Workflowmodu-ai/moai-adk1.2k—~3.1kAutomated safety check: PassApache-2.0
Test Patternsrohitg00/skillkit1.5k—~1.8kAutomated safety check: PassApache-2.0
Add TestsMichealWayne/fe-tools207—~359Automated safety check: PassNone

Similar skills

  • Write Tests

    grafana/synthetic-monitoring-app

    Official

    Write Jest integration and unit tests for the Grafana Synthetic Monitoring app using React Testing Library, MSW, and src/test helpers.

    171 GitHub stars~1.2k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Write Tests

    openplayerjs/openplayerjs

    Write or extend Jest tests for OpenPlayerJS to this repo's exact conventions — makeCore factories, typed internals handles instead of as any, media property mocking, fake timers, ads/vast mocks, and…

    649 GitHub stars~1.8k tokensUpdated 4 days ago
    Testing & QAAuto-check passed
  • MoAI TDD Workflow

    modu-ai/moai-adk

    Drives test-first development through the RED, GREEN, REFACTOR cycle, with a config switch that selects between TDD and a DDD workflow for existing code.

    1.2k GitHub stars~3.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Test Patterns

    rohitg00/skillkit

    Applies proven testing patterns — Arrange-Act-Assert (AAA), Given-When-Then, Test Data Builders, Object Mother, parameterized tests, fixtures, spies, and test doubles — to help write maintainable…

    1.5k GitHub stars~1.8k tokensUpdated 4 mo ago
    Testing & QAAuto-check passed
  • Add Tests

    MichealWayne/fe-tools

    Add or update Jest unit tests for fe-tools utilities. An agent skill from MichealWayne/fe-tools.

    207 GitHub stars~359 tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Senior QA

    alirezarezvani/claude-skills

    Generates unit tests, integration tests, and E2E tests for React/Next.js applications.

    28k GitHub starsUsed in 1 repo~2.1k tokens
    Testing & QAAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated yesterday
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated yesterday
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated yesterday
    Auto-check passed

Works with

Categories

Questions about Generating Test Doubles

What does Generating Test Doubles do?

Generate mocks, stubs, spies, and fakes for dependency isolation. Generating Test Doubles is an agent skill from jeremylongshore/tons-of-skills-marketplace. Generate mocks, stubs, spies, and fakes for dependency isolation.

When should I use Generating Test Doubles?

Generating Test Doubles fits situations like: test isolation fixtures; with phrases like generate mocks; create test doubles.

How do I install Generating Test Doubles in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-test-doubles -a claude-code`. Or copy the skill folder (skills/.curated/generating-test-doubles in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/generating-test-doubles in your project. Claude Code loads it when a task matches its description.

How do I install Generating Test Doubles in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-test-doubles -a codex`. Or copy the skill folder (skills/.curated/generating-test-doubles in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/generating-test-doubles in your project. Codex loads it when a task matches its description.

Can I use Generating Test Doubles in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-test-doubles -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/generating-test-doubles, .gemini/skills/generating-test-doubles, .github/skills/generating-test-doubles and .opencode/skills/generating-test-doubles in your project.

What does Generating Test Doubles need to run?

Going by SKILL.md and its folder, Generating Test Doubles needs Python for the scripts in its folder and the command-line tools its instructions call (tsc). Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(test:doubles-*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Generating Test Doubles access the network?

SKILL.md names 5 domains. As links in the text: jestjs.io, sinonjs.org, docs.python.org, github.com and martinfowler.com. This is read from the text; nothing was executed.

Is Generating Test Doubles safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Generating Test Doubles use?

Generating Test Doubles is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Generating Test Doubles use?

About 1.3k tokens (SKILL.md is roughly 5.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 17 tokens, read only when the agent opens those files.

What are the alternatives to Generating Test Doubles?

Skills that share tags, products or a category with Generating Test Doubles: Write Tests (grafana/synthetic-monitoring-app, 171 stars), Write Tests (openplayerjs/openplayerjs, 649 stars), MoAI TDD Workflow (modu-ai/moai-adk, 1.2k stars) and Test Patterns (rohitg00/skillkit, 1.5k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Generating Test Doubles?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.