guide ai-agents claude email-marketing

How To Automate Your Email Newsletter With Claude Code

14 min read

I built a Claude Code skill that drafts and publishes my weekly newsletter to Kit, so it actually gets done every week.

Part of the AI Agents and Claude topic hubs.

Hero image for How To Automate Your Email Newsletter With Claude Code
Table of Contents

I’ve been really erratic with my email marketing. I’ve got opt-in forms on every blog post and I’m collecting email subscribers.

But email marketing is operational work. I have to log into my email platform, Kit, and write a newsletter and… it just takes time.

More importantly, I’ve moved fully to an agentic way of working. I’ve set up personal AI agents that execute my strategies and vision. I don’t want to be logging into different apps and doing the grunt work.

This blog, for example, is mostly controlled by my AI agent. I give it the content, it handles the rest.

So at some point I thought, why am I still logging into Kit’s web dashboard to do email stuff manually? The agent knows what I just published. It knows the topic, the tags, the audience. It should handle the email side too.

So that’s what we’re going to do.

The Current State

If you’re new here, a quick bit of context. This website is custom-built with Astro and Tailwind, and I build and maintain the whole thing with Claude Code in my terminal.

So when I want to write a new blog post or create a new page, I work with Claude to write it. I have a process so that I’m not producing AI generated slop, but original ideas in my unique voice and style.

The agent polishes the content, creates the pages, posts, and components, manages the content index, handles deployments, and maintains internal linking. It even adds a newsletter opt-in to the blog post automatically based on the ones I’ve set up in Kit.

More importantly, my agent now has full context of every post on this site. Which means, it can go beyond just publishing content to my site. It can promote it too.

I’ve already set it up to promote content on social media. The only thing left is to promote it to my newsletter.

The Future State

There are two things I’d like to do when I create new content when it comes to the newsletter.

  1. I said that my agent automatically adds email opt-ins to each blog post. However, it’s only picking from opt-ins I’ve had to manually create in Kit. Ideally, it should generate a new opt-in that’s tailored to the blog post, and automatically set that up in Kit without me doing it manually.
  2. When I publish a post, it should summarize it and queue it up as a newsletter broadcast in Kit.

So basically I’d like to auto-create new forms, sequences, and broadcasts in Kit.

Exploring The Kit API

Before I could give my agent control over Kit, I needed to understand what the API supports because that’s how my agent will be interfacing with it.

The Kit API v4 is solid for some things and completely missing others. Here’s the breakdown:

CapabilityAPI SupportNotes
Broadcasts (newsletters)Full CRUDCreate, schedule, send, get stats. This is the strongest area.
SubscribersFull CRUDCreate, update, list, unsubscribe, bulk operations
TagsFull CRUDCreate, rename, delete, tag/untag subscribers
Custom fieldsFull CRUDCreate fields, set values on subscribers
WebhooksFull CRUDSubscribe to events like new subscriber, unsubscribe
FormsRead onlyList forms, get details, add subscribers. Cannot create forms.
Visual automationsNoneZero API support. UI only.
SequencesRead + subscribeCan add subscribers to existing sequences. Cannot create sequences.

The bad news first. You can’t create forms, automations, or sequences through the API, which means part 1 of my wishlist is off the table. This is something I hope Kit will fix in the future but for now it needs to be done manually via the dashboard.

That being said, the broadcasts are fully programmable. And that solves my second problem of writing the email newsletter after I publish a post.

Here’s what a basic API call looks like to create a broadcast:

curl -X POST https://api.kit.com/v4/broadcasts \
  -H "Content-Type: application/json" \
  -H "X-Kit-Api-Key: your_api_key_here" \
  -d '{
    "subject": "This Week: AI Agents and Email Marketing",
    "content": "<h1>Hey there!</h1><p>Here is what I published this week...</p>",
    "description": "Weekly newsletter - March 2026"
  }'

Don’t worry if you don’t understand what that means. What’s happening is that you just created a draft broadcast in Kit without opening a browser! The API returns the broadcast ID, which you can then use to update, schedule, or check stats.

Rate limits are reasonable too. With an API key you get 120 requests per 60 seconds. More than enough for an agent doing occasional email operations.

Giving Claude Code the API Key

First, you need a Kit API key. Go to your Kit dashboard, click Settings, then Developer, and generate a new v4 API key.

Store it in a .env file in your project root:

KIT_API_KEY="your_v4_api_key_here"

Make sure .env is in your .gitignore so you don’t accidentally commit your key. Most frameworks already have this in their default gitignore.

