Skip to content
Back to skills

Transactions And Consistency

ASecurity

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

  • 147 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added June 6, 2026
tools

Security analysis

A100/100

Scanned June 6, 2026

npx -y skills add jpcaparas/superpowers-laravel --skill transactions-and-consistency --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Transactions And Consistency?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Transactions And Consistency
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jpcaparas-transactions-and-consistency/badge)](https://www.skillsdirectory.com/skills/jpcaparas-transactions-and-consistency)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel:transactions-and-consistency
description: Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency
---

# 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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.