Logo Api Distributed Design

Api Distributed Design

Cộng đồng
andrew0928
api-distributed-design

Design Andrew-style API and distributed-system contracts from domain lifecycle, message flow, and correctness guarantees. Use when Codex needs state-machine-driven API design, contract-first or API-first planning, service-to-service messaging, retry and idempotency design, queue or scheduler workflows, worker isolation choices, or measurable validation of ordering, latency, and duplicate-execution tradeoffs.

Tổng quan

Nhà phát hànhandrew0928
Kho mãandrew-skills
Tên kỹ năngapi-distributed-design
Sao
36
Bản fork
6
Tệp đi kèm
8
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 là Markdown thuần túy, không phải 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ộ.

  • 8 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 andrew0928 công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Api Distributed Design 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 thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/andrew0928/andrew-skills/tree/main/plugins/architect/skills/api-distributed-design
  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/andrew0928/andrew-skills.git /tmp/andrew-skills
mkdir -p .claude/skills
cp -r /tmp/andrew-skills/plugins/architect/skills/api-distributed-design .claude/skills/api-distributed-design
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 Distributed Design 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ự tải Api Distributed Design 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 Api Distributed Design không bị giới hạn ở mô hình mà kỹ năng này được viết cho. 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 kỹ năng chưa dùng không tốn chi phí.

  • Đổ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.

Andrew API Distributed Design

Overview

Use this skill when the design surface crosses service boundaries, transport boundaries, or failure boundaries.

Start from the domain lifecycle and the exposed value, then derive both synchronous API contracts and asynchronous message contracts from the same model. Treat retry, duplication, delay, reordering, shutdown, and scale-out as part of the architecture, not as post-implementation surprises.

Working Style

  • Write in Traditional Chinese when the user or repo context is Chinese.
  • Start from the domain object, lifecycle, and collaboration model before choosing endpoints, queues, or frameworks.
  • Treat the API as the exposed form of a domain service, not as a mirror of one current UI flow.
  • Keep one-way message, RPC message, HTTP API, and internal worker boundaries consistent with the same core model.
  • Make actor, target system, identity, correlation, and delivery semantics explicit.
  • Decide correctness boundaries up front: what must never happen twice, what may retry safely, and what may arrive late or out of order.
  • Prefer the smallest coordination mechanism that is strong enough for the guarantee you need.
  • Use storage-native atomic operations, transactions, or lock primitives before inventing your own coordination protocol.
  • Keep transport adapters thin; let contracts, lifecycle rules, and policies live in reusable core code.
  • Treat startup, shutdown, context propagation, observability, and autoscaling as first-class design concerns.

Workflow

1. Problem Analysis

  • Clarify why the contract exists and what value it exposes.
  • Identify the consumers and collaborators:
    • human-facing clients
    • internal services
    • workers
    • schedulers
    • partner systems
  • State the communication style required by the use case:
    • synchronous request/response
    • asynchronous one-way delivery
    • asynchronous RPC
    • scheduled execution
    • streaming or staged processing
  • List the real failure model:
    • timeout
    • duplicate delivery
    • reordered delivery
    • lost reply
    • worker crash
    • shutdown during processing
    • delayed or corrected data
  • Name the hard guarantee explicitly: exactly once, at least once, at most once, idempotent-safe retry, max delay, or bounded reordering.

2. Domain And Interaction Modeling

  • Identify the primary subject, entity, or service whose lifecycle is being exposed.
  • Model the domain using:
    • operation
    • state
    • actor
    • target system
    • event
  • Distinguish occurrence time, receive time, and process time when interpretation depends on the difference.
  • Separate core business state from ordinary properties or flags.
  • Model major collaboration edges explicitly:
    • caller to service
    • service to queue
    • queue to worker
    • worker to storage
    • worker to result or reply channel

3. Contract Surfaces

  • Translate the model into four surfaces:
    • entity
    • action
    • authorize
    • event
  • Derive request and response shapes from domain semantics, not from screens.
  • Keep the core API smaller than the full product surface when possible.
  • Define message contracts separately from HTTP shape when the same domain action may travel over multiple transports.
  • For message-driven RPC, define correlation, reply routing, and completion expectations explicitly.
  • Propagate request or track context across boundaries so cross-service diagnosis remains possible.
  • Keep message envelopes responsible for transport metadata and payloads responsible for domain meaning.

