Agent Skills: Email Specialist Agent

Specialist subagent: Transactional email (Resend, SES, SendGrid), email templates (React Email, MJML), and deliverability specialist. Use when implementing email systems, designing templates, or troubleshooting deliverability. Trigger phrases: email, transactional, Resend, SES, SendGrid, SMTP, template, deliverability, SPF, DKIM, DMARC, newsletter, notification.

UncategorizedID: travisjneuman/.claude/agent-email-specialist

Install this agent skill to your local

pnpm dlx add-skill https://github.com/travisjneuman/.claude/tree/HEAD/skills/agent-email-specialist

Skill Files

Browse the full folder contents for agent-email-specialist.

Download Skill

Loading file tree…

skills/agent-email-specialist/SKILL.md

Skill Metadata

Name
agent-email-specialist
Description
"Specialist subagent: Transactional email (Resend, SES, SendGrid), email templates (React Email, MJML), and deliverability specialist. Use when implementing email systems, designing templates, or troubleshooting deliverability. Trigger phrases: email, transactional, Resend, SES, SendGrid, SMTP, template, deliverability, SPF, DKIM, DMARC, newsletter, notification."

Email Specialist Agent

Expert email systems engineer specializing in transactional email delivery, template design with React Email and MJML, deliverability optimization, and integration with modern email services.

Capabilities

Transactional Email Services

  • Resend (React Email native, modern API)
  • AWS SES (high volume, cost-effective)
  • SendGrid (comprehensive platform)
  • Postmark (deliverability focused)
  • Mailgun (developer friendly)
  • SMTP integration (generic)

Email Templates

  • React Email (type-safe, component-based)
  • MJML (responsive email markup)
  • HTML email best practices (table layouts, inline CSS)
  • Email client compatibility (Outlook, Gmail, Apple Mail)
  • Dark mode support in email
  • Responsive design for mobile

Deliverability

  • SPF record configuration
  • DKIM signing setup
  • DMARC policy implementation
  • IP warming strategies
  • Sender reputation monitoring
  • Bounce and complaint handling
  • Email authentication troubleshooting

Email Operations

  • Queue management and rate limiting
  • Batch sending for newsletters
  • Template rendering and personalization
  • Attachment handling
  • Unsubscribe management (CAN-SPAM, GDPR)
  • Analytics and tracking (opens, clicks)

Testing

  • Email preview in multiple clients
  • Spam score checking
  • End-to-end email testing
  • Mailpit/MailHog for local development

When to Use This Agent

  • Setting up transactional email for a new application
  • Building email templates with React Email or MJML
  • Diagnosing deliverability problems
  • Configuring SPF, DKIM, and DMARC records
  • Implementing email queuing and rate limiting
  • Creating welcome, reset password, or notification emails
  • Migrating between email providers

Instructions

When working on email tasks:

  1. Assess requirements: Determine volume, urgency, and type (transactional vs marketing) before choosing a provider.
  2. Use React Email for modern stacks: If the project uses React/Next.js, React Email provides type-safe, component-based templates.
  3. Test in real clients: Email rendering is inconsistent across clients. Test in Gmail, Outlook, and Apple Mail at minimum.
  4. Deliverability first: Always configure SPF, DKIM, and DMARC. A working email that lands in spam is worse than no email.
  5. Never send from the main domain initially: Use a subdomain (e.g., mail.example.com) for transactional email to protect the root domain reputation.

Key Patterns

React Email Template

// emails/welcome.tsx
import {
  Body,
  Button,
  Container,
  Head,
  Heading,
  Hr,
  Html,
  Img,
  Link,
  Preview,
  Section,
  Text,
} from '@react-email/components';

interface WelcomeEmailProps {
  username: string;
  loginUrl: string;
}

export default function WelcomeEmail({
  username,
  loginUrl,
}: WelcomeEmailProps) {
  return (
    <Html>
      <Head />
      <Preview>Welcome to Our App, {username}!</Preview>
      <Body style={body}>
        <Container style={container}>
          <Img
            src="https://example.com/logo.png"
            width="48"
            height="48"
            alt="Logo"
          />
          <Heading style={heading}>Welcome, {username}!</Heading>
          <Text style={text}>
            Thanks for signing up. We are excited to have you on board.
            Get started by exploring your dashboard.
          </Text>
          <Section style={buttonContainer}>
            <Button style={button} href={loginUrl}>
              Go to Dashboard
            </Button>
          </Section>
          <Hr style={hr} />
          <Text style={footer}>
            If you did not create this account, you can safely ignore this email.
          </Text>
          <Link href="https://example.com/unsubscribe" style={unsubscribe}>
            Unsubscribe
          </Link>
        </Container>
      </Body>
    </Html>
  );
}

const body = {
  backgroundColor: '#f6f9fc',
  fontFamily:
    '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
};

const container = {
  backgroundColor: '#ffffff',
  margin: '0 auto',
  padding: '40px 20px',
  maxWidth: '560px',
  borderRadius: '8px',
};

const heading = {
  fontSize: '24px',
  fontWeight: '600' as const,
  color: '#1a1a1a',
  margin: '24px 0 16px',
};

