跳到主内容
智客 ZICQ

技能库 智客分类:文档办公 documenting-contracts

Documenting Contracts

在记录 HTTP API 、 消息有效载荷、 队列合同、 DTO 、 文件格式、 或 Webhooks 时使用 - 或者在写入遗留活动的 pip- reference 时使用, 或者在调用者不断询问字段的含义或端点返回错误时使用 。 编码了四个细节关卡,即DTO-第一目录,有源锚的有线类型,生成- spec one-home 规则,并省略-相对于-null语义. 每当机器接口需要记录其呼叫者时使用,即使没有人说"API docs".

24529 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

在记录 HTTP API 、 消息有效载荷、 队列合同、 DTO 、 文件格式、 或 Webhooks 时使用 - 或者在写入遗留活动的 pip- reference 时使用, 或者在调用者不断询问字段的含义或端点返回错误时使用 。 编码了四个细节关卡,即DTO-第一目录,有源锚的有线类型,生成- spec one-home 规则,并省略-相对于-null语义. 每当机器接口需要记录其呼叫者时使用,即使没有人说"API docs".

何时用

记录 HTTP API 、 消息有效载荷、 队列合同、 DTO 、 文件格式、 或 Webhooks - 或当写入遗留活动的 api- reference 时, 或当调用者不断询问字段的含义或端点返回出错时。 编码四个详细关卡, DTO- first

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Documenting contracts、Overview、When to invoke, and not、One home versus generated specs、The four detail levels、The DTO catalog。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Use when documenting an HTTP API, message payloads, queue contracts, DTOs, file formats, or webhooks - or when writing the api-reference of a legacy campaign, or when callers keep asking what a field means or which errors an endpoint returns. Encodes the four detail levels, the DTO-first catalog, wire types with source anchors, the generated-spec one-home rule, and omitted-versus-null semantics. Use whenever a machine interface needs documenting for its callers, even if nobody says "API docs".

Documenting contractsOverviewWhen to invoke, and notOne home versus generated specsThe four detail levelsThe DTO catalogThe templateAPI reference: <service>ConventionsEndpointsPOST /thingMessages

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
documenting-contracts
description
Use when documenting an HTTP API, message payloads, queue contracts, DTOs, file formats, or webhooks - or when writing the api-reference of a legacy campaign, or when callers keep asking what a field means or which errors an endpoint returns. Encodes the four detail levels, the DTO-first catalog, wire types with source anchors, the generated-spec one-home rule, and omitted-versus-null semantics. Use whenever a machine interface needs documenting for its callers, even if nobody says "API docs".
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「documenting-contracts」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-36713c000a126a7b-Documenting-Contracts.html
请存为 .cursor/skills/documenting-contracts/SKILL.md 或 .claude/skills/documenting-contracts/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/riekelt/technical-writer' --list

