mcpField
L
laravel-transactions-and-consistency

laravel-transactions-and-consistency

github.com/noartemDevelopment1374 installsUpdated 2w ago
Repository

About laravel-transactions-and-consistency

A Laravel skill for keeping multi-step database writes consistent. It covers transaction boundaries, after-commit events and jobs, idempotent retries, and row-level locking.

Key features

  1. 01Wrap related writes in transactions
  2. 02Dispatch events and jobs after commit
  3. 03Make jobs safe to retry
  4. 04Coordinate writes with row locks
  5. 05Validate invariants before transactions

Use cases

  1. 01Update an order and its items atomically
  2. 02Delay invoice jobs until commit
  3. 03Prevent duplicate effects when retrying jobs

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/noartem/skills --skill laravel-transactions-and-consistency

After installing, type/laravel-transactions-and-consistencyin Claude Code to confirm it loaded.

Details

From the project README

Transactions and Consistency

Ensure multi-step changes are atomic; make retries safe.

Commands

DB::transaction(function () use ($order, $payload) {
    $order->update([...]);
    $order->items()->createMany($payload['items']);
    OrderUpdated::dispatch($order);        // or flag for after-commit
});

// Listener queued after commit
class SendInvoice implements ShouldQueue {
    public $afterCommit = true;
}

Patterns

  • Use DB::transaction to wrap write sequences and related side-effects
  • Prefer $afterCommit or dispatchAfterCommit() for events / jobs
  • Make jobs idempotent (check existing state, use unique constraints)
  • Use lockForUpdate() for row-level coordination when needed
  • Validate invariants at the boundary before starting the transaction

Comments

Markdown supported