Api Contract Architecture logo

Api Contract Architecture

Organization
devcodex-labs
api-contract-architecture

API 契约架构专家 Owner — 当任务涉及 public API、HTTP/SDK/CLI 契约、版本兼容、错误模型、分页过滤、幂等、Schema、类型、迁移或消费者影响时使用;要求先冻结消费者契约,再设计实现与验证。

Overview

Publisherdevcodex-labs
Repositorydevcodex
Skill nameapi-contract-architecture
Stars
433
Forks
44
Bundled files
1
LicenseAGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by devcodex-labs on GitHub. Read the source before you install it.

Installation

Install the Api Contract Architecture AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/devcodex-labs/devcodex/tree/main/content/skills/api-contract-architecture
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/devcodex-labs/devcodex.git /tmp/devcodex
mkdir -p .claude/skills
cp -r /tmp/devcodex/content/skills/api-contract-architecture .claude/skills/api-contract-architecture
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Api Contract Architecture in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Api Contract Architecture on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Api Contract Architecture is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

API Contract Architecture Skill

定位

本 Skill 负责 API 契约 Owner 视角。它确保方案先回答“谁消费、契约是什么、如何兼容、如何验证”,再进入实现细节。

触发条件

场景是否触发
新增或调整 HTTP API、SDK API、CLI 参数、Hook payload、MCP tool/resource、事件、配置 Schema 或 public types必须
涉及版本兼容、迁移、错误码、分页、过滤、幂等、鉴权响应或消费者文档必须
修复会影响调用方行为或示例用法必须
纯内部实现且不改变任何公开输入/输出/错误/类型N/A + skipReason

核心门禁

Gate要求证据
ApiContractArchitectureGate公开契约必须有消费者、输入、输出、错误、兼容和验证矩阵consumerSurface、contractInventory
ConsumerSurfaceGate先列真实消费者,避免首个实现反向定义公共契约README、types、examples、route、SDK
ErrorModelGate错误结构、错误码、detail 和恢复路径必须稳定errorModel、docs
CliJsonContractGate机器可读 CLI 必须冻结 envelope 字段、成功/失败互斥、错误码、nextStep 与 native exit codeDevCodexCliEnvelopeV1、spawn fixtures
VersionCompatibilityGate兼容、弃用、迁移和 breaking change 必须明确versionCompatibility
ReleaseAuthorityBeforeCompatibilityGate先证明契约是否已发布并形成稳定消费者,再决定兼容、迁移或直接收敛publishedState、consumerEvidence、authoritySources、decision
ConfigurationErgonomicsGate公开配置 Schema 必须证明最小任务、字段必要性、复杂度预算和可选字段省略行为MinimalTaskConfig、FieldNecessityMatrix、OptionalFieldOmissionProbe
ContractVariantIsolationMutationGatediscriminated union/tool/event/state 合同必须拒绝 sibling variant 字段,并验证完成态必需证据不能被删除或反转ContractVariantIsolationMatrix、CompletionEvidenceDeletionMatrix
IdempotencyPaginationGate写操作、分页、过滤、排序和重试场景必须定义语义idempotencyPagination

执行步骤

  1. 列出所有消费者:前端、SDK、CLI、Hook、文档示例、测试、外部系统。
  2. 冻结现状契约:字段、类型、错误、版本、默认值、边界条件。
  3. 执行 ReleaseAuthorityBeforeCompatibilityGate:核对 tag/registry/release note/public docs/实际消费者;已发布才进入兼容评估,未发布且无稳定消费者默认直接收敛,未发布但存在产品取舍则交用户决策,事实不明时不得编造兼容义务。
  4. 定义目标契约与兼容策略:新增、保留、弃用、迁移、拒绝。
  5. 为错误模型、分页过滤、幂等和重试写稳定语义;CLI JSON 合同还要冻结 success/failure 字段互斥和 exit=0/1/2 映射。
  6. 若合同存在 discriminator 或条件完成态,执行 cross-variant 字段注入与完成证据删除/反转 mutation;Schema、semantic validator、docs field set 与 runtime 必须给出同一结论。
  7. 把契约映射到文档、示例、.http / .cjs、types、runtime probe。

