Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add noartem/skills --skill "laravel-transactions-and-consistency"
Install specific skill from multi-skill repository
# Description
Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency
# 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::transactionto wrap write sequences and related side-effects - Prefer
$afterCommitordispatchAfterCommit()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
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.