api-patterns

A set of patterns for building web API endpoints and server-side actions. It covers request validation, responses, errors, pagination, caching, rate limits, and connections to external REST services.

In plain words
What is it for?
Use it when adding API routes, handling form submissions or data changes, validating requests with Zod, or connecting an application to another service.
Why use it?
It gives request handlers consistent input checks and error responses, reducing invalid data, leaked details, and unreliable external calls.

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/monkilabs/opencastle/api-patterns
Any agent
npx skills add monkilabs/opencastle --skill api-patterns
Clone the repo
git clone --depth 1 https://github.com/monkilabs/opencastle

Made for: Claude Code, Codex.

Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 401 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 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.00055 $0.00401
Opus 5 $0.00028 $0.00200
Sonnet 5 $0.00011 $0.00080
Haiku 4.5 $0.00006 $0.00040

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

Security

Grade A, and why

api-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 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.

Makes network callslowCapability

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

Smoke-test a new route with `curl -fsS "http://localhost:3000/api/<name>?query=test"`.
src/orchestrator/skills/api-patterns/SKILL.md · 31 lines

What it actually says

API Patterns

Project-specific config: .opencastle/stack/api-config.md.

Architecture

Layer Use for
Server Actions (preferred) mutations, form submissions, data writes, auth
Route Handlers (route.ts) analytics, autocomplete, external integrations
Proxy layer IP rate limiting, fingerprinting, bot detection

Route files live at app/api/<name>/route.ts or app/<segment>/route.ts.

Rules

  • Validate every input with Zod on the server at the top of the handler; 400 on parse failure.
  • Response envelope: { "data": ..., "meta": { "total": 42, "page": 1 } }
  • Error shape: { "error": { "code": "VALIDATION_ERROR", "message": "...", "details": [...] } } — never leak stack traces. Status codes: 400, 401, 403, 404, 422, 429, 500.
  • RESTful nouns, versioned: /api/v1/places/:slug. Add fields only — never remove or rename; deprecation headers before removal.
  • Pagination: cursor-based preferred; params limit, cursor, sort, order.
  • Retry external API calls twice with linear backoff (500 ms × attempt).
  • Rate-limit public endpoints; set Cache-Control and ETag/If-None-Match.

Smoke-test a new route with curl -fsS "http://localhost:3000/api/<name>?query=test".

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 · 31 lines · 55 tokens per session scan A 682e3e7b4022

Subscribe to this mod's changes

api-patterns is a skill published in the GitHub repository monkilabs/opencastle (61 stars, last pushed 4d ago), licensed MIT. It adds 55 tokens to every session and 401 once invoked, about $0.0003 per session on Opus 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-08-30.

Related

Other skills, from other repositories

product-architect

Complete product development system with 64 agents and 35 frameworks. Use when the user wants to build a product, write a PRD, plan an MVP or roadmap, design an app, research a market or check whether a feature already exists or is novel, do competitive analysis, run a security audit, build a financial model, plan…

ankitjha67/product-architect · 211 tokens

codex-delegation

Use when a coding task would benefit from delegating work to Codex in the background — a deep independent second opinion, security or architecture analysis, or a parallel implementation running while the session continues. Lets Claude drive the codex companion itself (task, review, status --wait, result) without the…

zebbern/agent-collab · 74 tokens

cursor-delegation

Use when a coding task would benefit from delegating work to Cursor in the background — fast parallel implementation, scaffolding, or an everyday review running while the session continues. Lets Claude drive the cursor companion itself (task, review, status --wait, result) without the user typing /cursor: commands.

zebbern/agent-collab · 66 tokens

cursor-cli-runtime

Internal helper contract for calling the cursor-companion runtime from Claude Code.

zebbern/agent-collab · 17 tokens

cursor-prompting

Internal guidance for composing cursor-agent prompts and picking models for coding, review, diagnosis, and research tasks inside the Cursor Claude Code plugin.

zebbern/agent-collab · 31 tokens

cursor-result-handling

Internal guidance for presenting Cursor helper output back to the user.

zebbern/agent-collab · 16 tokens