write-fixtures

A guide for writing test fixtures for aimock, a local mock server that simulates AI providers, tools, multimedia APIs, MCP, A2A, and related services. Fixtures define which request to match and what response or error to return.

In plain words
What is it for?
Use it to create or debug mock responses, tool-call sequences, sequential replies, embeddings, structured output, error cases, and agent-loop tests.
Why use it?
It lets tests run predictably without calling real AI services and helps reproduce multi-turn conversations, tool calls, failures, and provider responses.

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/copilotkit/aimock/write-fixtures
Any agent
npx skills add CopilotKit/aimock --skill write-fixtures
Clone the repo
git clone --depth 1 https://github.com/CopilotKit/aimock

Made for: Claude Code, Codex.

Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 10,514 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00048 $0.10514
Opus 5 $0.00024 $0.05257
Sonnet 5 $0.00010 $0.02103
Haiku 4.5 $0.00005 $0.01051

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

Security

Grade C, and why

write-fixtures scanned grade C with 1 finding 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.

Hidden instructionshighPrompt injection

Directives inside HTML comments, invisible characters or bidirectional overrides are read by the model and not by the person reviewing the file.

<!-- prettier-ignore -->
skills/write-fixtures/SKILL.md · 842 lines

How it starts

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

Writing aimock Test Fixtures

What aimock Is

aimock is a zero-dependency mock infrastructure for AI apps. Fixture-driven. Multi-provider (OpenAI, Anthropic, Gemini, Gemini Interactions, AWS Bedrock, Azure OpenAI, Vertex AI, Ollama, Cohere, OpenRouter). Multimedia endpoints (image generation, text-to-speech, audio transcription, video generation). MCP, A2A, AG-UI, and vector DB mocking. Runs a real HTTP server on a real port — works across processes, unlike MSW-style interceptors. WebSocket support for OpenAI Responses/Realtime and Gemini Live APIs. Record-and-replay for all endpoints including multimedia. Chaos testing and Prometheus metrics.

Core Mental Model

  • Fixtures = match criteria + response
  • First-match-wins — order matters
  • All providers share one fixture pool (provider adapters normalize to ChatCompletionRequest)
  • Fixtures are live — mutations after start() take effect immediately
  • Sequential responses are supported via sequenceIndex (match count tracked per fixture)

Match Field Reference

Field Type Matches Against
userMessage string Substring of last role: "user" message text
userMessage RegExp Pattern test on last role: "user" message text
systemMessage string Substring of the concatenated text of every role: "system" message in the request. Use to gate a fixture on host-supplied context (persona, agent-context entries) so changes to that context cause the fixture to fall through instead of returning a stale baked response
systemMessage string[] Array of substrings — ALL must be present in the joined system text (AND semantics). Use when the gate must combine multiple non-adjacent tokens whose serialisation order isn't stable
systemMessage RegExp Pattern test on the concatenated system-message text
inputText string Substring of embedding input text (concatenated if multiple inputs)
inputText RegExp Pattern test on embedding input text
toolName string Exact match on any tool in request's tools[] array (by function.name)
toolCallId string Exact match on tool_call_id of last role: "tool" message
toolResultContains string Substring of the last tool message's text content, gated on that message being the request's LAST message (same rule as toolCallId). Discriminates resume paths that share a tool_call_id and differ only inside the tool-result payload (e.g. approve {"chosen_time": …} vs cancel {"cancelled": true})
model string Exact match on req.model
model RegExp Pattern test on req.model
responseFormat string Exact match on req.response_format.type ("json_object", "json_schema")
sequenceIndex number Matches only when this fixture's match count equals the given index (0-based)
turnIndex number Stateless conversation-depth matching. Counts role: "assistant" messages in the request; matches when that count equals the value. turnIndex: 0 = first turn (no prior assistant messages). Use instead of sequenceIndex for shared/deployed instances where stateful counters break under concurrency
hasToolResult boolean Stateless tool-message presence matching, scoped to the CURRENT turn (messages after the last role: "user" message). true matches when a role: "tool" message appears after the last user message; false matches when none does. (If the request has no user message, the whole conversation is scanned.) Provider-consistent across all aimock handlers (OpenAI, Claude, Gemini, Bedrock, Ollama, Cohere)
endpoint string Restrict to endpoint type: "chat", "image", "speech", "transcription", "video", "embedding"
predicate (req: ChatCompletionRequest) => boolean Custom function — full access to request

Read the full file on GitHub · 842 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 · 842 lines · 48 tokens per session scan C db712b41365e

Subscribe to this mod's changes

write-fixtures is a skill published in the GitHub repository CopilotKit/aimock (902 stars, last pushed 2d ago), licensed MIT. It adds 48 tokens to every session and 10,514 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (hidden instructions). 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

skill-creator

Create, install, or update skills in the workspace. Use when (1) installing a skill from a URL or remote source, (2) creating a new skill from scratch, (3) updating or restructuring existing skills. Always use this skill for any skill installation or creation task.

zhayujie/CowAgent · 61 tokens

image-generation

Generate or edit images from text prompts. Use when the user asks to create, draw, design, or edit an image, illustration, photo, icon, poster, or any visual content.

zhayujie/CowAgent · 41 tokens

implementation-final-review

Perform the repository's risk-tiered independent final review before implementation completion. Use only when explicitly invoked or when repository instructions require it after behavior-impacting implementation work; audit the complete task diff, supported contracts, lifecycle and security boundaries, complexity, and…

openai/openai-agents-python · 58 tokens

metrics-instrumentation

Specification for instrumenting an opik-backend workflow with operational OpenTelemetry metrics — per-stage throughput/latency/error counters and native histograms, dimensioned per-customer (workspace). Use when a pipeline (scoring, ingestion, experiments, jobs) needs per-stage visibility. Covers metric emission only…

comet-ml/opik · 93 tokens

baby-sit

Monitor a GitHub pull request until CI is green, diagnose failures, and rerun only evidence-backed flaky GitHub Actions jobs.

langchain-ai/open-swe · 30 tokens

continual-learning

Nightly refinement of an existing per-repo review-style prompt using this reviewer's own finding outcomes. Read confirmed (resolved-by-commit / thumbs-up) and dismissed (thumbs-down) findings, promote the bug patterns the team actually fixes, demote the false-positive patterns, reconcile against the current prompt…

langchain-ai/open-swe · 89 tokens