Email-driven coding agent: an engineer mails a bug or feature request to a Mailtrap Inbound address. The Claude Agent SDK implements the change on a target repository, opens a GitHub pull request, and replies in the same Mailtrap thread with the PR link. Follow-up mail in that thread (Mailtrap Threads) continues the loop.
- Inbound — custom domain webhook at
POST /webhook - Threads — follow-ups are keyed by Mailtrap
thread_idand resume the Claude session - Replies — in-thread response via the inbound reply API (not a new conversation)
- Email API — the reply is sent outbound; every agent message uses category
coding-agent(X-MT-Category)
- Mailtrap account with a verified sending domain and inbound custom domain (MX on that domain). See Inbound and receiving emails.
- Inbound webhook pointing at this server:
https://<your-host>/webhook(webhooks). - Anthropic API key
- GitHub Personal Access Token with
reposcope (create at GitHub → Settings → Developer settings → Personal access tokens). A GitHub App installation token works the same way if you set it asGITHUB_TOKEN. ghis not required on PATH; the Agent SDK uses git/ghvia its Bash tool ifghis installed. Install GitHub CLI so the agent can open PRs.
cp .env.example .env
# fill in the values below
npm install
npm startPoint the Mailtrap inbound webhook at POST /webhook on this host.
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY |
Claude API key |
MAILTRAP_API_TOKEN |
Mailtrap API token |
MAILTRAP_INBOX_ID |
Inbound inbox ID (used if the webhook payload omits it) |
DEFAULT_FROM_EMAIL |
Address on the inbound custom domain (required for replies) |
GITHUB_TOKEN |
PAT or GitHub App token |
TARGET_REPO |
owner/name of the repository to fix |
PORT |
HTTP port (default 3000) |
- Mail
dev@your-domainwith a bug report. - Webhook loads the message and thread, runs the Agent SDK (
Read/Edit/Bash/ tests) onTARGET_REPO. - Agent opens a GitHub PR and this server replies in-thread with the PR URL (category
coding-agent). - Reply in the same thread (e.g. “please also update the tests”). The agent resumes that thread’s session, pushes another commit, and replies again.
- Mailtrap API
- Mailtrap Inbound
- Inbound messages / replies
- Inbound threads
- Email categories (
X-MT-Category) - Claude Agent SDK
MIT — see LICENSE.txt.