4. State Machine And Delivery Semantics

  • Model lifecycle-driven APIs with a state machine first.
  • Mark:
    • meaningful states
    • state-changing operations
    • read-only operations
    • allowed actors
    • follow-on events
  • Use the state machine as the shared map for endpoint naming, action naming, event naming, and authorization.
  • For every action or message, define delivery semantics explicitly:
    • may retry or not
    • idempotent by nature or requires a key
    • ordering scope
    • correlation id
    • dedupe key
    • ack point
  • Treat undefined combinations of current state and action as invalid by design.

5. Correctness And Coordination

  • Protect critical sections at the scope where contention actually exists.
  • Choose coordination based on scope:
    • local lock for one process
    • database transaction for one durable transactional boundary
    • storage-native atomic operation for simple distributed counters or swaps
    • distributed lock only when shared critical sections truly cross instances
  • Prefer atomic operations supplied by the platform or storage before composing them yourself.
  • Design APIs to be naturally idempotent when possible.
  • Use idempotency keys as an extra protection layer when natural idempotency is not enough.
  • Ensure transition validation and state change are atomic enough for the failure model you accept.
  • Distinguish:
    • safe retry
    • duplicate execution detection
    • duplicate execution tolerance
  • When late or corrected data is normal, define how prior results are revised and where replay enters the system.

6. Worker And Runtime Topology

  • Separate contracts, core implementation, and transport adapters.
  • Abstract message senders and workers so business handlers do not own queue plumbing.
  • Choose runtime isolation level deliberately:
    • in-process for lowest overhead
    • thread for concurrency without real isolation
    • process for stronger blast-radius control
    • container or infrastructure orchestration when the platform fit is good enough
  • Compare isolation choices by startup cost, execution cost, blast radius, tech-stack freedom, and operational fit.
  • Keep workers able to start, stop, drain, and shut down gracefully.
  • Design scaling so Ops can change instance count without needing custom per-release manual fixes.

7. Scenario Mapping

  • Start with one minimal happy path over the state machine.
  • Then walk at least these stress scenarios:
    • retry after timeout with unknown result
    • duplicate message arrival
    • out-of-order arrival
    • worker restart during processing
    • scheduler race between instances
    • scale-out plus shutdown
  • For each scenario, verify:
    • the transition exists
    • the actor is allowed
    • the delivery semantics are consistent
    • the result is sufficient for the next system
  • If the same story needs one model for API docs and another model for workers, the design is not yet coherent.

8. Metrics

  • Define metrics before tuning knobs such as worker count, polling frequency, lock lead time, or buffer size.
  • Pick metrics that match the architecture shape:
    • request latency
    • queue delay
    • throughput
    • retry count
    • duplicate-execution count
    • lock acquisition failure
    • early-lock count
    • delay exceed count
    • reorder buffer usage
    • drop or skip count
    • work in progress
    • time to first result
    • time to last completion
    • average lead time
    • delay standard deviation
    • DB cost score or polling cost
  • Mark which metrics are correctness gates and which are optimization targets.
  • Use theory limits when the architecture behaves like a pipeline or staged worker system.

9. POC And Simulation

  • Validate the architecture with the thinnest runnable model that can expose the guarantee and the tradeoff.
  • Prefer validating core behavior outside HTTP first.
  • Use mocks, in-memory repositories, or local queues when they preserve the design meaning.
  • Simulate failure modes deliberately:
    • retry
    • duplicate delivery
    • delayed reply
    • out-of-order events
    • shutdown during work
    • multiple instances racing for the same job
  • Use controllable time when delay windows, polling cadence, or scheduling precision matter.
  • Run the same model across different parameter sets instead of arguing from intuition.

10. Evaluation

  • Compare candidate designs against the chosen guarantee first, then secondary efficiency metrics.
  • Prefer designs whose failure behavior is explicit and explainable.
  • If one coordination mechanism is expensive, check whether the contract can be redesigned to need less coordination.
  • If the bottleneck is a stage, optimize the bottleneck or change the topology, not just the surrounding code.
  • If a custom mechanism only solves a narrow gap, keep the rest delegated to mature infrastructure.
  • Name the assumptions that would force a redesign later.

