Skip to content

Add CLI for sending emails and listing templates#1

Merged
jalexw merged 3 commits into
mainfrom
claude/create-email-cli-tool-QE8ts
Apr 13, 2026
Merged

Add CLI for sending emails and listing templates#1
jalexw merged 3 commits into
mainfrom
claude/create-email-cli-tool-QE8ts

Conversation

@jalexw

@jalexw jalexw commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a command-line interface (CLI) to the @schemavaults/send-email package, enabling users to send emails and list templates directly from the shell without writing code. The CLI wraps the existing sendEmail(), sendEmailToMailingList(), and listEmailTemplates() helpers.

Key Changes

  • New CLI entry point (src/cli.ts): A comprehensive command-line tool with three subcommands:

    • send — Send an email to one or more individual recipients
    • send-to-mailing-list — Send an email to a mailing list
    • list-templates — List available email templates in JSON or table format
  • CLI features:

    • Global options for --api-key and --environment (applied to all subcommands)
    • Support for both template-based and raw text/HTML message bodies
    • File input options (--text-file, --html-file, --body-file) for large or complex content
    • JSON template props parsing with clear error messages
    • Proper error handling with non-zero exit codes on failure
    • Repeatable options for multi-recipient sends (e.g., --to alice@example.com --to bob@example.com)
  • Package configuration:

    • Added commander dependency for CLI argument parsing
    • Added bin entry in package.json to register schemavaults-send-email as an executable
    • Split build process into build:lib (TypeScript compilation) and build:cli (esbuild bundling with Node.js compatibility)
  • Documentation:

    • New skill file .claude/skills/send-one-off-email/SKILL.md documenting the one-off email sending workflow
    • Updated .claude/skills/send-email-to-mailing-list/SKILL.md to document the new CLI option and recommend it as the preferred path for ad-hoc sends
    • Updated .claude/skills/list-email-templates/SKILL.md to document the new CLI option for template discovery

Notable Implementation Details

  • The CLI uses commander for robust argument parsing and automatic --help generation
  • Message body construction is abstracted into buildMessage() to handle both template and raw text/HTML modes
  • File loading and JSON parsing include descriptive error messages for better UX
  • The CLI supports both inline arguments and JSON file input for maximum flexibility
  • Global options are properly inherited by subcommands via optsWithGlobals()
  • The build process uses esbuild to bundle the CLI with Node.js compatibility shims for ES modules

https://claude.ai/code/session_01FYgbBN91L6CpSeRksx8ks3

claude added 3 commits April 13, 2026 11:46
Wraps the existing sendEmail, sendEmailToMailingList, and listEmailTemplates
helpers in a Commander-based CLI, exposed via the new
'schemavaults-send-email' bin entry. The CLI is bundled with esbuild so it
runs cleanly under Node ESM (the SchemaVaults dependency chain currently
emits extension-less relative imports that only resolve under bun).

Also enables tsc-alias resolveFullPaths so the library's own dist emits
proper .js extensions on relative imports for Node ESM consumers.
- list-email-templates: add a CLI usage section (bunx schemavaults-send-email
  list-templates) and recommend it as the simplest path for one-off catalog
  discovery; keep the /tmp/ Bun script as a fallback for richer queries.

- send-email-to-mailing-list: add a CLI usage section covering text/html,
  template, mailing-list-override, file-based body, and --body-file flows;
  rework the Claude-Code-post-workflow-notification section to recommend the
  CLI as the primary path for simple end-of-task emails (one shell command,
  no scratch script) and keep the /tmp/ Bun script as a fallback for
  bodies too elaborate for shell quoting.

- send-one-off-email: new skill covering single-recipient and small-fanout
  sends -- a use case the existing skill set didn't address. The CLI's
  `send` subcommand makes this trivial; the helper is documented for
  application-code embedding.

Frontmatter descriptions updated so the skills' triggers reflect the CLI
as a first-class entry point.
@jalexw jalexw merged commit 85609e9 into main Apr 13, 2026
3 checks passed
@jalexw jalexw deleted the claude/create-email-cli-tool-QE8ts branch April 13, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants