vibe.commerce-patternslisted
Install: claude install-skill su-record/vibe
# Commerce Patterns
## Pre-check (K1)
> Is this an e-commerce transaction flow? If building simple CRUD without payment/stock management, this skill is not needed.
## Gotchas & Traps
These are the non-obvious failure modes LLMs typically miss:
### Payment
| Trap | Consequence | Prevention |
|------|-------------|------------|
| No idempotency key | User double-clicks → charged twice | `idempotencyKey: order_${orderId}_${timestamp}` on every payment request |
| Webhook not idempotent | Retry delivers duplicate events | Check `eventId` before processing, store processed events |
| Missing webhook signature verification | Attacker forges payment confirmation | Always verify HMAC signature before processing |
| No payment state machine | Order stuck in limbo | `PENDING → PROCESSING → AUTHORIZED → CAPTURED → COMPLETED` (+ FAILED, CANCELED, REFUNDED) |
### Inventory
| Trap | Consequence | Prevention |
|------|-------------|------------|
| Non-atomic stock decrement | Race condition → negative stock | `UPDATE SET stock = stock - $1 WHERE stock >= $1` (atomic with check) |
| No reservation TTL | Stock locked forever on abandoned checkout | 15-min reservation + scheduled cleanup job |
| Commit without reservation | Stock sold twice | Two-phase: RESERVE (checkout start) → COMMIT (payment success) / RELEASE (failure) |
| Optimistic lock without retry | Fails silently under contention | Use `version` column or `FOR UPDATE` for high-contention products |
### Cart & Pricing
| Tra