Design Checks

  • Revisit the API if endpoints mirror screens instead of the domain lifecycle.
  • Revisit the message design if correlation, ordering scope, or ack semantics are implicit.
  • Revisit the state model if flags or properties are inflating the FSM.
  • Revisit the correctness design if duplicate handling is described only as "the caller should avoid retry."
  • Revisit the coordination design if you introduced distributed locks before checking storage-native atomic options.
  • Revisit the worker model if graceful shutdown is impossible without manual cleanup.
  • Revisit the topology if isolation requirements and runtime choice do not match.
  • Revisit the scheduler or queue design if multiple instances can still execute the same job without a clear defense.
  • Revisit the metrics if they cannot distinguish correctness failure from efficiency loss.
  • Revisit the POC if it proves only the happy path and hides the real failure model.

Default Output Shape

When the user asks for design, respond in this order unless they request another structure:

  1. Problem Analysis
  2. Domain And Interaction Modeling
  3. Contract Surfaces
  4. State Machine And Delivery Semantics
  5. Correctness And Coordination
  6. Worker And Runtime Topology
  7. Scenario Mapping
  8. Metrics
  9. POC
  10. Evaluation
  11. Risks And Refactor Triggers

Use these expectations for each section:

  • Problem Analysis: define the business value, consumers, failure model, and hard guarantee.
  • Domain And Interaction Modeling: define the primary subject, states, actors, target systems, and time semantics.
  • Contract Surfaces: define entities, actions, authorization shape, events, and transport metadata boundaries.
  • State Machine And Delivery Semantics: define legal transitions plus retry, ordering, dedupe, correlation, and ack behavior.
  • Correctness And Coordination: define critical sections, atomicity mechanisms, idempotency strategy, and replay behavior.
  • Worker And Runtime Topology: define layers, worker roles, scaling, isolation, and shutdown model.
  • Scenario Mapping: walk one happy path and at least one failure-heavy path.
  • Metrics: define correctness gates and optimization signals.
  • POC: propose the smallest runnable validation and the failure injections to run.
  • Evaluation: compare alternatives and state the architectural decision.
  • Risks And Refactor Triggers: name what would invalidate the current choice later.

References

  • Read references/api-first-strategy-principles.md when the task is about API-first or contract-first planning.
  • Read references/api-state-machine-principles.md when the task is about lifecycle-driven API design, actors, authorization, or scenario mapping.
  • Read references/distributed-correctness-principles.md when the task is about transactions, distributed locks, idempotency, retries, late data, or atomic operations.
  • Read references/messaging-and-operation-principles.md when the task is about message queues, RPC over messaging, context propagation, worker lifecycle, or design for operation.
  • Read references/pipeline-scheduling-principles.md when the task is about staged workers, scheduling, reordering, buffering, queue metrics, or theory-limit reasoning.
  • Read references/worker-isolation-principles.md when the task is about process pools, runtime isolation, or choosing between process and infrastructure orchestration.
  • Keep article-specific notes in references/.
  • Promote only stable cross-article guidance back into this SKILL.md.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

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

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

Design Andrew-style API and distributed-system contracts from domain lifecycle, message flow, and correctness guarantees. Use when Codex needs state-machine-driven API design, contract-first or API-first planning, service-to-service messaging, retry and idempotency design, queue or scheduler workflows, worker isolation choices, or measurable validation of ordering, latency, and duplicate-execution tradeoffs.

Vì sao nên dùng Api Distributed Design 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 Distributed Design 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 Distributed Design trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/andrew0928/andrew-skills/tree/main/plugins/architect/skills/api-distributed-design. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành 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 Distributed Design?

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.

Bạn có thể dùng Api Distributed Design 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 Distributed Design 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 Distributed Design có miễn phí không?

Kỹ năng này được andrew0928 phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. 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 cho mô hình các công cụ mới để gọi — mã đượ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à tiêu chí của đầu ra tốt. 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 👇