Agent skill
laravel-transactions-and-consistency
Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency
Install this agent skill to your Project
npx add-skill https://github.com/noartem/skills/tree/main/skills/laravel-transactions-and-consistency
SKILL.md
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
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
laravel-filesystem-uploads
Store and serve files via Storage; set visibility, generate URLs, and handle streaming safely
laravel-task-scheduling
Schedule tasks with safety; use withoutOverlapping, onOneServer, and visibility settings for reliable cron execution
laravel-dependencies-trim-packages
Remove unneeded Composer packages and assets to improve boot time, memory, and security surface
laravel-controller-tests
Write focused controller tests using HTTP assertions; keep heavy logic in Actions/Services and unit test them
laravel-strategy-pattern
Use the Strategy pattern to select behavior at runtime; bind multiple implementations to a shared interface
laravel-template-method-and-plugins
Stabilize workflows with Template Method or Strategy; extend by adding new classes instead of editing core logic
Didn't find tool you were looking for?