Transactions and consistency

From jpcaparas/superpowers-laravel · View interactive version

Transactions and consistency is an AI agent skill from the GitHub repository jpcaparas/superpowers-laravel. Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency

How to use this skill

Skill file

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 this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.