api-engineering

Guidance for designing and maintaining APIs, the contracts that let different programs exchange data. It covers REST, GraphQL, gRPC, events, schemas, compatibility, authentication, pagination, idempotency, webhooks, and contract testing.

In plain words
What is it for?
Use it when creating or changing routes, request and response fields, authentication rules, generated clients, webhooks, event schemas, or API version migrations.
Why use it?
It helps keep API changes compatible with the applications, SDKs, and services that depend on them.

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/cass-2003/local-workflow-skill/api-engineering
Any agent
npx skills add cass-2003/local-workflow-skill --skill api-engineering
Clone the repo
git clone --depth 1 https://github.com/cass-2003/local-workflow-skill

Made for: Claude Code, Codex.

Per session 118 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 13,462 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.00118 $0.13462
Opus 5 $0.00059 $0.06731
Sonnet 5 $0.00024 $0.02692
Haiku 4.5 $0.00012 $0.01346

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

Security

Grade A, and why

api-engineering 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 3d 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.

skills/backend-api/community/api-engineering/SKILL.md · 388 lines

How it starts

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

API 工程

API 工程(api-engineering,兼容 slug: api)负责本技能描述范围内的定位、执行、验证和交接边界;旧短 slug 仅作兼容 alias/URL 主键,不作为规范技能名。

定位:把 API 从“能调通”收敛为“契约可验证、消费者可迁移、状态码可观测、失败可回滚”。先拿需求、消费者、版本、契约和线上证据,再设计 REST/GraphQL/gRPC/Event 边界;不凭记忆改公开契约。

快速总则

  • API 是跨端契约,不是控制器函数;任何字段、状态码、错误 code、认证 scope、分页语义、事件 schema 改动都要查生产方、消费方、SDK、Mock、OpenAPI、网关、缓存、监控和发布回滚。
  • 先定资源语义和失败语义,再写接口;REST 用资源和 HTTP 语义,GraphQL 用聚合和按需取数,gRPC 用强类型内网 RPC,Event/Webhook 用异步事实通知。
  • OpenAPI/JSON Schema/Proto/GraphQL schema/AsyncAPI 是契约源;示例、Mock、typed clients、contract test 必须与真实响应同源或可校验。
  • 新端点默认认证;资源 id、子资源 id、批量 id、GraphQL node id、事件订阅都要对象级授权,防 BOLA/IDOR。
  • POST 创建、支付、扣减、状态流转、Webhook、AI tool action 必须有幂等键、重放防护、并发冲突处理和补偿查询。
  • 破坏性变更必须版本化、双字段/双路由过渡、灰度、Deprecation/Sunset 或等价公告;内部 API 也要说明消费者和回滚点。
  • 错误模型必须稳定:HTTP status、业务 code、Problem Details/type、字段级错误、request_id、重试语义不能漂移。
  • 统一表示:id 格式、时间一律 ISO 8601/RFC 3339 + 时区、金额用最小货币单位或 decimal string、单位写入字段名/Schema、locale/language/currency 显式传递;枚举新增默认兼容,客户端必须容忍未知枚举。
  • 证据不足先补证据;无法确认消费者时按公开破坏性变更处理,不硬删旧契约。

强制执行流程:需求 → 资源 → 契约 → 消费者 → 门禁

  1. 需求拆解:先列业务目标、消费者、用户旅程、禁止项、读写频率、数据敏感级别、兼容范围、回滚要求和验收样本;缺消费者证据按公开 API 处理。
  2. API 选型:必须说明 REST/GraphQL/gRPC/Event/Webhook/SSE 的选择理由;长耗时、最终一致、批量导入导出、回调结果默认评估 202 + operation resource 或事件化。
  3. 资源建模:列资源、子资源、关系、动作、状态、所有者、权限边界;命令型动作优先转成资源状态流转,不能把控制器函数直接暴露成 API。
  4. 状态机建模:涉及订单、任务、审批、支付、库存、AI tool action 时,必须列状态、事件、允许迁移、终态、非法迁移、补偿和并发冲突。
  5. 契约草案:实现前产出 method/path 或 schema/operation、请求、响应、错误示例、分页/过滤/排序、权限 scope、幂等、限流和可观测字段。
  6. 消费者对账:列前端、App、SDK、第三方、后台任务、BI、Webhook、Mock、文档和缓存使用矩阵;未确认消费者时不得删除或收紧契约。
  7. 兼容判定:字段、枚举、错误、状态码、排序、分页、scope、limit/quota 任一变化都要判定兼容等级、迁移窗口、旧端策略和回滚点。
  8. 契约门禁:OpenAPI/Schema/Proto/GraphQL/AsyncAPI 必须与 Mock、SDK、示例、contract test 和真实响应校验同源或可自动比对。
  9. 测试交接:交给 tst 的最小包包括成功/边界/异常/权限/并发/重放/旧端/contract/灰度回滚场景。
  10. 停止条件:无消费者清单、无契约草案、无错误模型、无权限边界、无兼容判定、无回滚点或安全边界不清时,不进入实现。

单技能开发闭环门禁

  • 实现前门禁:每个新增/修改接口必须先落一页契约说明,至少包含 method/path、输入 DTO、输出 DTO、错误码、权限、分页/过滤/排序、幂等、兼容性、验证样本和回滚点;没有这页契约,不允许直接写 controller。
  • Controller 门禁:controller 只做协议适配、认证上下文、DTO 解析、错误映射和 response envelope;业务规则、状态机、权限判断、DB model 更新、第三方副作用不得堆在 controller 函数里。
  • DTO 门禁:请求 DTO、响应 DTO、内部实体、DB model、事件 payload 必须分层;禁止把请求体直接绑定内部实体后保存,禁止把 DB model 原样返回给外部 API。
  • 输入门禁:未知字段、重复字段、大小写差异、空对象、超大 body/header、content-type 不匹配、数组超限、嵌套深度、非法 enum、时区/金额/单位都要有固定处理策略和测试。
  • 输出门禁:响应只返回契约字段;默认不暴露内部 id、审计字段、租户字段、权限字段、软删字段、实验字段、第三方原始错误和调试信息。
  • 错误门禁:同一失败只能有一个稳定 HTTP status + 业务 code;message/detail 可变,客户端只能依赖 code、status、retryable 和字段级错误。
  • 权限门禁:先认证,再租户隔离,再对象级授权,再字段级授权,再动作授权;批量、导出、搜索、缓存、异步任务和 webhook 补偿查询也要走同一权限链。
  • 写入门禁:任何写接口必须回答“谁可写、可写哪些字段、写入前状态、写入后状态、并发冲突、幂等重放、失败补偿、审计日志、回滚策略”。
  • 兼容门禁:旧客户端、SDK、Mock、OpenAPI、文档、网关缓存、监控分桶、告警阈值和灰度开关必须同步;只改服务端实现不算完成。
  • 验收门禁:不能只测 happy path;最少覆盖成功、字段缺失/null/零值、非法字段、权限失败、对象越权、并发、重复请求、旧端 contract、SDK/Mock 和回滚验证。
  • 证据门禁:完成前必须给出契约 diff、真实请求/响应样本、schema 校验或 contract test、错误样本、权限样本、灰度指标/日志 request_id、回滚开关或旧版本路径。

Read the full file on GitHub · 388 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. 3d ago First seen · 388 lines · 118 tokens per session scan A b2ed61f62546

Subscribe to this mod's changes

api-engineering is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 1mo ago), licensed MIT. It adds 118 tokens to every session and 13,462 once invoked, about $0.0006 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

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens