Logo Api Design First

Api Design First

Cộng đồng
peterbamuhigire
api-design-first

Dùng khi thiết kế API HTTP với OpenAPI, quản lý phiên bản, xác thực, giới hạn tốc độ, tính bất biến khi lặp lại yêu cầu, quy ước lỗi, yêu cầu về khả năng quan sát và lựa chọn cách truyền dữ liệu bằng REST, webhook, SSE hoặc WebSocket.

Add to TypingMind

Tổng quan

Nhà phát hànhpeterbamuhigire
Kho mãchwezi-dev-engine
Tên kỹ năngapi-design-first
Sao
29
Bản fork
6
Tệp đi kèm
24
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 24 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được peterbamuhigire công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Api Design First trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/peterbamuhigire/chwezi-dev-engine/tree/main/skills/architecture/api-design-first
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/peterbamuhigire/chwezi-dev-engine.git /tmp/chwezi-dev-engine
mkdir -p .claude/skills
cp -r /tmp/chwezi-dev-engine/skills/architecture/api-design-first .claude/skills/api-design-first
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Api Design First trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Api Design First ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Api Design First với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

API Design First

Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.

Design APIs as contracts before code. This skill produces the OpenAPI 3.1 contract and its companion auth / error / idempotency / observability artifacts that downstream frontend, mobile, SDK, security, and reliability skills depend on.

Use When

  • Designing a new HTTP API (REST or GraphQL decision open), or adding endpoints to an existing API.
  • Normalising an existing API against the house contract (envelope, error model, versioning, rate limits).
  • Producing the OpenAPI contract that SDK, frontend, mobile, contract-testing, and security skills will consume.
  • Choosing an auth method and writing the auth/role matrix for a new service.
  • Defining idempotency keys and observability notes handed to reliability-engineering and observability-monitoring.

Do Not Use When

  • The task is purely client-side consumption of a third-party API (load the relevant SDK or integration skill).
  • The task is full threat modelling — load vibe-security-skill; this skill only records the auth model.
  • GraphQL-specific hardening is needed — load graphql-patterns.

Required Inputs

  • Context map and critical-flow table from system-architecture-design.
  • Access-pattern list from database-design-engineering.
  • Consumers, trust boundaries, and latency budget for each endpoint.
  • Tenancy model (single-tenant, shared schema, schema-per-tenant) so tenant_id propagation can be proven.

Workflow

  • Read this SKILL.md, then load only the references needed for the task (for example openapi-workflow.md for a greenfield design; auth-and-security.md for an auth choice; rest-conventions.md for URL / status-code review).
  • Apply the six-step design workflow before writing any code.
  • Produce the OpenAPI contract in the template format from skill-composition-standards/references/openapi-contract.md.
  • Record the auth model, error model, idempotency map, and observability notes alongside the spec.
  • Run the implementation checklist before merging.

Quality Standards

  • Spec is the source of truth; code follows the spec, never the reverse.
  • Every endpoint has documented auth, error codes, rate limits, pagination where relevant, and observability notes.
  • Tenant scope is derived from the auth token, never from a request body or query string.
  • Breaking changes require a new major version; existing versions are frozen except for bug fixes.
  • British English, no emojis, language-tagged code fences.

Anti-Patterns

  • Writing code first and "generating" the spec afterwards — the spec loses its role as contract.
  • Accepting tenant_id from the request body — enables cross-tenant data leaks.
  • Returning 403 for wrong-tenant lookups — leaks existence; return 404.
  • Wildcard Access-Control-Allow-Origin: * with credentials — browsers ignore, auth breaks, security hole opens.
  • Storing API keys in plaintext — a database leak becomes an immediate credential leak.
  • Mutating an existing version's response schema — every client with hard-coded parsers breaks.

Outputs

  • OpenAPI 3.1 contract covering every endpoint, schema, error, rate-limit header, and example.
  • Auth model: selected method, role/scope matrix, token lifetime, revocation strategy.
  • Error model conforming to the standard envelope with documented error codes.
  • Idempotency map: which endpoints require Idempotency-Key, scope, TTL.
  • Observability notes: per-endpoint span names, SLO class, log fields, audit events.
  • Implementation checklist result.

Evidence Produced

CategoryArtifactFormatExample
CorrectnessOpenAPI contractMarkdown doc plus OpenAPI YAML covering paths, schemas, and error responsesdocs/api/openapi-checkout.yml
CorrectnessContract test resultsCI log or recorded report from API contract tests against the OpenAPI specdocs/api/contract-tests-2026-04-16.md

References

Prerequisites

Load these skills first:

  • system-architecture-design — produces the context map and critical-flow table consumed below.
  • database-design-engineering — produces the access-pattern list that shapes resource design.
  • world-class-engineering — the shared release gate this skill ships into.

Load alongside:

  • vibe-security-skill for threat modelling of the auth model produced here.
  • graphql-patterns whenever building or auditing a GraphQL API (it owns the GraphQL hardening guidance).

When this skill applies

  • A new service is being designed and needs its HTTP surface defined.
  • A feature adds endpoints to an existing API and must follow the house contract.
  • An existing API is being normalised for versioning, error envelope, or rate limits.
  • A partner integration requires a published OpenAPI contract.
  • Mobile or SDK work is blocked on a stable contract for code generation.

Inputs

ArtifactProduced byRequired?Why
Context mapsystem-architecture-designrequiredDefines service/module boundaries the API sits inside
Critical-flow tablesystem-architecture-designrequiredSupplies latency/availability targets for endpoints
Access-pattern listdatabase-design-engineeringrequiredRead/write shapes drive resource model and pagination choices
Failure-mode listsystem-architecture-designoptionalInforms degradation behaviour on dependency outages
Threat modelvibe-security-skilloptionalInforms auth, rate-limit, and abuse-case rules
Tenancy modeldatabase-design-engineeringrequiredProves tenant isolation at the API boundary

Outputs

ArtifactConsumed byTemplate
OpenAPI 3.1 contractfrontend, mobile, SDK, advanced-testing-strategy (contract tests)skill-composition-standards/references/openapi-contract.md
Error modelfrontend, mobile, advanced-testing-strategyskill-composition-standards/references/error-model.md
Auth modelvibe-security-skill, mobile-rbac, ios-rbacinline in spec (components.securitySchemes) + role/scope matrix in auth-and-security.md
Idempotency mapreliability-engineering, stripe-paymentsinline table — see references/auth-and-security.md
Observability notesobservability-monitoringinline table — see references/implementation-checklist.md

Non-negotiables

  • OpenAPI spec is written before a single endpoint is implemented.
  • Tenant scope comes from the auth token, never from the request body or query string.
  • Every response carries the mandatory security headers from auth-and-security.md.
  • Every POST that causes an external side effect (payment, email, webhook, inventory movement) requires an Idempotency-Key.
  • Every new endpoint is added to the observability notes table before merge.
  • Breaking changes never mutate an existing version; they ship as a new major version.

Decision rules

Auth-method selection

Caller shapeChooseFailure mode if wrong
Server-to-server, trusted partner, long-livedAPI Key (SHA-256 hashed)JWT: can't be revoked fast; raw-key storage: leak = instant compromise
Web app with user consent, third-party accessedOAuth2 Authorization CodeImplicit flow: token leaks via URL history; ROPC: phishing vector
Service-to-service with scopes, standards-compliantOAuth2 Client CredentialsAPI key: no standardised scopes or introspection
First-party mobile app / SPAJWT access + refresh (short)Long-lived JWT: revocation impossible; session cookie: breaks on iOS
Legacy / tightly-controlled client with no user flowOAuth2 ROPC (last resort)Credentials pass through the API surface — avoid when any alternative

Versioning action

ChangeActionFailure mode if wrong
Adding optional field, endpoint, or enum valueShip in current version, mark non-breakingSpawning a new version for a safe change: client churn
Removing or renaming a fieldShip as new major version, sunset oldMutating existing version: silent parsing failures in clients
Changing response shape or required paramsShip as new major version, sunset oldAs above
Bug fix that narrows behaviour clients may depend onShip behind a header flag, deprecate quietlySilent fix: clients relying on the bug break in production

Idempotency requirement

Endpoint classRequire Idempotency-Key?TTLFailure mode if skipped
Payment, refund, chargeyes24 hDouble charges on retry
Order/invoice creationyes24 hDuplicate orders on network retry
Outbound email / webhook dispatchyes7 dDuplicate user-visible side effects
Inventory movementyes24 hPhantom stock changes
Read-only (GET, HEAD)non/an/a
Partial update without external effectoptional1 hBenign — but worth enabling on sensitive ops

Cache-Control choice

Resource shapeHeaderFailure mode if wrong
Public, rarely changes (prices)public, max-age=3600no-store: wastes bandwidth, slow clients
Per-user privateprivate, max-age=300public: leaks via shared CDN cache
Sensitive or mutable (auth, cart)no-storepublic: security incident

GraphQL vs REST

SituationChoose
Multiple clients with diverging field needsGraphQL
Public API, webhooks, file uploadsREST
Simple CRUDREST
Real-time subscriptionsGraphQL subscriptions

