Skip to content
You're viewing documentation for v0.6.2. It may be out of date.Go to latest
Email SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Agent skill

Install the Email SDK skill for coding agents and expose a send_email tool with createEmailAgentTools.

Two ways to put Email SDK in front of an agent: a skill that teaches coding agents (Claude Code and compatible tools) how to integrate the SDK correctly, and a tool factory that lets a runtime agent send email through your configured client.

The email-sdk skill

The repo ships a skill at skills/email-sdk/SKILL.md. Install it with the skills CLI:

Or copy the skills/email-sdk/ directory into your repo’s skills directory (.claude/skills/email-sdk/ for Claude Code). Agents pick it up whenever they add, review, or document an Email SDK integration.

What it enforces

  • Refresh docs first. The skill is deliberately dynamic: before writing code, the agent reads the installed package’s README, package.json exports, and TypeScript declarations — so it implements against the version actually installed, not stale training data.
  • Correct imports and secrets. Adapters come from their own entry points (@opencoredev/email-sdk/resend, /smtp, …), credentials stay in environment variables, and no Nodemailer — the SDK includes its own SMTP transport.
  • Compatible fallbacks. Fallback routes only when the backup adapter supports the same fields, checked against field support. Idempotency keys on externally visible sends that may retry.
  • CLI smoke tests. email-sdk doctor and send --dry-run before any live send, and no real external mail without your approval.
  • Secret-safe observability. Hooks and the observability plugin for redacted events — never API keys, message bodies, or unnecessary recipient data in logs.
  • Narrow validation. The smallest test or typecheck that covers the send path before declaring the work done.

Prompt example

Agent tools: send email at runtime

createEmailAgentTools(client) from @opencoredev/email-sdk/agent-tools turns an email client into tool definitions an LLM agent can call:

It returns one tool, sendEmail, as a plain EmailAgentTool object:

PropType
name?string

Tool name the model calls.

Typestring
Default"send_email"
description?string

Instructs the model to ask for confirmation before sending user-visible or external email.

Typestring
parameters?Record<string, unknown>

JSON Schema for the input. Requires from, to, and subject; optional html, text, adapter, and provider.

TypeRecord<string, unknown>
execute?(input) => Promise<unknown>

Runs client.send with the input message. adapter / provider route the send to a specific registered adapter.

Type(input) => Promise<unknown>

Because the tool is plain data plus an execute function, it maps onto any agent framework’s tool format:

execute goes through the full client pipeline — validation, retries and fallbacks, plugins, hooks — so an agent send behaves exactly like any other send in your app.

Last updated on