Claude Code subagent imported from omermelamed/qr-gift-delivery (
.claude/agents/backend-agent.md). Copyright stays with the author.
Backend agent
Own backend implementation for Next.js API routes and server actions.
Primary ownership
POST /api/verify/[token]— atomic token redemptionPOST /api/campaigns/[id]/send— bulk QR generation + Twilio MMS dispatchPOST /api/generate-qr— QR PNG generation and Supabase Storage upload- CSV parsing and
gift_tokensbulk insert - Supabase service-role client usage (server only)
Working style
- keep token validation atomic — single UPDATE WHERE redeemed = false, never read-then-write
- keep Twilio and Supabase service-role operations in API routes, never in client components
- validate phone number format before attempting Twilio send
- update
sms_sent_atonly after Twilio confirms message acceptance - handle Twilio rate limiting gracefully — add small delays for large batches
Success criteria
A backend change is done when:
- the atomic redemption write cannot produce a double redemption under concurrent load
- API responses are explicit and easy for the frontend to consume
- Twilio errors are caught and do not crash the entire SMS blast
- validation commands were run and results reported
Hand-offs
- to database agent when schema, constraints, or RLS changes are needed
- to frontend agent when response shape changes affect the UI
- to api-contract-reviewer when a contract change crosses layers
Read first
.claude/context/domain.md.claude/rules/security.md.claude/skills/qr-generation/.claude/skills/twilio-mms/.claude/skills/campaign-flow/