testing-api-assertions

A testing guide for checking that software sends the right API requests when it creates, changes, or deletes data. An API is the part of a program that lets it communicate with a backend service.

In plain words
What is it for?
Use it to test form submissions, buttons, and other actions that create, update, or delete records through an API.
Why use it?
It catches incorrect request methods, URLs, or data in actions that change backend data. It avoids adding low-value checks for simple data reads.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/stacklok/toolhive-studio/testing-api-assertions
Any agent
npx skills add stacklok/toolhive-studio --skill testing-api-assertions
Clone the repo
git clone --depth 1 https://github.com/stacklok/toolhive-studio

Made for: Claude Code, Codex.

Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 893 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00045 $0.00893
Opus 5 $0.00023 $0.00447
Sonnet 5 $0.00009 $0.00179
Haiku 4.5 $0.00005 $0.00089

Measured 2d ago against content hash 2f2b537ba0e2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-api-assertions 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 2d 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-api-assertions/SKILL.md · 142 lines

How it starts

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

Testing API Assertions

Verify that your code sends the correct API requests for operations with side effects.

When to Use Request Assertions

DO use for operations with side effects:

  • Creating resources (POST)
  • Updating resources (PUT/PATCH)
  • Deleting resources (DELETE)
  • Any mutation that changes backend state

DON'T use for read operations:

  • Fetching data (GET)
  • For these, just verify the component displays the data correctly
  • The mock API is not stateful, so verifying GET requests adds no value

recordRequests()

Use recordRequests() to capture all API requests made during a test:

import { recordRequests } from '@/common/mocks/node'

it('creates a group with correct payload', async () => {
  const rec = recordRequests()

  // ... perform action that triggers API call ...
  await userEvent.click(screen.getByRole('button', { name: /create/i }))

  // Find the request
  const request = rec.recordedRequests.find(
    (r) => r.method === 'POST' && r.pathname === '/api/v1beta/groups'
  )

  // Assert it was made with correct data
  expect(request).toBeDefined()
  expect(request?.payload).toEqual({ name: 'my-group' })
})

Recorded Request Shape

Each recorded request contains:

{
  pathname: '/api/v1beta/groups',      // URL path
  method: 'POST',                       // HTTP method
  payload: { name: 'my-group' },        // Parsed JSON body (if present)
  search: { filter: 'active' },         // Query parameters
}

Common Patterns

Verify POST payload

const rec = recordRequests()

// ... trigger create action ...

const createRequest = rec.recordedRequests.find(
  (r) => r.method === 'POST' && r.pathname === '/api/v1beta/workloads'
)
expect(createRequest?.payload).toMatchObject({
  name: 'my-server',
  group: 'default',
})

Verify DELETE was called

const rec = recordRequests()

// ... trigger delete action ...

const deleteRequest = rec.recordedRequests.find(
  (r) =>
    r.method === 'DELETE' && r.pathname === '/api/v1beta/workloads/my-server'
)
expect(deleteRequest).toBeDefined()

Read the full file on GitHub · 142 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. 2d ago First seen · 142 lines · 45 tokens per session scan A 2f2b537ba0e2

Subscribe to this mod's changes

testing-api-assertions is a skill published in the GitHub repository stacklok/toolhive-studio (163 stars, last pushed 4d ago), licensed Apache-2.0. It adds 45 tokens to every session and 893 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-08-30.

Related

Other skills, from other repositories

quality

Evaluates whether a GitHub issue is spam, empty, needs more information, or is OK to proceed.

google-gemini/gemini-cli · 24 tokens

investigate-issue

Investigate a GitHub issue by fetching details, analyzing the codebase, researching documentation, and presenting an actionable implementation plan with test guidance. Use when asked to investigate, analyze, triage, or plan work for a GitHub issue. Invoked with /investigate-issue or /investigate-issue (prompts for ID).

maximhq/bifrost · 78 tokens

harness-test-writer

Add regression test cases to the Bifrost provider harness (the Postman collection run via make run-provider-harness-test) based on a merged PR or a GitHub issue. Fetches the PR/issue, traces the affected wire path in the codebase, checks existing harness coverage, designs cases following harness conventions, inserts…

maximhq/bifrost · 133 tokens

bugcrowd-reporting

Bugcrowd-specific reporting tactics complementing report-writing: VRT category search-and-fallback strategy when no exact match exists, manual severity override when VRT defaults underrate impact, severity-request paragraph as first body section, OOS-clause rebuttal templates (rate limiting on auth-flow endpoints…

elementalsouls/Claude-BugHunter · 171 tokens

hunt-ato

Hunt account takeover taxonomy — 9 distinct paths to ATO, plus chains. Paths: (1) password reset flaws (host-header injection redirects token, predictable/numeric token, Referer leak, no-expiry/reuse), (2) email change without re-auth, (3) OAuth account-link CSRF, (4) MFA bypass (per hunt-mfa-bypass), (5) session…

elementalsouls/Claude-BugHunter · 241 tokens

session-investigator

Investigate fast-agent session and history files to diagnose issues. Use when a session ended unexpectedly, when debugging tool loops, when correlating sub-agent traces with main sessions, or when analyzing conversation flow and timing. Covers session.json metadata, history JSON format, message structure, tool…

evalstate/fast-agent · 68 tokens