输出字段

markdown
## ApiContractArchitectureGate

| 字段 | 内容 |
|------|------|
| consumerSurface | 消费者列表和调用入口 |
| contractInventory | 当前/目标输入、输出、错误、类型、配置 |
| versionCompatibility | 兼容、弃用、迁移、breaking change |
| releaseAuthority | publishedState、consumerEvidence、authoritySources 与兼容决策 |
| errorModel | 错误码、detail、恢复路径 |
| cliJsonContract | envelope、字段互斥、错误码、nextStep、exit map 与默认人读兼容 |
| idempotencyPagination | 幂等、分页、过滤、排序、重试语义 |
| sdkDocsImpact | SDK、README、examples、public types、文档影响 |
| evidenceMatrix | 判断 -> 代码 / 类型 / 文档 / 测试 / 运行时证据 |
| contractMutationMatrix | variant isolation、completion evidence deletion/reversal、schema/semantic/docs/runtime 结论 |

反模式

字段语义(contractInventory.fieldSemantics)

当公开输入、输出、配置、状态或嵌套对象含字段时,在原 contractInventory 中逐实际 fieldPath 记录 fieldSemantics,而不是另造契约 Owner。每项包含:fieldPath / consumer / purpose / requiredWhen / allowedValues / omittedMeaning / nullMeaning / emptyMeaning / zeroMeaning / falseMeaning / defaultSource / dependencies / conflicts / errorRecovery / compatibility / evidence。不适用的值写 N/A + reason,不得用空白掩盖未决定;无字段的任务整体 N/A 并说明理由,不强造产品字段。

必须分别说明省略、null、空字符串/数组/对象、0、false对当前消费者的含义,以及默认来自服务端、调用者还是推导。requiredWhen覆盖条件必填;依赖、互斥与错误恢复对应真实字段路径。相同语义可分组引用,但每个字段保留例外,不能用父对象一行代替子字段。类型、可选标记或一个成功示例只能证明结构,不能证明语义完整。未有产品决定的含义保持未决,不从实现反推承诺。

developer-experience-architecture引用同一记录审查字段必要性和首次使用路径;文档、示例、Schema与验证消费者交叉核对该记录,不复制另一套字段含义。

反模式修正
先写实现,再让消费者适配输出先冻结 contractInventory 和 consumerSurface
只写 happy path,没有错误模型补 errorModel 和失败恢复
首个 provider 字段反向定义公共 API区分业务契约与 provider payload
用单个示例证明兼容抽样 public types、README、tests 和 runtime
未发布候选也默认背负历史兼容层先做 ReleaseAuthorityBeforeCompatibilityGate;无稳定消费者时直接收敛 canonical contract
JSON 错误只写 message 或以 exit 0 返回冻结稳定 errorCode/nextStep,并用原生退出码区分合同错误与检查失败

与其他 Skill 的关系

  • developer-experience-architecture:API 示例、错误信息和迁移路径共同影响 DX。
  • backend-domain-architecture:领域不变量和权限策略必须映射到 API 契约。
  • test-router:API 变更触发 .http / .cjs、types、runtime 或 docs sync 验证。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Api Contract Architecture AI skill do?

API 契约架构专家 Owner — 当任务涉及 public API、HTTP/SDK/CLI 契约、版本兼容、错误模型、分页过滤、幂等、Schema、类型、迁移或消费者影响时使用;要求先冻结消费者契约,再设计实现与验证。

Why use Api Contract Architecture on TypingMind?

Because you install it once and use it with any model. Api Contract Architecture is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Api Contract Architecture in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/devcodex-labs/devcodex/tree/main/content/skills/api-contract-architecture. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Api Contract Architecture?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Api Contract Architecture?

As many as you like. As long as a model supports skills, you can use Api Contract Architecture with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Api Contract Architecture AI skill free?

Yes. It is published on GitHub by devcodex-labs under the AGPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