api-client-patterns

api-client-patterns is a skill for Claude Code, Codex from saajunaid/caddis-plugin. It costs 53 tokens per session (2,835 once invoked), scanned A, original, MIT.

A set of patterns for building typed clients that call REST APIs and tRPC, a system for connecting TypeScript applications to backend procedures.

In plain words
What is it for?
Use it to build fetch wrappers, validate responses, add authentication, generate OpenAPI clients, or manage queries, mutations, infinite lists, and optimistic updates.
Why use it?
It helps keep frontend requests, responses, authentication, errors, and data-fetching behaviour consistent and checked against expected types.

Skill for Claude CodeCodex

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

Good fit Use it to build fetch wrappers, validate responses, add authentication, generate OpenAPI clients, or manage queries, mutations, infinite lists, and optimistic updates.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/saajunaid/caddis-plugin/api-client-patterns
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 saajunaid/caddis-plugin --skill api-client-patterns
Clone the repo
git clone --depth 1 https://github.com/saajunaid/caddis-plugin

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 api-client-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/saajunaid/caddis-plugin/api-client-patterns/github.svg)](https://agentmods.dev/skills/saajunaid/caddis-plugin/api-client-patterns)
Your own site
<a href="https://agentmods.dev/skills/saajunaid/caddis-plugin/api-client-patterns"><img src="https://agentmods.dev/badge/skills/saajunaid/caddis-plugin/api-client-patterns/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 api-client-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/saajunaid/caddis-plugin/api-client-patterns"><img src="https://agentmods.dev/badge/skills/saajunaid/caddis-plugin/api-client-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,835 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.00053 $0.02835
Opus 5.5 $0.00021 $0.01134
Sonnet 5.5 $0.00011 $0.00567
Haiku 4.5 $0.00005 $0.00283

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

Security

Grade A, and why

api-client-patterns scanned grade A 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 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

response = await fetch(url, { ...init, headers: { 'Content-Type': 'application/json', ...init?.headers } })
.github/skills/coding/api-client-patterns/SKILL.md · 368 lines

How it starts

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

API Client Patterns Skill

Typed, maintainable API clients — from simple fetch wrappers to full TanStack Query integration and tRPC.

1. Typed Fetch Wrapper with Zod Validation

// lib/api/fetcher.ts
import { z } from 'zod'

export type ApiError = { type: 'network'; message: string }
                     | { type: 'validation'; issues: z.ZodIssue[] }
                     | { type: 'http'; status: number; body: unknown }

export type ApiResult<T> = { ok: true; data: T } | { ok: false; error: ApiError }

async function fetchJson<T>(
  url: string,
  schema: z.ZodSchema<T>,
  init?: RequestInit,
): Promise<ApiResult<T>> {
  let response: Response

  try {
    response = await fetch(url, { ...init, headers: { 'Content-Type': 'application/json', ...init?.headers } })
  } catch (e) {
    return { ok: false, error: { type: 'network', message: String(e) } }
  }

  if (!response.ok) {
    return { ok: false, error: { type: 'http', status: response.status, body: await response.json().catch(() => null) } }
  }

  const raw = await response.json()
  const parsed = schema.safeParse(raw)

  if (!parsed.success) {
    return { ok: false, error: { type: 'validation', issues: parsed.error.issues } }
  }

  return { ok: true, data: parsed.data }
}

2. API Client Factory Pattern

// lib/api/client.ts
import { z } from 'zod'

function createApiClient(baseUrl: string, getAuth: () => string | null) {
  async function request<T>(
    method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
    path: string,
    schema: z.ZodSchema<T>,
    body?: unknown,
  ) {
    const token = getAuth()
    return fetchJson(`${baseUrl}${path}`, schema, {
      method,
      headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) },
      ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
    })
  }

  return {
    get: <T>(path: string, schema: z.ZodSchema<T>) => request('GET', path, schema),
    post: <T>(path: string, schema: z.ZodSchema<T>, body: unknown) => request('POST', path, schema, body),
    put: <T>(path: string, schema: z.ZodSchema<T>, body: unknown) => request('PUT', path, schema, body),
    patch: <T>(path: string, schema: z.ZodSchema<T>, body: unknown) => request('PATCH', path, schema, body),
    delete: <T>(path: string, schema: z.ZodSchema<T>) => request('DELETE', path, schema),
  }
}

// Usage
import { getAccessToken } from '@/lib/auth'
export const api = createApiClient(process.env.NEXT_PUBLIC_API_URL!, getAccessToken)

Read the full file on GitHub · 368 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 Changed · -36 tokens per session dead98f9379e
  2. 2mo ago First seen · 368 lines · 89 tokens per session scan A 971aa818c1b0

Subscribe to this mod's changes

api-client-patterns is a skill published in the GitHub repository saajunaid/caddis-plugin (0 stars, last pushed 3d ago), licensed MIT. It adds 53 tokens to every session and 2,835 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

api-client-patterns compared with skills from other repositories

api-client-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
api-client-patternssaajunaid/caddis-pluginSkill03d agoMITA53Claude Code, Codex
agent-raft-managerruvnet/rufloSkill83ktodayMITA18Claude Code
moai-ref-api-patternsmodu-ai/moai-adkSkill1.3ktodayApache-2.0A85Claude Code
continuum-tools-mcpshyftlabs/continuumSkill863d agoApache-2.0A94Claude Code
goga-define-challengeqarium/gogaSkill468d agoBSD-3-ClauseA6Claude Code, Codex
goga-define-goalsqarium/gogaSkill468d agoBSD-3-ClauseA6Claude Code, Codex
skill-creatoreigent-ai/eigentSkill16kyesterdayApache-2.0A35Claude Code, Codex