npx skills add 'https://github.com/riekelt/technical-writer' --skill 'documenting-contracts'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: documenting-contracts description: Use when documenting an HTTP API, message payloads, queue contracts, DTOs, file formats, or webhooks - or when writing the api-reference of a legacy campaign, or when callers keep asking what a field means or which errors an endpoint returns. Encodes the four detail levels, the DTO-first catalog, wire types with source anchors, the generated-spec one-home rule, and omitted-versus-null semantics. Use whenever a machine interface needs documenting for its callers, even if nobody says "API docs". --- # Documenting contracts **REQUIRED BACKGROUND:** the `technical-writing` skill (hard rules, truth rules, style). ## Overview A contract document is read by a stranger who cannot see the code and is about to depend on it. Core principle: **document the wire, exhaustively, with each detail at its own level; the caller's language is the wire format and domain terms, never the implementation's types.** Contract surfaces are reference kind, so the core Reference rule applies: every endpoint, every field, every error. ## When to invoke, and not Invoke when documenting anything machines call or parse: REST and RPC endpoints, message queues and topics, webhooks, CLI commands, file formats. The `api-reference.md` of a legacy campaign (`documenting-legacy-codebases`) is this skill's document. Do NOT invoke for internal code interfaces, which the code documents itself, or for configuration references, which belong in `config-reference.md` under the core Reference rule. Judging whether the contract is well designed is out of scope: this skill documents the contract that exists. ## One home versus generated specs When an OpenAPI or AsyncAPI spec exists, or the code generates one, that spec owns the field tables. The markdown then documents only what the spec cannot say (semantics, side effects, ordering, omitted-versus-null) and links the spec; never hand-maintain field tables beside a generated one; a second home drifts. The catalog below is for the case where no machine spec exists; writing one is not this document's job. ## The four detail levels Each level has its own home; the writer moves detail found at the wrong level into the level that owns it: | Level | The caller asks | Home | |---|---|---| | Index | What exists here | The endpoint, message, and command tables | | Semantics | What invoking it does | Per-endpoint, per-message, and per-command prose: side effects, events published, idempotency, redelivery, exit behavior, quirks | | Shape | What crosses the wire | The DTO catalog: one field table per DTO | | Example | What it looks like | At most one illustrative example per DTO | Repetition across levels is the defect to hunt: an endpoint section restating its DTO's fields, an example smuggling in a field the table lacks. ## The DTO catalog A DTO is defined once and referenced everywhere: - **Wire types, not language types.** `string (date, ISO 8601)`, `number (64-bit integer)`, `string (decimal)`: the column says what crosses the wire, complete enough that no reader needs the implementation's type as a proxy. A 64-bit integer that exceeds the range or precision of a consumer's native number type is wire information; the type name that produced it is not. - **One Source line per DTO**, naming the owning class or schema file. Reference kind sanctions this evidence anchor, as a config reference carries binding evidence. - **Required is a tri-state**: `yes`, `no`, or `if ` with the condition stated. - **Omitted versus null is stated wherever it matters**, and always on a DTO used in a replace-style write, where an omitted field is absent from the result. Where the server assumes a value on omission instead, that value goes in the Default column. - **Enums get their own table**, values with meanings; nested objects link to their own catalog entry, never a second inline copy. - **Constraints in domain terms**: "past date", "1..100 chars", "must reference an existing budget policy", read from validation the code enforces. ## The template ```markdown # API reference: ## Conventions [Once, never per endpoint: base path, auth, content type, the error envelope, global (de)serialization behavior, idempotency defaults.] ## Endpoints | Method | Path | Purpose | Request | Response | Errors | |---|---|---|---|---|---| | POST | `/thing` | Create a thing | [ThingRequest](#thingrequest) | 200 [Thing](#thing) | 422, 404 | ### POST /thing [Semantics only: side effects, events published, idempotency, quirks. No field lists; the index and catalog are not repeated.] ## Messages | Direction | Destination | Payload | Reply | On error | |---|---|---|---|---| | in | `thing.create` | [ThingRequest](#thingrequest) | `thing.created` | `thing.create.error` | ### thing.create [Semantics only: redelivery, ordering, events published, quirks; what differs from the sibling transport is called out here.] ## Commands | Command | Purpose | Arguments | Output | |---|---|---|---| ### [Semantics only: side effects, idempotency, exit behavior, quirks.] ## DTOs ### ThingRequest Source: `api/ThingRequest` | Field | Type | Required | Default | Constraints | Meaning | |---|---|---|---|---|---| [Omitted versus null, where it matters. At most one illustrative example.] ### Thing [Response shapes are catalog entries like any other.] ## Errors | Status | When | Body | |---|---|---| ``` ## Rules - **Verify against the serializer, not the class.** The wire is what the configured serializer emits and accepts: a global trimmer, a null-omitting mapper, or a custom date format changes the contract without touching any DTO. Read the serialization configuration before writing a single field row. - **Asymmetries are semantics.** The mutation that publishes an event on one transport and nothing on the other, or the endpoint that skips a step its siblings perform, is documented at the semantics level. - **Examples are illustrative, never normative.** One per DTO at most, labeled so, and containing no field the table lacks; the table is the contract. - **Errors are cataloged once**, as envelope plus a status table; an endpoint lists only which entries apply to it. Command failures are cataloged the same way, by exit code. - **The exhaustiveness is checkable.** The endpoint count and the DTO count are denominators like any other (core truth rules): a legacy campaign records them in its coverage ledger with the commands behind them and the date.

相关技能

文档办公

Ontology

为结构化的代理内存和可堆肥技能所打入的知识图. 在创建/征服实体(Person, project, Task, Evention, Document)时使用,链接相关对象,强制约束,规划多步动作作为图变,或技能需要共享状态时使用. 触发到"记住","我知道什么","链接X到Y",…

文档办公

Nano Pdf

使用纳米-pdf CLI编辑带有自然语言指令的PDF.

文档办公

Word / DOCX

创建,检查,并编辑有可靠样式的Microsoft Word文档和DOCX文件,编号,跟踪更改,表格,章节,并进行相容性检查. 当 (1) 任务涉及 Word 或 ".docx " 时使用; (2) 文件包括跟踪的更改,评论,字段,表格,模板,或页面布局限制; (3) 文档必须在不…

文档办公

Api Gateway

通过 Maton 网关调用第三方 API, 它为用户已经连接的应用程序注入证书 。 当用户命名一个连接的应用程序和其中的具体行动时使用此技能——读取一个邮箱,查询一个CMM,归档一个问题,更新一个电子表格,通过一个连接的搜索或刮取提供者运行一个查询. 每一次通话都到用户连接的应用…