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.
npx agentmods add skills/dhslegen/digital-delivery-team/api-contract-firstnpx skills add dhslegen/digital-delivery-team --skill api-contract-firstgit clone --depth 1 https://github.com/dhslegen/digital-delivery-teamWrote 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.
[](https://agentmods.dev/skills/dhslegen/digital-delivery-team/api-contract-first)<a href="https://agentmods.dev/skills/dhslegen/digital-delivery-team/api-contract-first"><img src="https://agentmods.dev/badge/skills/dhslegen/digital-delivery-team/api-contract-first.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00062 | $0.01208 |
| Opus 5 | $0.00031 | $0.00604 |
| Sonnet 5 | $0.00012 | $0.00242 |
| Haiku 4.5 | $0.00006 | $0.00121 |
Grade A, and why
api-contract-first 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 6d 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.
How it starts
The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.
API Contract First
Triggers
- architect-agent 启动 /
/design命令(写契约) /build-api//build-webmain thread 加载 backend-development / frontend-development skill 时只读链入(契约消费方,M6.4 起 main thread 直接执行而非 subagent)
Core Principles
- 契约先于代码:没有 lint 通过的 OpenAPI,不允许动 web/ 或 server/
- 契约是唯一真相源:UI 文案、错误提示、日志格式以外的所有接口约定必须出自契约
- 契约变更 = 事件:每次契约变更在
docs/arch.md的 ADR 章节追加一条,说明原因、影响面、兼容策略
Design Rules
URL 结构(DDT 标准)
# 资源名:名词、复数、小写、kebab-case
GET /api/v1/users
POST /api/v1/users
GET /api/v1/users/:id
PUT /api/v1/users/:id
PATCH /api/v1/users/:id
DELETE /api/v1/users/:id
# 子资源(所有权关系)
GET /api/v1/users/:id/orders
# 动作(谨慎使用,限非 CRUD)
POST /api/v1/orders/:id/cancel
字段约束
- 所有字段含
type/required/description/example - 所有错误响应用枚举(
error.code)+ 人类可读 message,避免只有数字码 - 分页统一:
page+pageSize+total,或游标cursor+nextCursor二选一,全局一致 - 幂等操作必须声明
Idempotency-Keyheader - 所有时间字段 ISO-8601 UTC
HTTP 状态码(强制)
200 OK — GET/PUT/PATCH 有响应体
201 Created — POST 成功(含 Location header)
204 No Content — DELETE/PUT 无响应体
400 Bad Request — 格式错误、缺少必填字段
401 Unauthorized — 未认证
403 Forbidden — 已认证但无权限
404 Not Found — 资源不存在
409 Conflict — 重复创建、状态冲突
422 Unprocessable Entity — 语义非法(格式合法但业务无效)
429 Too Many Requests — 限流(含 Retry-After header)
500 Internal Server Error — 不暴露内部细节
分页(二选一,全局保持一致)
- Offset(小数据集 < 10K / 管理后台):
?page=2&pageSize=20 - Cursor(大数据集 / 无限滚动):
?cursor=<opaque>&limit=20,响应含nextCursor
版本化策略(ADR)
1. URL Path 版本(推荐):/api/v1/ → /api/v2/
2. 不破坏性变更不需要新版本:
- 新增可选字段、新增端点、新增可选查询参数
3. 破坏性变更必须新版本:
- 删改字段名/类型、改 URL 结构、改认证方式
4. 废弃策略:宣告(6 个月) → Sunset header → 410 Gone
Do
- 用
npx @redocly/cli lint跑 schema lint,lint 必须通过后才能进入实现阶段 - 用
openapi-typescript或等价工具生成前端 types - 用
openapi-generator或等价工具生成后端路由骨架 - 每个 endpoint 含完整的 request / response / error 示例(见
templates/api-contract.template.yaml)
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.
- 6d ago First seen · 101 lines · 62 tokens per session scan A a2745c7c0b01
api-contract-first is a skill published in the GitHub repository dhslegen/digital-delivery-team (1 stars, last pushed 3mo ago), licensed MIT. It adds 62 tokens to every session and 1,208 once invoked, about $0.0003 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-31.
Other skills, from other repositories
symfony:doctrine-events
React to Doctrine entity lifecycle in Symfony with attribute listeners (#[AsDoctrineListener]/#[AsEntityListener], ORM 3) and lifecycle callbacks.
api-contract-design
REST and GraphQL API design patterns, OpenAPI/Swagger specifications, versioning strategies, and authentication patterns. Use when designing APIs, reviewing API contracts, evaluating API technologies, or implementing API endpoints.
symfony:api-platform-versioning
Evolve API Platform APIs via deprecation (deprecationReason/sunset, RFC 8594/9745), the recommended alternative to versioning; plus path/header strategies.
symfony:config-env-parameters
Manage Symfony configuration with .env files, parameters, secrets vault, and environment-specific settings.
symfony:doctrine-batch-processing
Process large datasets with Doctrine (ORM 3 toIterable, flush+clear, bulk DQL) and memory management.
symfony:doctrine-migrations
Create and manage Doctrine migrations (lib 4.x) for schema versioning; handle dependencies, rollbacks, and production deployment.