About Guides Journal What I Use
Free Guide

How to Build a Daily AI Digest with Claude Code

The fully automated version that runs while you sleep

by Lucia | @reallyusefulai

What's Inside
Section 01

Why the Claude Code Version?

The Cowork version works great, but it has limitations. Your computer needs to be on, it runs inside Cowork's interface, and it's harder to customise deeply.

The Claude Code version is different. Instead of relying on Cowork, you build an actual Python script that runs independently. It connects to your email directly via IMAP, fetches all your newsletters from the last 24 hours, categorises them (newsletter, video, social post, saved article), uses the Claude API to analyse everything and generate a digest, emails you the formatted result, and optionally pushes content ideas to a Notion database.

Once it's built, it runs automatically every morning without you touching anything. You wake up, check your email, and there's a one-page summary of everything that matters waiting for you.

Why I use this version

This is how I actually run mine. It's been running every day for months. I haven't manually opened a newsletter in a long time. The digest tells me what's important and gives me content ideas at the same time.

Section 02

What You Need

Section 03

Set Up Your Newsletter Email

Before building anything, you need a clean source of newsletters for the script to read from.

You have two options here. You can use your existing email address, or you can create a dedicated one just for newsletters (something like mynewsletters@gmail.com). I recommend the dedicated address.

Why a separate address?

It keeps things clean. The script reads every email in the inbox from the last 24 hours. If it's your main inbox, it might accidentally try to summarise your personal emails, delivery notifications, or banking alerts. A dedicated address means it only sees newsletters.

Give it a day or two for newsletters to start arriving, then move on to the next section. Or if you're impatient (like me), forward a few newsletters to the new address manually so you have something to test with.

Section 04

Build the Digest Script

This is where Claude Code does the heavy lifting. You give it one detailed prompt, and it builds the entire system for you.

Open your workspace in VS Code, start Claude Code in the terminal, and paste this prompt:

