api-patterns

api-patterns is a skill for Claude Code, Codex from monkilabs/opencastle. It costs 56 tokens per session (472 once invoked), scanned A, original, MIT.

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

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

Good fit Use it when adding API routes, handling form submissions or data changes, validating requests with Zod, or connecting an application to another service.

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

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/monkilabs/opencastle/api-patterns"><img src="https://agentmods.dev/badge/skills/monkilabs/opencastle/api-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 472 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
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.00056 $0.00472
Opus 5.5 $0.00022 $0.00189
Sonnet 5.5 $0.00011 $0.00094
Haiku 4.5 $0.00006 $0.00047

Measured 10d ago against content hash fecb5c1097b2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 10d 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 endpoint against the dev server with `curl -fsS` before you call it done.
src/orchestrator/skills/api-patterns/SKILL.md · 34 lines

What it actually says

API Patterns

The project's endpoints and where they live: .opencastle/stack/api-config.md when it has one, and the skill bound to the framework slot. Match what the existing endpoints do; where they disagree, follow the majority and say so, rather than add a third way.

Contract first

Decide the request, the response, the status codes and the error cases before you write the handler. Writing the handler first is how inconsistent APIs happen.

  • Validate every input with a schema at the top of the handler (Zod, Pydantic, the framework's validator): 400 or 422 on failure, naming the field.
  • One error shape, such as { "error": { "code": "VALIDATION_ERROR", "message": "...", "details": [...] } }, with no stack trace or query in it. The status says what happened: 400, 401, 403, 404, 409, 422, 429, 500.
  • Lists are paginated, with a cursor when the data changes under the reader, and limit capped on the server.
  • Changes are additive. Add fields; never remove or rename one a client may use without a new version and a deprecation period.

Writes and side effects

  • A mutation a client may retry is idempotent: an idempotency key, or an upsert on a natural key.
  • Authorization is checked on the server for every call (security-hardening).

External APIs

  • A timeout on every call. Retry only what is safe to repeat, at most twice, with backoff.
  • Map their errors to your error shape, and log the upstream detail on the server.

Limits and caching

Rate-limit public endpoints. Set Cache-Control, and an ETag on responses clients poll.

Smoke-test a new endpoint against the dev server with curl -fsS before you call it done.

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. 10d ago Changed · +3 lines · +19 tokens per session fecb5c1097b2
  2. 12d ago Changed · -18 tokens per session 753dc9362933
  3. 1mo 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 (80 stars, last pushed 2d ago), licensed MIT. It adds 56 tokens to every session and 472 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-08-30.