You can verify the key works by running a quick test:

source .env && curl -s https://api.kit.com/v4/account \
  -H "X-Kit-Api-Key: $KIT_API_KEY" | python3 -m json.tool

You should see your account name, email, and plan type come back. If you get an auth error, double check the key in your .env file.

At this point, you could just tell Claude Code “draft a new broadcast announcing this week’s post” in any session and it would read the .env file, figure out the API calls, and create the broadcast. It works. But you’d have to explain the context every time: what posts you published, what voice to use, what the API endpoints are.

Since this is something I do every week, I wanted to wrap it up in a reusable workflow. That’s where Claude Code skills come in.

Building the Newsletter Skill

If you haven’t used Claude Code skills before, they’re surprisingly simple. A skill is just a markdown file that lives in your project’s .claude/skills/ folder. It tells Claude Code how to handle a specific task. When you type /newsletter in your terminal, Claude reads the skill file and follows the instructions step by step.

Here’s the file structure:

.claude/
└── skills/
    └── newsletter/
        └── SKILL.md

And the skill file starts with a frontmatter block that tells Claude Code when to use it:

---
name: newsletter
description: Draft and create a weekly newsletter broadcast in Kit
  based on recent blog posts. Use when the user says "newsletter",
  "send newsletter", "create newsletter", or "weekly email".
---

The description field is important. It’s how Claude Code knows to pick up this skill when you mention anything related to newsletters. You want to include the different ways you might phrase the request.

After the frontmatter, the rest of the file is just instructions. I’ll walk through each section of my skill.

Step 1: Find recent posts

The first thing the skill does is figure out what I published recently. My site has a content index (a JSON file at .content/content-index.json that gets updated every time I publish a new post). It has every post’s title, description, publish date, tags, and an internal summary.

Here’s what I tell the skill to do with it:

### 1. Find recent posts

Read `.content/content-index.json` and filter for posts where:
- `pubDate` is within the last 7 days (compare against today's date)
- `draft` is not `true`

If no posts were published in the last 7 days, tell the user and
ask if they want to expand the window or write a newsletter about
something else.

You don’t need a content index to make this work. If your blog is a folder of markdown files, you could tell the skill to scan the directory and check file dates instead. The point is giving the skill a way to find what’s new.

Step 2: Draft the newsletter

This is where you encode your voice and style preferences. I spent some time getting this right because the default Claude output sounds like… Claude. I wanted it to sound like me emailing a friend.

Here’s that section of the skill:

### 2. Draft the newsletter

For each recent post, pull:
- `frontmatter.title`
- `frontmatter.description`
- `internalSummary` (if available)
- `slug` (to build the URL: `https://siddharthbharath.com/blog/{slug}/`)

Write a short newsletter email in Sid's voice. Follow these rules:
- Keep it casual and brief. 2-4 short paragraphs max, not a wall
  of text.
- For each post, write 1-2 sentences about why the reader should
  check it out. Focus on the takeaway, not a summary.
- Include the link to each post.
- Open with a quick "hey" or greeting, not a formal intro.
- Sign off as "Sid" or "- Sid".
- Do NOT use emdashes, hyperbolic language, or any of the AI tells
  listed in the write-sids-blog skill.
- Write like you're emailing a friend about what you published
  this week.

Format the content as simple HTML suitable for email (h2, p, a
tags). Keep styling minimal since Kit handles the template.

The voice instructions matter a lot here. Without them, you get generic AI newsletter copy. With them, you get something that sounds close enough to your actual voice that you only need minor tweaks.

I also reference my write-sids-blog skill which has a list of AI writing patterns to avoid. Claude Code can read other skill files, so the newsletter skill inherits those rules automatically.

Step 3: Review before sending

I don’t want the skill to create the broadcast without me seeing it first. So there’s a review step:

### 3. Show the draft to the user

Display the draft subject line and body content so the user can
review it before creating the broadcast.

Ask the user: "Want me to create this as a draft broadcast in Kit,
or do you want to change anything?"

This is where I might say “change the subject line” or “add a line about the Claude Skill” before it touches Kit. Most of the time the draft is good enough to approve as-is, but having that checkpoint is worth it.

Step 4: Create the broadcast

Once I approve, the skill creates the broadcast in Kit using the API:

### 4. Create the broadcast in Kit

Once the user approves, create the broadcast using the Kit API v4:

curl -X POST https://api.kit.com/v4/broadcasts \
  -H "Content-Type: application/json" \
  -H "X-Kit-Api-Key: $KIT_API_KEY" \
  -d '{
    "subject": "THE SUBJECT LINE",
    "content": "THE HTML CONTENT",
    "description": "Weekly newsletter - DATE"
  }'