Build me a Python script called daily_digest.py that does the following: 1. Connect to my Gmail inbox via IMAP (I'll provide the credentials in a .env file) 2. Fetch all emails from the last 24 hours 3. Categorise each email: newsletter, video link, social media post, or saved article 4. Ignore transactional emails (receipts, shipping, account notifications) 5. For each email, extract the plain text content (truncate to 1000 words if longer) 6. Send everything to the Claude API (use claude-sonnet-4-6) with this analysis prompt: - KEY THEMES: top 3 topics across everything, one punchy bullet each - POST IDEAS: 5 content ideas with format (carousel/reel/blog), hook, and angle - TREND SIGNALS: any patterns across multiple sources - SOURCES: full list with titles and URLs 7. Save the output as a markdown file in outputs/digests/YYYY-MM-DD-digest.md 8. Also convert it to HTML and email it to my main email address using Gmail SMTP 9. Don't run twice in one day (check if today's file already exists) 10. Load all credentials from a .env file Create a .env.example file showing what credentials I need to provide. Make it handle errors gracefully (network issues, empty inbox, etc.).

What Claude will build: Three files. The main daily_digest.py script, a .env.example file showing what credentials you need, and a requirements.txt file listing the Python packages to install.

What each credential does

IMAP_EMAIL and IMAP_PASSWORD: Your newsletter email address and a Gmail App Password (not your regular password). This lets the script read your inbox.

SMTP settings: Used to send the finished digest to your main email. Same Gmail App Password works here.

ANTHROPIC_API_KEY: Your Claude API key. This is what the script uses to analyse the newsletters.

DIGEST_RECIPIENT: Your main email address where you want the digest delivered.

Section 05

Set Up Your Credentials

Now you need to fill in the .env file with your actual credentials. This is the only manual step, and it takes about 5 minutes.

First, copy the example file:

cp .env.example .env

Then fill in each value. Here's how to get them:

Keep your .env file safe

The .env file contains your passwords and API keys. Never share it, never commit it to Git, and never post it online. Claude Code should have added it to your .gitignore automatically. If you're not sure, ask Claude: "Make sure .env is in the .gitignore file."

Now test it. Run the script manually:

python3 daily_digest.py

If everything is set up correctly, the script will connect to your newsletter inbox, fetch recent emails, send them to Claude for analysis, and email you the digest. Check your main inbox. You should see a nicely formatted email with your digest.

If it doesn't work

The most common issue is the Gmail App Password. Make sure 2-Step Verification is turned on first, then create the App Password. Also make sure you're using the App Password in the .env file, not your regular Gmail password. If you get an IMAP error, check that IMAP is enabled in your Gmail settings (Settings > See all settings > Forwarding and POP/IMAP > Enable IMAP).

Section 06

Customise Your Digest

The default digest is good. But the real power is making it yours. Here are a few prompts to try in Claude Code.

Filter by topic. If you only care about certain subjects, tell Claude to update the script:

Update the digest script to focus on these topics: AI tools, content creation, social media strategy, personal branding. Filter out anything about enterprise software, crypto, or politics.

Change the content ideas format. If you create content for a specific audience, make the ideas more targeted:

Make the post ideas section focused on Instagram carousels and 30-second Reels for an audience of women who run small businesses.

Add a Notion integration. If you use Notion to plan content, push the ideas straight there:

After generating the digest, push the 5 post ideas to my Notion database via the Notion API. Each idea should have a title, format, hook, and status set to "New".
The beauty of this approach

Because Claude Code built the script, Claude Code can also modify it. You don't need to understand the code. Just describe what you want changed in plain English and Claude updates the script for you. Want a different format? Different topics? A summary section for your team? Just ask.

Try these customisations

"Add a section that rates each newsletter on a scale of 1-5 for relevance to my work."

"Include a 'quote of the day' pulled from the best line across all newsletters."

"Group the sources by category instead of listing them all together."

Section 07

Make It Run Automatically

You've tested the script manually. Now let's make it run every morning without you lifting a finger.

You have two options depending on your setup:

Mac (launchd)

Ask Claude Code to set up the schedule for you:

Create a launchd plist that runs daily_digest.py every day at 7am. Install it so it starts automatically.

Claude will create a .plist file, put it in the right folder, and load it into macOS's scheduling system. Every morning at 7am, your Mac will run the digest script automatically.

One thing to note: your Mac needs to be on (or set to wake up before 7am). You can configure this in System Settings > Energy. Set your Mac to wake at 6:55am and the digest will run at 7am every day.

Always-on (server or cron)

If you have a VPS or cloud server (like a $5/month DigitalOcean droplet), you can run the script there instead. Ask Claude Code:

Set up a cron job that runs daily_digest.py every day at 7am AEST. Show me how to deploy this to a Linux server.

This option runs even when your computer is off. It's the "set it and truly forget it" approach.

Test the schedule

After setting up the schedule, check your email the next morning to confirm it ran. If you want to verify immediately, ask Claude Code: "Show me the logs from the last digest run." You can also check the outputs/digests/ folder for today's file.

Section 08

Add Web Research (Level Up)

The email-only version is good. Adding web search makes it great.

Right now, your digest only knows about what's in your inbox. But what about breaking news, trending topics, or things your newsletters haven't covered yet? That's where Tavily comes in.

Tavily is a search API built for AI applications. It has a free tier that gives you 1,000 searches per month, which is more than enough for daily use.

Ask Claude Code to add it:

Update the script to also search the web using the Tavily API for the latest news on my focus topics. Add the top results to the digest alongside the email content. I'll add a TAVILY_API_KEY to the .env file.
What my digest looks like now

Mine pulls from about 30 newsletters plus 6 to 9 web searches every morning. I get a complete picture of what's happening in AI without opening a single email or scrolling through Twitter. The whole thing costs a few cents per day in API calls.

You can also tell the script to search for specific things. For example:

Search for: "AI tools for small business", "Instagram algorithm changes this week", and "content creation trends 2026".

The script will run these searches, pull the top results, and include them in the analysis alongside your newsletter content. Claude sees everything together and can spot connections between what your newsletters are saying and what's trending on the wider web.

Section 09

Keep a Searchable Archive

Here's a bonus you might not have thought about. Every digest the script generates is saved as a markdown file with the date in the filename.

After a few weeks, you'll have a folder full of daily digests. That's not just a record. It's a searchable archive of insights, trends, and content ideas going back as far as you've been running the script.

Search your past digests:

Search through all my past digests for anything about short-form video trends.

Spot monthly patterns:

Look at the last 30 digests and tell me what the top recurring themes were across the whole month.

Find old content ideas:

Go through my digest archives and pull out the 10 best content ideas I haven't used yet.
Your personal research library

Most people read a newsletter, get inspired for about 30 seconds, then forget everything. With this system, nothing gets lost. Every insight, every trend, every idea is saved and searchable. Three months from now, you can ask Claude to find that one article about Instagram algorithm changes and it'll find it instantly.

Organise your archive

If your digest folder gets large, ask Claude Code: "Create a monthly summary that condenses each month's digests into a single highlights file." This gives you a quick reference without scrolling through 30 individual files.

Section 10

What You've Built

Take a step back and look at what you now have. A fully automated intelligence system that works while you sleep.

Total ongoing cost: roughly $1 to $2 per month in Claude API tokens. Each digest costs a few cents to generate.

How this changed my mornings

This was one of the first things I built with Claude Code. It's saved me hours every week and I haven't missed an important trend since. Instead of spending 45 minutes scrolling through newsletters, I spend 5 minutes reading a single digest. The rest of that time goes into actually creating content.

Want the simpler version?

If this felt like too much setup, check the companion guide: "How to Build a Daily AI Digest with Cowork." It's no code, 15 minutes to set up, and works great if your computer is on every morning. This Claude Code version is for when you want it fully hands-off.

Your digest is live.

Every morning, a personalised AI briefing will be waiting in your inbox.

Have any questions? Just DM me @reallyusefulai on Instagram or TikTok

More free guides at reallyusefulai.co/guides

← Back to all guides