laravel:transactions-and-consistency

SkillDev tools

Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the laravel:transactions-and-consistency skill

What this skill tells your AI

The instructions your AI receives, as published by jpcaparas/superpowers-laravel in skills/transactions-and-consistency/SKILL.md and read by ahel’s review.

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
  • Laravel 13+: upsert() throws InvalidArgumentException on an empty uniqueBy — always pass the real unique columns

Signals

GitHub stars
153
Forks
2
Last commit
Jul 2026
Advanced
Catalog kind
skill
Gateway key
laravel-transactions-and-consistency
Source
github.com/jpcaparas/superpowers-laravel