Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement Customer.io enterprise reference architecture. Use when designing integration layers, event-driven architectures, or enterprise-grade Customer.io setups. Trigger: "customer.io architecture", "customer.io design", "customer.io enterprise", "customer.io integration pattern".
.claude/skills/jeremylongshore-customerio-reference-architecture/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 158% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 119% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 90% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 99% | 0% |
Enterprise-grade reference architecture for Customer.io: a service layer separating Track and App API concerns, event-driven processing with message queues, repository pattern for user-to-CIO sync, webhook event bus, and infrastructure as code.
TrackClient for behavioral data in, APIClient for messages out┌─────────────┐ ┌───────────────────┐ ┌──────────────┐
│ Application │───>│ MessagingService │───>│ Track API │
│ Routes │ │ (service layer) │ │ identify() │
└─────────────┘ │ │ │ track() │
│ - identify users │ └──────────────┘
│ - track events │
│ - send txn emails │ ┌──────────────┐
│ │───>│ App API │
└───────────────────┘ │ sendEmail() │
│ │ broadcast() │
│ └──────────────┘
v
┌───────────────────┐
│ Event Queue │ ┌──────────────┐
│ (Redis/Kafka) │───>│ DLQ │
│ for reliability │ │ (failures) │
└───────────────────┘ └──────────────┘
┌─────────────┐ ┌───────────────────┐ ┌──────────────┐
│ Customer.io │───>│ Webhook Handler │───>│ BigQuery │
│ Webhooks │ │ HMAC verification │ │ (analytics) │
└─────────────┘ │ Event routing │ └──────────────┘typescript// services/messaging-service.ts import { EventEmitter } from "events"; import { TrackClient, APIClient, SendEmailRequest, RegionUS, RegionEU } from "customerio-node"; interface MessagingConfig { siteId: string; trackApiKey: string; appApiKey: string; region: "us" | "eu"; } export class MessagingService extends EventEmitter { private track: TrackClient; private app: APIClient; constructor(config: MessagingConfig) { super(); const region = config.region === "eu" ? RegionEU : RegionUS; this.track = new TrackClient(config.siteId, config.trackApiKey, { region }); this.app = new APIClient(config.appApiKey, { region }); } async identifyUser(userId: string, attrs: Record<string, any>): Promise<void> { const start = Date.now(); try { await this.track.identify(userId, { ...attrs, last_seen_at: Math.floor(Date.now() / 1000), }); this.emit("identify", { userId, latencyMs: Date.now() - start }); } catch (err) { this.emit("error", { operation: "identify", userId, err }); throw err; } } async trackEvent( userId: string, name: string, data?: Record<string, any> ): Promise<void> { const start = Date.now(); try { await this.track.track(userId, { name, data }); this.emit("track", { userId, name, latencyMs: Date.now() - start }); } catch (err) { this.emit("error", { operation: "track", userId, name, err }); throw err; } } async sendTransactional( to: string, templateId: string, data: Record<string, any>, identifiers?: { id?: string; email?: string } ): Promise<{ delivery_id: string }> { const start = Date.now(); try { const request = new SendEmailRequest({ to, transactional_message_id: templateId, message_data: data, identifiers, }); const result = await this.app.sendEmail(request); this.emit("transactional", { to, templateId, latencyMs: Date.now() - start }); return result; } catch (err) { this.emit("error", { operation: "transactional", to, templateId, err }); throw err; } } async triggerBroadcast( broadcastId: number, data: Record<string, any>, options: { segment?: { id: number }; emails?: string[]; ids?: string[] } ): Promise<void> { await this.app.triggerBroadcast(broadcastId, data, options); this.emit("broadcast", { broadcastId }); } async suppressUser(userId: string): Promise<void> { await this.track.suppress(userId); } async deleteUser(userId: string): Promise<void> { await this.track.destroy(userId); } }
typescript// services/messaging-queue.ts // Wraps MessagingService with queue-based reliability import { Queue, Worker, Job } from "bullmq"; import { MessagingService } from "./messaging-service"; const REDIS_URL = process.env.REDIS_URL ?? "redis://localhost:6379"; const identifyQueue = new Queue("cio:identify", { connection: { url: REDIS_URL } }); const trackQueue = new Queue("cio:track", { connection: { url: REDIS_URL } }); const transactionalQueue = new Queue("cio:transactional", { connection: { url: REDIS_URL }, }); export class QueuedMessagingService { constructor(private messaging: MessagingService) {} async enqueueIdentify( userId: string, attrs: Record<string, any> ): Promise<void> { await identifyQueue.add("identify", { userId, attrs }, { attempts: 3, backoff: { type: "exponential", delay: 2000 }, }); } async enqueueTrack( userId: string, name: string, data?: Record<string, any> ): Promise<void> { await trackQueue.add("track", { userId, name, data }, { attempts: 3, backoff: { type: "exponential", delay: 2000 }, }); } startWorkers(): void { new Worker("cio:identify", async (job: Job) => { await this.messaging.identifyUser(job.data.userId, job.data.attrs); }, { connection: { url: REDIS_URL }, concurrency: 10 }); new Worker("cio:track", async (job: Job) => { await this.messaging.trackEvent( job.data.userId, job.data.name, job.data.data ); }, { connection: { url: REDIS_URL }, concurrency: 10 }); new Worker("cio:transactional", async (job: Job) => { await this.messaging.sendTransactional( job.data.to, job.data.templateId, job.data.data, job.data.identifiers ); }, { connection: { url: REDIS_URL }, concurrency: 5 }); } }
typescript// repositories/user-messaging-repo.ts // Syncs your user database with Customer.io profiles import { MessagingService } from "../services/messaging-service"; interface User { id: string; email: string; firstName: string; lastName: string; plan: string; createdAt: Date; preferences: { marketing: boolean; transactional: boolean }; } export class UserMessagingRepository { constructor(private messaging: MessagingService) {} async syncUser(user: User): Promise<void> { if (!user.preferences.transactional && !user.preferences.marketing) { // User has opted out of all messaging — suppress await this.messaging.suppressUser(user.id); return; } await this.messaging.identifyUser(user.id, { email: user.email, first_name: user.firstName, last_name: user.lastName, plan: user.plan, created_at: Math.floor(user.createdAt.getTime() / 1000), marketing_opt_in: user.preferences.marketing, transactional_opt_in: user.preferences.transactional, }); } async onUserDeleted(userId: string): Promise<void> { await this.messaging.suppressUser(userId); await this.messaging.deleteUser(userId); } }
hcl# terraform/customerio.tf # Secrets resource "google_secret_manager_secret" "cio_site_id" { secret_id = "customerio-site-id" replication { auto {} } } resource "google_secret_manager_secret" "cio_track_key" { secret_id = "customerio-track-api-key" replication { auto {} } } resource "google_secret_manager_secret" "cio_app_key" { secret_id = "customerio-app-api-key" replication { auto {} } } # Cloud Run service resource "google_cloud_run_v2_service" "cio_service" { name = "customerio-service" location = "us-central1" template { scaling { min_instance_count = 1 max_instance_count = 10 } containers { image = "gcr.io/${var.project_id}/customerio-service:latest" env { name = "CUSTOMERIO_REGION" value = "us" } env { name = "CUSTOMERIO_SITE_ID" value_source { secret_key_ref { secret = google_secret_manager_secret.cio_site_id.secret_id version = "latest" } } } resources { limits = { cpu = "1", memory = "512Mi" } } } } }
| Issue | Solution | |-------|----------| | Queue worker failure | BullMQ retries with exponential backoff; check DLQ | | Service layer error | EventEmitter "error" event logged + alerted | | Secret rotation | Update Secret Manager version, redeploy | | Cross-service consistency | Use idempotent operations (identify is idempotent) |
After implementing architecture, proceed to customerio-multi-env-setup for multi-environment configuration.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | fail→fail | 19,283 | 10,652 | -45% | 1 | 1 | 0% | 3,221 | 4,915 | +53% | 0 | 0 | — |
case-07 | fail→pass | 7,977 | 6,313 | -21% | 1 | 1 | 0% | 1,506 | 3,886 | +158% | 0 | 0 | — |
case-08 | pass→pass | 6,772 | 4,820 | -29% | 1 | 1 | 0% | 1,230 | 3,638 | +196% | 0 | 0 | — |
case-05 | fail→pass | 11,955 | 10,512 | -12% | 1 | 1 | 0% | 2,221 | 4,865 | +119% | 0 | 0 | — |
case-01 | fail→fail | 16,621 | 14,587 | -12% | 1 | 1 | 0% | 3,786 | 6,421 | +70% | 0 | 0 | — |
case-02 | fail→fail | 21,167 | 19,237 | -9% | 1 | 1 | 0% | 4,856 | 7,093 | +46% | 0 | 0 | — |
case-03 | fail→fail | 18,901 | 16,787 | -11% | 1 | 1 | 0% | 4,060 | 6,449 | +59% | 0 | 0 | — |
case-04 | pass→pass | 15,425 | 12,663 | -18% | 1 | 1 | 0% | 3,146 | 5,510 | +75% | 0 | 0 | — |
case-09 | pass→pass | 11,637 | 8,298 | -29% | 1 | 1 | 0% | 2,625 | 4,623 | +76% | 0 | 0 | — |
case-10 | fail→fail | 16,098 | 14,689 | -9% | 1 | 1 | 0% | 3,298 | 5,894 | +79% | 0 | 0 | — |
case-11 | fail→pass | 9,709 | 4,576 | -53% | 1 | 1 | 0% | 1,897 | 3,661 | +93% | 0 | 0 | — |
case-12 | fail→pass | 17,433 | 14,589 | -16% | 1 | 1 | 0% | 2,992 | 5,673 | +90% | 0 | 0 | — |
case-13 | pass→pass | 15,933 | 13,602 | -15% | 1 | 1 | 0% | 2,518 | 4,966 | +97% | 0 | 0 | — |
case-14 | pass→pass | 15,466 | 12,226 | -21% | 1 | 1 | 0% | 3,415 | 5,273 | +54% | 0 | 0 | — |
case-15 | fail→fail | 13,414 | 15,528 | +16% | 1 | 1 | 0% | 2,335 | 5,821 | +149% | 0 | 0 | — |
case-16 | pass→pass | 13,708 | 11,817 | -14% | 1 | 1 | 0% | 2,791 | 5,118 | +83% | 0 | 0 | — |
case-17 | pass→pass | 12,478 | 12,589 | +1% | 1 | 1 | 0% | 2,569 | 5,413 | +111% | 0 | 0 | — |
case-18 | fail→pass | 13,245 | 9,417 | -29% | 1 | 1 | 0% | 2,269 | 4,506 | +99% | 0 | 0 | — |
case-19 | fail→fail | 13,447 | 14,929 | +11% | 1 | 1 | 0% | 2,459 | 5,560 | +126% | 0 | 0 | — |
case-20 | fail→fail | 16,254 | 13,129 | -19% | 1 | 1 | 0% | 3,261 | 5,436 | +67% | 0 | 0 | — |
case-21 | pass→pass | 9,814 | 6,979 | -29% | 1 | 1 | 0% | 2,243 | 4,232 | +89% | 0 | 0 | — |
case-22 | fail→pass | 10,970 | 4,343 | -60% | 1 | 1 | 0% | 1,999 | 3,598 | +80% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +27 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.