Failure mode if wrong: GraphQL-first for simple CRUD buys query-complexity DoS risk with no field-flexibility payoff; REST-first for multi-client heavy-reads pushes clients into over-fetch and N+1 round trips.

This table is the REST/GraphQL shortcut only. For real-time, service-to-service, event, or callback interactions (SSE, WebSocket, gRPC, webhooks, broker messaging), decide per interaction with references/api-style-selection.md; one-way live updates rarely need GraphQL subscriptions or WebSocket.

Design workflow (six steps)

  1. Define consumers, latency expectations, and trust boundaries.
  2. Write the API action plan, then model resources and actions around business concepts, not controller names.
  3. Write the OpenAPI contract, including auth, validation, errors, and pagination.
  4. Prove tenancy, authorisation, and idempotency rules before implementation.
  5. Design observability: request IDs, audit events, deprecation path, rate-limit telemetry.
  6. Validate that the API can evolve without breaking current consumers.

Full spec skeleton and per-step detail in references/openapi-workflow.md. For partner, public, long-lived, or workflow-heavy APIs, also load references/practical-api-architecture.md. For consumer ergonomics, endpoint naming, pagination, embedding, versioning, and test expectations, load references/api-you-wont-hate-rules.md.

Response envelope

The canonical envelope produced by this skill — every downstream client depends on it:

json
{
  "success": true,
  "data": { "id": 123 },
  "meta": { "page": 1, "per_page": 25, "total": 142 }
}
json
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The amount field is required.",
    "documentation_url": "https://api.example.com/errors#VALIDATION_ERROR",
    "fields": { "amount": ["Required"] }
  }
}

Detail, status-code mapping, and pagination mechanics live in references/rest-conventions.md.

Anti-patterns

  • Spec-after-code. The team writes endpoints and exports the OpenAPI spec from code annotations. Fix: draft the spec in a PR first, get sign-off from at least one consumer, then implement.
  • Tenant from body. POST /api/v1/invoices { "franchise_id": 42, "amount": 100 }. Fix: derive franchise_id from the authenticated token server-side; ignore any tenant field on the wire.
  • 403 on wrong-tenant. GET /api/v1/invoices/999 returns 403 Forbidden when invoice 999 belongs to another tenant. Fix: return 404 Not Found — 403 leaks that the resource exists.
  • Wildcard CORS with credentials. Access-Control-Allow-Origin: * plus Access-Control-Allow-Credentials: true. Fix: echo only origins from an allow-list; set credentials true only for those origins.
  • Raw API key storage. INSERT INTO api_keys (key) VALUES ('sk_live_abc123'). Fix: store key_hash = SHA-256(key), return the raw key once on creation, never again.
  • Unversioned breaking change. The team removes a field from GET /api/v1/invoices/{id} because nobody "should" be using it. Fix: ship as v2, keep v1 unchanged, emit Deprecation + Sunset headers on v1.
  • No idempotency on payments. POST /api/v1/payments charges the card. Network retry charges it again. Fix: require Idempotency-Key header, store (tenant, user, key) -> response for 24 h, replay the stored response on duplicate.
  • Unbounded page size. GET /api/v1/invoices?per_page=100000. Fix: clamp per_page to a hard maximum (e.g. 100) server-side.

Read next

  • skill-composition-standards — normalisation standard this skill was rewritten against; templates for the OpenAPI contract and error model live there.
  • observability-monitoring — consumes the observability notes table to build SLOs, alerts, and runbooks.
  • reliability-engineering — consumes the idempotency map for retry and circuit-breaker design.
  • deployment-release-engineering — consumes the versioning plan for migration choreography and rollback windows.
  • vibe-security-skill — consumes the auth model to build the threat model and abuse-case list.

References

Capability contract

Default to contract design and validation. Write specifications or generate clients only when authorised; do not deploy gateways, rotate credentials, or change production routes without approval.

Degraded mode

If consumers, traffic evidence, or the current contract are unavailable, produce a read-only draft with assumptions and unresolved compatibility risks; do not claim implementation readiness.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Api Design First làm được gì?

Dùng khi thiết kế API HTTP với OpenAPI, quản lý phiên bản, xác thực, giới hạn tốc độ, tính bất biến khi lặp lại yêu cầu, quy ước lỗi, yêu cầu về khả năng quan sát và lựa chọn cách truyền dữ liệu bằng REST, webhook, SSE hoặc WebSocket.

Vì sao nên dùng Api Design First trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Api Design First là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Api Design First trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/peterbamuhigire/chwezi-dev-engine/tree/main/skills/architecture/api-design-first. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Api Design First?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Api Design First với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Api Design First với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Api Design First có miễn phí không?

Có. Kỹ năng này được peterbamuhigire phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