Distributed Transactions logo

Distributed Transactions

Community
d-padmanabhan
distributed-transactions

Designs and reviews cross-service consistency using Transactional Outbox/Inbox, Saga orchestration, Saga choreography, compensating actions, idempotency, and eventual consistency. Use when the user mentions outbox, inbox, saga, orchestration, choreography, compensation, distributed transaction, dual write, CDC relay, duplicate delivery, or cross-service workflow consistency.

Overview

Publisherd-padmanabhan
Repositoryagent-engineering-handbook
Skill namedistributed-transactions
Stars
20
Forks
3
Bundled files
3
LicenseMIT
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.

  • 3 bundled files

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

  • Open source

    Published by d-padmanabhan on GitHub. Read the source before you install it.

Installation

Install the Distributed Transactions 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/d-padmanabhan/agent-engineering-handbook/tree/main/skills/distributed-transactions
  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/d-padmanabhan/agent-engineering-handbook.git /tmp/agent-engineering-handbook
mkdir -p .claude/skills
cp -r /tmp/agent-engineering-handbook/skills/distributed-transactions .claude/skills/distributed-transactions
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Distributed Transactions 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 Distributed Transactions 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 Distributed Transactions 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.

Distributed Transactions

Use this skill when one business operation spans services, databases, brokers, or external systems and cannot rely on one local ACID transaction.

Non-Negotiables

  • Prefer one local ACID transaction when the data can remain inside one ownership boundary.
  • Every design must preserve declared business invariants across success, retries, concurrency, partial failure, compensation, and recovery. Never imply that eventual consistency or a Saga provides global ACID semantics.
  • Never implement a database write followed by direct message publication as an unprotected dual write.
  • Assume messages can be delayed, duplicated, reordered, and redelivered.
  • Make externally visible commands and consumers idempotent at the business-effect boundary.
  • Acknowledging or committing a message is not proof that the business effect occurred exactly once.
  • Compensation is a new business action, not a database rollback. It can fail and may require human resolution.
  • Persist workflow state, deadlines, attempts, and decisions durably. Do not keep authoritative Saga state only in process memory.
  • Bound retries and timeouts; quarantine poison messages and expose reconciliation paths.

Choose the Simplest Correct Pattern

  1. One service and one database: use a local transaction.
  2. Publish an event after a local state change: use Transactional Outbox.
  3. Protect a consumer from duplicate business effects: use Inbox/deduplication, a domain idempotency key, or both.
  4. A short cross-service flow with clear central ownership and complex compensation: prefer Saga orchestration.
  5. A loosely coupled event reaction with few participants and no central workflow state: choreography may fit.
  6. Many ordered steps, long waits, approvals, deadlines, or operational intervention: use a durable workflow engine or explicit orchestrator.
  7. Strong global atomicity is genuinely mandatory: reconsider service/data boundaries before reaching for distributed locking or two-phase commit.

Design Workflow

Before proposing implementation, document:

  • business invariant and consistency boundary;
  • participating services and data owners;
  • commands, events, correlation ID, causation ID, aggregate ID, and idempotency keys;
  • state machine, terminal states, deadlines, retry policy, and concurrency policy;
  • compensation for each completed step and what cannot be compensated;
  • message ordering requirements and partition/routing key;
  • duplicate, stale, late, and out-of-order handling;
  • operator visibility, reconciliation query, replay policy, and manual-resolution path;
  • schema/version evolution and deployment compatibility;
  • retention and cleanup for Outbox, Inbox, workflow, and audit records.

Do not start with a framework or broker feature. Start with invariants and failure modes.

Transactional Outbox and Inbox

Write the domain change and Outbox row in the same local transaction. A separate relay publishes pending rows and marks publication progress without assuming publish-and-mark is atomic. Give each event a stable identifier and enough routing/version metadata for deterministic handling.

Consumers must make duplicate delivery harmless. Record processed message identity in the same local transaction as the business effect where possible. A transport-level dedupe window alone is insufficient for long-lived business guarantees.

Use the Outbox and Inbox reference (${HANDBOOK_ROOT}/skills/distributed-transactions/references/outbox-inbox.md) for schema, relay, CDC, polling, retention, and recovery details.

Saga Orchestration and Choreography

Prefer orchestration when

  • the workflow has many steps, branches, waits, or deadlines;
  • compensation order matters;
  • one team owns the end-to-end process;
  • operators need one authoritative workflow state;
  • participants should not know the full process.

Prefer choreography when

  • reactions are independently valuable and loosely coupled;
  • the participant graph is small and understandable;
  • no central component needs to decide the next step;
  • event contracts and ownership remain clear without circular dependencies.

Choreography is not “no orchestration”; the emergent event graph becomes the workflow and must still be observable, versioned, bounded, and testable.

Use the Saga reference (${HANDBOOK_ROOT}/skills/distributed-transactions/references/saga-orchestration-choreography.md) for state, compensation, isolation anomalies, timeouts, and recovery.

Reliability Contract

  • Use stable operation and message identifiers generated before retries.
  • Distinguish retrying transport from retrying the business command.
  • Reject or ignore stale state transitions with an explicit version or expected-state check.
  • Serialize operations per aggregate when concurrent transitions would violate invariants.
  • Keep handlers deterministic around recorded input; isolate nondeterministic calls behind persisted results.
  • Use dead-letter handling only with ownership, alerts, replay safety, and a runbook.
  • Reconciliation compares authoritative business state to Outbox, Inbox, broker, and workflow state; it does not blindly replay everything.

Observability

Emit structured events and metrics for:

  • workflow state transitions and age;
  • relay backlog age and publish attempts;
  • duplicate and stale-message counts;
  • retry, timeout, compensation, and manual-resolution counts;
  • dead-letter depth and oldest-message age;
  • correlation and causation across every command and event.

Never log secrets or unrestricted payloads. Prefer identifiers, state, schema version, and redacted failure context.

Testing

Test failure boundaries, not only the happy path:

  • crash after domain commit but before publish;
  • publish succeeds but publication marking fails;
  • duplicate, delayed, stale, and out-of-order delivery;
  • consumer crash before and after local commit;
  • concurrent commands for the same aggregate;
  • timeout followed by a late success;
  • compensation failure and repeated compensation;
  • schema version skew during rolling deployment;
  • replay from dead-letter storage and reconciliation repair.

Use deterministic fault injection and verify durable state after each interruption.

Review Output

For a design or code review, report:

  1. Invariant and boundary
  2. Critical correctness risks
  3. Chosen pattern and why
  4. Message/workflow state contract
  5. Idempotency, ordering, timeout, and compensation behavior
  6. Recovery and reconciliation
  7. Tests and operational signals

Reject vague claims such as “Kafka guarantees exactly once” or “the Saga rolls everything back.” State the actual end-to-end guarantee and its limits.

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 Distributed Transactions AI skill do?

Designs and reviews cross-service consistency using Transactional Outbox/Inbox, Saga orchestration, Saga choreography, compensating actions, idempotency, and eventual consistency. Use when the user mentions outbox, inbox, saga, orchestration, choreography, compensation, distributed transaction, dual write, CDC relay, duplicate delivery, or cross-service workflow consistency.

Why use Distributed Transactions on TypingMind?

Because you install it once and use it with any model. Distributed Transactions 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 Distributed Transactions in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/d-padmanabhan/agent-engineering-handbook/tree/main/skills/distributed-transactions. 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 Distributed Transactions?

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 Distributed Transactions?

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

Is the Distributed Transactions AI skill free?

Yes. It is published on GitHub by d-padmanabhan under the MIT 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 👇