# MassTransit Skills Runbook (Agent)

This file is for coding agents. Use it to choose focused MassTransit guidance, then verify the target application's MassTransit version and existing conventions.
Canonical documentation and source code take precedence if they conflict with a skill.

## Task-to-Skill Map

- [Consumer Foundation](consumer-foundation.md): create/update consumers and consumer definitions.
- [Saga State Machine Foundation](saga-state-machine-foundation.md): create/update saga state machines and saga persistence setup.
- [Routing Slip Activity Foundation](routing-slip-activity-foundation.md): create/update routing slip activities and compensation behavior.
- [Request Response Foundation](request-response-foundation.md): implement request client and response flows.
- [Test Harness Foundation](test-harness-foundation.md): write or fix MassTransit tests.
- [Outbox Foundation](outbox-foundation.md): select and configure in-memory, Consumer, or Bus Outbox behavior.
- [Endpoint Configuration Foundation](endpoint-configuration-foundation.md): tune endpoint naming, concurrency, retry, and topology.

## Agent Workflow

1. Select one primary skill based on the request.
2. Apply the relevant guidance, preserving the application's existing patterns where they are intentional.
3. Borrow only compatible patterns from secondary skills.
4. Validate with the `Verification` commands in the selected skill.
5. Confirm generated code aligns with linked concepts/configuration/guides references.

## Global Rules

- Prefer `record` message contracts for new application-owned contracts. Classes and interfaces are supported when interoperability or an existing contract requires them.
- Keep consumer/saga/activity behavior deterministic and explicit.
- Prefer configuration via registration/definitions over ad-hoc endpoint code.
- Keep transport assumptions explicit.

## Do

- Keep generated code minimal and production-safe.
- Preserve existing naming conventions and endpoint format.
- Add tests for success and failure/timeout/retry behavior.
- Verify correlation and idempotency for saga and outbox scenarios.

## Do Not

- Do not invent new architectural patterns when a skill already covers the case.
- Do not rely on exceptions for expected business outcomes in request/response flows.
- Do not publish events before durable updates when an outbox is required; choose the outbox type using the [selection guide](/concepts/outbox/#choose-an-outbox).
- Do not skip verification commands.

## Canonical Docs

- [Consumers (Concepts)](/concepts/consumers)
- [Configuration Overview](/configuration)
- [Saga State Machines Guide](/guides/saga-state-machines)
- [Routing Slips Guide](/guides/routing-slips)