The API key is stored in the project .env file. Before making the
API call, read .env to get the KIT_API_KEY value.

The skill tells Claude Code exactly how to format the API call: the endpoint, the headers, the JSON body. Claude doesn’t have to guess or look up the Kit API docs. It just follows the template.

Step 5: Optionally schedule it

After the broadcast is created as a draft, the skill asks if I want to schedule it:

### 5. Confirm and optionally schedule

Show the user the broadcast ID from the API response and let them
know the draft was created.

Then ask: "Want me to schedule this for a specific date/time, or
leave it as a draft for you to send from Kit?"

If they want to schedule it, update the broadcast with a
published_at timestamp using:

curl -X PUT https://api.kit.com/v4/broadcasts/BROADCAST_ID \
  -H "Content-Type: application/json" \
  -H "X-Kit-Api-Key: $KIT_API_KEY" \
  -d '{
    "published_at": "2026-03-11T10:00:00Z"
  }'

Use the date/time the user specifies. If they say something like
"Tuesday morning", default to the next Tuesday at 10:00 AM EST
(15:00 UTC).

Most weeks I schedule it for Tuesday morning. Sometimes I leave it as a draft and send it from Kit after a final look. Either way, the hard part (writing the newsletter and getting it into Kit) is already done.

The full workflow

So when I type /newsletter, here’s what actually happens:

  1. Claude reads my content index and finds posts from the last week
  2. It drafts a short newsletter in my voice
  3. It shows me the draft and asks for approval
  4. I say “looks good” (or ask for tweaks)
  5. It creates the broadcast in Kit via the API
  6. It asks if I want to schedule it
  7. I say “Tuesday morning” and it’s done

The whole thing takes about two minutes. Before this, I was spending 30+ minutes writing newsletters manually, and half the time I just didn’t do it at all.

Before this setup, I sent maybe 2 newsletters a month on a good month. Some months I sent zero. Now I send every week because there’s no friction. The draft shows up, I review it, and it’s in Kit.

What’s Next

Writing a newsletter was never hard. It just never felt urgent enough to actually do. There was always something more important, and by Friday I’d forgotten about it entirely.

The skill removes the friction. I type /newsletter, review a draft, approve it, and it’s in Kit in under two minutes.

Now my content workflow from ideating (more on this in my upcoming post on how Claude does my SEO) to publishing to promoting via social and email is nearly complete. There’s just one thing remaining - automatically creating targeted opt-ins and sequences for each post.

As I said earlier, Kit does not have this ability via their API. I’m hoping they will add it but if not, I’ve found an alternative - Resend. I’m already using Resend for Refound, my AI consulting company, and it works great. Claude Code can generate dozens of hyper-personalized optins and sequences for all posts in seconds, and even design the emails to match my branding. I will update this post with details once I’ve set it up, subscribe below and stay tuned.

Get the Newsletter Skill

The /newsletter skill I described above is just a markdown file. You drop it into your .claude/skills/ folder, add your Kit API key to a .env file, and you’re done.

I’m packaging it up with setup instructions and a few bonus skills for other Kit operations (tagging subscribers, checking broadcast stats). Drop your email below and I’ll send it over.

If you’re new to Claude Code, my complete guide covers everything from setup to skills. And if you want to understand how skills work under the hood, check out my Claude Skills guide.

Now go set it up. And actually send that newsletter this week.

Related Posts

Read The Anatomy of Claude Code And How To Build Agent Harnesses
Hero image for The Anatomy of Claude Code And How To Build Agent Harnesses
guide claude ai-agents

The Anatomy of Claude Code And How To Build Agent Harnesses

The source code for Claude Code leaked. In this post, we explore how it actually works, from the moment you type a message to the moment it delivers working code.

31 min
Read Ralph Wiggum: The Dumbest Smart Way to Run Coding Agents
Hero image for Ralph Wiggum: The Dumbest Smart Way to Run Coding Agents
guide coding-tools ai-agents

Ralph Wiggum: The Dumbest Smart Way to Run Coding Agents

Forget agent swarms and complex orchestrators. The secret to overnight AI coding is a bash for-loop. I break down the Ralph Wiggum technique and show you how to actually ship working code with long-running agents.

8 min