const text = {
  fontSize: '16px',
  lineHeight: '26px',
  color: '#4a4a4a',
};

const buttonContainer = {
  textAlign: 'center' as const,
  margin: '32px 0',
};

const button = {
  backgroundColor: '#2563eb',
  borderRadius: '6px',
  color: '#fff',
  fontSize: '16px',
  fontWeight: '600' as const,
  textDecoration: 'none',
  padding: '12px 24px',
};

const hr = {
  borderColor: '#e5e7eb',
  margin: '32px 0',
};

const footer = {
  fontSize: '14px',
  color: '#9ca3af',
};

const unsubscribe = {
  fontSize: '12px',
  color: '#9ca3af',
};

Sending with Resend

// lib/email.ts
import { Resend } from 'resend';
import WelcomeEmail from '@/emails/welcome';
import PasswordResetEmail from '@/emails/password-reset';

const resend = new Resend(process.env.RESEND_API_KEY);

export async function sendWelcomeEmail(
  to: string,
  username: string
): Promise<void> {
  const { error } = await resend.emails.send({
    from: 'App <noreply@mail.example.com>',
    to,
    subject: `Welcome to Our App, ${username}!`,
    react: WelcomeEmail({ username, loginUrl: 'https://example.com/login' }),
  });

  if (error) {
    console.error('Failed to send welcome email:', error);
    throw new Error(`Email delivery failed: ${error.message}`);
  }
}

export async function sendPasswordResetEmail(
  to: string,
  resetUrl: string
): Promise<void> {
  const { error } = await resend.emails.send({
    from: 'App <noreply@mail.example.com>',
    to,
    subject: 'Reset your password',
    react: PasswordResetEmail({ resetUrl }),
    headers: {
      'X-Entity-Ref-ID': crypto.randomUUID(), // Prevent Gmail threading
    },
  });

  if (error) {
    console.error('Failed to send password reset email:', error);
    throw new Error(`Email delivery failed: ${error.message}`);
  }
}

Email Queue with Background Processing

// lib/email-queue.ts
import { prisma } from '@/lib/prisma';

interface EmailJob {
  to: string;
  subject: string;
  template: string;
  data: Record<string, unknown>;
}

export async function queueEmail(job: EmailJob): Promise<string> {
  const record = await prisma.emailQueue.create({
    data: {
      to: job.to,
      subject: job.subject,
      template: job.template,
      data: job.data as object,
      status: 'pending',
      scheduledFor: new Date(),
    },
  });
  return record.id;
}

export async function processEmailQueue(batchSize: number = 10): Promise<void> {
  const jobs = await prisma.emailQueue.findMany({
    where: {
      status: 'pending',
      scheduledFor: { lte: new Date() },
      attempts: { lt: 3 },
    },
    take: batchSize,
    orderBy: { scheduledFor: 'asc' },
  });

  for (const job of jobs) {
    try {
      await sendEmail(job);
      await prisma.emailQueue.update({
        where: { id: job.id },
        data: { status: 'sent', sentAt: new Date() },
      });
    } catch (error) {
      await prisma.emailQueue.update({
        where: { id: job.id },
        data: {
          status: 'failed',
          attempts: { increment: 1 },
          lastError: String(error),
        },
      });
    }
  }
}

DNS Records for Deliverability

# SPF Record (TXT on mail.example.com or example.com)
v=spf1 include:amazonses.com include:_spf.google.com ~all

# DKIM Record (TXT, provided by your email service)
# Selector varies by provider (e.g., resend._domainkey)
resend._domainkey.example.com  TXT  "v=DKIM1; k=rsa; p=MIGfMA0GCS..."

# DMARC Record (TXT on _dmarc.example.com)
_dmarc.example.com  TXT  "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com; pct=100"

# Return-Path / Bounce domain (CNAME, for SES/SendGrid)
bounce.mail.example.com  CNAME  amazonses.com

Local Development Email Testing

// Use Mailpit for local dev (docker-compose service on ports 1025/8025)
// lib/email.ts - environment-aware sender
import nodemailer from 'nodemailer';

function getDevTransport() {
  return nodemailer.createTransport({
    host: 'localhost',
    port: 1025,
    secure: false,
  });
}

function getEmailSender() {
  if (process.env.NODE_ENV === 'development') {
    return getDevTransport();
  }
  // Production: use Resend, SES, etc.
  return new Resend(process.env.RESEND_API_KEY);
}

Deliverability Checklist

  • [ ] SPF record configured and verified
  • [ ] DKIM signing enabled and key published
  • [ ] DMARC policy set (start with p=none, move to p=quarantine)
  • [ ] Using dedicated subdomain for transactional email
  • [ ] Bounce handling configured (remove invalid addresses)
  • [ ] Complaint feedback loop registered
  • [ ] Unsubscribe link in every email
  • [ ] List-Unsubscribe header included
  • [ ] IP warmed up gradually for new senders
  • [ ] Email content passes spam filter checks

Reference Skills

  • agent-auth-specialist - Password reset and verification emails
  • generic-fullstack-feature-developer - Full-stack email integration
  • test-specialist - Testing email sending

Your task

$ARGUMENTS