Agentmail To Claude Code banner
mvanhorn mvanhorn

Agentmail To Claude Code

Communication community

Description

Email gateway that opens a Claude Code session per inbound AgentMail message (cmux or Ghostty)

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

agentmail-to-claude-code

Email gateway for [Claude Code](https://claude.com/claude-code). Subscribe an [AgentMail](https://agentmail.to) inbox over WebSocket, or poll a [Primitive](https://primitive.dev) inbox over REST; on every authenticated, allowlisted message the daemon opens a fresh Claude Code session in your terminal, writes the email to a prompt file, and tells Claude to read and act on it.

Send an email to the watched inbox and Claude Code starts working on whatever's in the subject and body, with any attachments available to it by path.

The point: because the trigger is just an email, you can put Claude Code to work on your own computer from anywhere. I've wired it to a `cc` command in my agent Hermes, so from my phone I run `cc ` and it lands as a working session on my Mac, no VPN or SSH into the machine. See [How I use it with Hermes](#how-i-use-it-with-hermes).

It drives either terminal:

  • cmux (cmux.com) via its Unix-socket control plane, or
  • standalone Ghostty (ghostty.org) via AppleScript.

Pick one with `CC_TERMINAL` in your env.

How it works

  1. cc-daemon.py connects to the selected provider:
    • CC_MAIL_PROVIDER=agentmail subscribes to AgentMail's WebSocket for AGENTMAIL_INBOX.
    • CC_MAIL_PROVIDER=primitive polls Primitive for PRIMITIVE_INBOX.
  2. On each incoming message, the handler drops anything whose sender isn't in CC_ALLOWED_FROM or that failed DKIM/SPF.
  3. Attachments are downloaded under CC_HOME/attachments//. Per-attachment failures log a warning and continue.
  4. A prompt is built from From:, Subject:, the body, and a footer listing every downloaded attachment by absolute path. It's written to CC_HOME/prompts/.md.
  5. The selected backend opens a new Claude Code session and sends a single-line pointer telling Claude to read and act on the prompt file:
    • cmux: surface.create (auto-launches Claude Code via the Ghostty