toolhive-studio: Skill for Claude Code

.claude/skills/testing-with-api-mocks/SKILL.md

testing-with-api-mocks is a skill for Claude Code from stacklok/toolhive-studio. It costs 44 tokens per session (1,438 once invoked), scanned A, original, Apache-2.0.

A guide for using API mocks in tests. API mocks are pretend backend responses that let tests run without contacting a real service.

In plain words
What is it for?
Use it when a test calls an API, especially when creating, changing, or refactoring tests for React components that load or submit data.
Why use it?
It removes the need to manually prepare basic fake API responses and explains how responses are generated and saved for later tests.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is stacklok/toolhive-studio's own configuration. It tells Claude Code how to work on toolhive-studio itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything toolhive-studio configures →

Reuse

Borrowing it

Nothing to install: this file belongs to stacklok/toolhive-studio. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/stacklok/toolhive-studio/main/.claude/skills/testing-with-api-mocks/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/stacklok/toolhive-studio

Made for: Claude Code.

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 testing-with-api-mocks

README.md
[![agentmods](https://agentmods.dev/badge/skills/stacklok/toolhive-studio/testing-with-api-mocks/github.svg)](https://agentmods.dev/skills/stacklok/toolhive-studio/testing-with-api-mocks)
Your own site
<a href="https://agentmods.dev/skills/stacklok/toolhive-studio/testing-with-api-mocks"><img src="https://agentmods.dev/badge/skills/stacklok/toolhive-studio/testing-with-api-mocks/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 testing-with-api-mocks

Your own site · 80×15
<a href="https://agentmods.dev/skills/stacklok/toolhive-studio/testing-with-api-mocks"><img src="https://agentmods.dev/badge/skills/stacklok/toolhive-studio/testing-with-api-mocks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,438 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 warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 118
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
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.00044 $0.01438
Opus 5.5 $0.00018 $0.00575
Sonnet 5.5 $0.00009 $0.00288
Haiku 4.5 $0.00004 $0.00144

Measured 2mo ago against content hash 4d26b466a92a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

testing-with-api-mocks 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 2mo 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.

.claude/skills/testing-with-api-mocks/SKILL.md · 199 lines

How it starts

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

Testing with API Mocks

This is the starting point for all API mocking in tests. Read this skill first before working on any test that involves API calls.

This project uses MSW (Mock Service Worker) with auto-generated schema-based mocks. When writing tests for code that calls API endpoints, mocks are created automatically.

How It Works

  1. Run a test that triggers an API call (e.g., a component that fetches data)
  2. Mock auto-generates if no fixture exists for that endpoint
  3. Fixture saved to renderer/src/common/mocks/fixtures/<endpoint>/<method>.ts
  4. Subsequent runs use the saved fixture

No manual mock setup is required for basic tests.

Fixture Location

Fixtures are organized by endpoint path and HTTP method:

renderer/src/common/mocks/fixtures/
├── groups/
│   ├── get.ts          # GET /api/v1beta/groups
│   └── post.ts         # POST /api/v1beta/groups
├── workloads/
│   └── get.ts          # GET /api/v1beta/workloads
├── workloads_name/
│   └── get.ts          # GET /api/v1beta/workloads/:name
└── ...

Path parameters like :name become _name in the directory name.

Fixture Structure

Generated fixtures use the AutoAPIMock wrapper with types from the OpenAPI schema:

// renderer/src/common/mocks/fixtures/groups/get.ts
import type {
  GetApiV1BetaGroupsResponse,
  GetApiV1BetaGroupsData,
} from '@common/api/generated/types.gen'
import { AutoAPIMock } from '@mocks'

export const mockedGetApiV1BetaGroups = AutoAPIMock<
  GetApiV1BetaGroupsResponse,
  GetApiV1BetaGroupsData
>({
  groups: [
    { name: 'default', registered_clients: ['client-a'] },
    { name: 'research', registered_clients: ['client-b'] },
  ],
})

The second type parameter (*Data) provides typed access to request parameters (query, path, body) for conditional overrides.

Naming Convention

Export names follow the pattern: mocked + HTTP method + endpoint path in PascalCase.

  • GET /api/v1beta/groups → mockedGetApiV1BetaGroups
  • POST /api/v1beta/workloads → mockedPostApiV1BetaWorkloads
  • GET /api/v1beta/workloads/:name → mockedGetApiV1BetaWorkloadsByName

Read the full file on GitHub · 199 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. 2mo ago First seen · 199 lines · 44 tokens per session scan A 4d26b466a92a

Subscribe to this mod's changes

testing-with-api-mocks is a skill published in the GitHub repository stacklok/toolhive-studio (173 stars, last pushed today), licensed Apache-2.0. It adds 44 tokens to every session and 1,438 once invoked, about $0.0002 per session on Opus 5.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.

Related

Other skills, from other repositories

run-tests

Run Embody's test suite and write new tests (Embody development).

dylanroscover/Embody · 18 tokens

testing

MUST READ before declaring any TouchDesigner build, fix or show done, and before any soak or performance test: the verification ladder (structure, errors, frame, motion, data, performance, soak, end to end), runsoaktest and the observer-effect rules that keep measuring from perturbing the show, the iterate-by-capture…

dylanroscover/Embody · 77 tokens

agent-tests

MUST READ before calling RunAgentTests or touching agent-tier test infrastructure -- these tests spawn real AI clients (Claude Code, Codex) and SPEND SUBSCRIPTION USAGE; never run casually. Tier model, async runner rationale, auth/isolation rules.

dylanroscover/Embody · 56 tokens

ganju-cli

Write, test, deploy and debug Ganju custom tools (Functions) with the ganju CLI and the @ganju/sdk handler API. Use this whenever the user works in a folder with a ganju.json, imports @ganju/sdk or defineTool, mentions @ganju/cli or any ganju command (init, link, build, test, deploy, logs, versions, rollback, secret…

MontoyaAndres/ganju · 148 tokens

elicitation-scenarios

Drive the elicitation tester's scenario catalogue over the modern protocol, where input requests arrive in the tool result and are answered from the chat.

mappedsky/seizu · 34 tokens

elicitation-scenarios-legacy

Drive the elicitation tester's scenario catalogue over the legacy protocol, where the server sends elicitation requests during the call instead of returning them in the result.

mappedsky/seizu · 39 tokens