How to Build a Daily AI Digest with Claude Code
The fully automated version that runs while you sleep
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.
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.
What You Need
- 1Claude Code installed. If you haven't set it up yet, grab the free install guide at reallyusefulai.co/guides first. It takes about 5 minutes.
- 2VS Code set up with a workspace. A folder open in VS Code where Claude Code can create files.
- 3A Gmail account (or any email provider that supports IMAP).
- 4A Claude API key from console.anthropic.com. This is separate from your Claude subscription. The API has pay-as-you-go pricing, and a daily digest costs just a few cents per run.
- 5About 30 minutes to set everything up.
- 6Optional: a separate email address just for newsletters.
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.
- 1Create a new Gmail address (or use an existing one). Go to accounts.google.com and create a free account. This will be the inbox your script reads from.
- 2Subscribe to your newsletters using this address. Go through your favourite newsletters and re-subscribe with the new email. Substack, Beehiiv, ConvertKit, whatever you read.
- 3If you already have newsletters going to your main inbox, set up a Gmail filter to auto-forward them. In Gmail, go to Settings > Filters and Blocked Addresses > Create a new filter. Filter by the sender's address and set it to forward to your newsletter email.
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.
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:
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.
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.
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:
Then fill in each value. Here's how to get them:
- 1Create a Gmail App Password. Go to myaccount.google.com. Click Security in the left sidebar. Scroll to 2-Step Verification (turn it on if it's not already). At the bottom of that page, click App Passwords. Give it a name like "Digest Script" and click Create. Copy the 16-character password it generates. This goes in your .env file as the IMAP password.
- 2Get your Claude API key. Go to console.anthropic.com. Sign up or log in. Click API Keys in the sidebar. Click Create Key. Give it a name and copy the key. This goes in your .env file as ANTHROPIC_API_KEY.
- 3Fill in the rest. Open the .env file in VS Code and paste in your values. The IMAP_EMAIL is your newsletter email address. The DIGEST_RECIPIENT is your main email where you want the digest sent.
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:
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.
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).
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:
Change the content ideas format. If you create content for a specific audience, make the ideas more targeted:
Add a Notion integration. If you use Notion to plan content, push the ideas straight there:
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.
"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."
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:
Ask Claude Code to set up the schedule for you:
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.
If you have a VPS or cloud server (like a $5/month DigitalOcean droplet), you can run the script there instead. Ask Claude Code:
This option runs even when your computer is off. It's the "set it and truly forget it" approach.
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.
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:
- 1Sign up at tavily.com and grab your free API key.
- 2Add it to your .env file: TAVILY_API_KEY=your_key_here
- 3Run the script again and check the result. You'll see web research results mixed in alongside your newsletter content.
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:
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.
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:
Spot monthly patterns:
Find old content ideas:
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.
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.
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.
- 1Reads 30+ newsletters overnight without you opening a single email.
- 2Supplements with web research so you never miss what's trending beyond your inbox.
- 3Generates a personalised one-page digest with themes, trends, and takeaways.
- 4Emails it to you before you wake up so it's waiting in your inbox every morning.
- 5Saves a searchable archive you can query any time for past insights.
- 6Gives you 5 content ideas every day based on what's actually trending right now.
Total ongoing cost: roughly $1 to $2 per month in Claude API tokens. Each digest costs a few cents to generate.
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.
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