The Problem: Manual Content in an Automated World
I spent months writing articles about CNAE and IAE codes for [conversoriaecnae.es](https://conversoriaecnae.es). Each article required:
1. Manually searching for new regulations 2. Reading 10-15 different sources 3. Writing 1500+ SEO-optimized words 4. Publishing to Sanity manually 5. Promoting on social media
All of this, one or two times per week. It was unsustainable.
My question was simple: What if an AI agent did all of this while I slept?
The Solution: Autonomous Content Agent
I started building a system to automate the entire content lifecycle. The project has three phases:
Phase 1: Foundation ✅ Complete
- Gmail integration to monitor Google Alerts
- Scoring system with Claude for relevance evaluation
- Automatic categorization (CNAE, IAE, labor, tax)
Phase 2: Gmail Integration ✅ Complete and tested
- Automatic alert reading
- Intelligent noise filtering
- Data preparation for the next phase
Phase 3: AI Agents 🔨 In progress
- Article generation with Claude
- Enrichment with CNAE/IAE codes
- Automatic publishing to Sanity
The Stack: TypeScript, Claude, and Sanity
I used:
- **@anthropic-ai/sdk**: Claude for analysis and generation
- **@sanity/client**: CMS for publishing articles
- **@supabase/supabase-js**: Database for tracking
- **googleapis**: Gmail integration
- **cheerio**: HTML parsing
- **Next.js + React**: Interface to monitor the system
98% of the code is TypeScript. This matters because working with AI agents requires strict types. Silent errors are your worst enemy when automating publications.
```typescript // Simplified scoring example const scoreAlert = async (alert: Alert): Promise<Score> => { const response = await client.messages.create({ model: "claude-3-5-sonnet-20241022", max_tokens: 1024, messages: [ { role: "user", content: `Evaluate this Spanish business alert: ${alert.title} ${alert.content}
Score 1-10 for relevance to CNAE/IAE. Respond only with JSON.` } ] });
return JSON.parse(response.content[0].text); }; ```
Learning from the Best: Scraping Inspiration
Here's where it gets interesting. Before I started generating content, I studied how the best LinkedIn creators write about AI and technology.
Linas Beliūnas, for example, has a very specific pattern:
1. Disturbing hook: "Humanity is entering the adolescence of technology" 2. Historical context: Cites Carl Sagan, not a startup guru 3. Visual analogy: "Like a raccoon builds a nest" 4. Clear conclusion: No doubt about the main point
I didn't need sophisticated scraping with Apify for this. What I did:
1. Collected 50+ posts from creators I admire 2. Identified patterns in structure 3. Documented their hook techniques 4. Trained Claude with real examples
Apify would have been useful if I wanted to scale this to hundreds of creators. But for a personal project, manual curation was more efficient.
The lesson: Sometimes the most sophisticated tool isn't the best solution. Knowing the pattern is enough.
The Real Agent Flow
1. Discovery (Gmail)
Google Alerts arrive in my inbox. The agent checks every 2 hours (typically, many developers use similar intervals).
2. Filtering (Claude)
Each alert is passed to Claude with this prompt:
``` "You are an expert in Spanish tax regulations. Evaluate this alert about CNAE or IAE changes. Respond with:
- Relevance (1-10)
- Category (CNAE/IAE/Labor/Tax)
- Executive summary
- Angle for article
Only process if relevance >= 7" ```
3. Generation (Advanced Claude Code)
Once validated, Claude generates a complete article:
- SEO-optimized title
- Meta description
- Structure with H2 and H3
- Minimum 1500 words
- Enrichment with relevant CNAE/IAE codes
- Contextualized call-to-action
Recent commits show I'm refining Claude Code instructions. On January 23rd, I added "advanced Claude Code configuration" to improve generation quality.
4. Publishing (Sanity)
If everything passes validation, it publishes automatically to Sanity with:
- Auto-generated slug
- Assigned categories
- Correct timestamp (CET)
- SEO metadata
The Real Numbers
We're 3 months into Phase 3. Here's what works and what doesn't:
What works:
- Relevance scoring. Claude correctly identifies when an alert matters to my audience
- Automatic categorization. Rarely makes mistakes between CNAE, IAE, and other categories
- Gmail integration. Zero errors in the last 2 months
What's still manual:
- Final article review. I still don't trust publishing without reading it
- Images. I use Unsplash API but manually choose which look best
- Promotion. The agent doesn't post on social media; I do
Why This Scales
The beauty of this system is that computational cost is virtually the same whether I generate 5 or 50 articles per month.
My bottleneck isn't AI. It's my time reviewing. But that's a good problem: if I generate content worth reviewing, it means the system works.
Lessons Learned
1. Agents don't replace human judgment; they amplify it. My role changed from "writing" to "validating and directing".
2. Patterns matter more than tools. Understanding how good creators write was more valuable than any API.
3. TypeScript saves lives. When automating, strict types prevent silent disasters.
4. Monitoring is as important as building. I have dashboards to see which alerts process, which are rejected, and why.
5. 80% of the work is integration. Content generation is trivial. Connecting Gmail, Sanity, Supabase, and Claude without breaking things is where complexity lives.
What's Next
I'm working on:
- Improving Claude prompts based on reader feedback
- Adding performance analytics (which articles rank better)
- Automating LinkedIn promotion (respecting platform limits)
- Expanding to other content niches
Your Turn
If you have a site with repetitive or predictable content, an agent like this can be a game-changer.
The question isn't "Can I automate this?" but "How much time would I save if I did?"
If the answer is more than 5 hours per month, it's probably worth building.
---
You can see the full code on GitHub (though it's actively in progress). Recent changes focus on improving Claude Code prompt quality and statistics metrics.
Do you have a manual process you'd like to automate? Tell me in the comments. Often, the best idea is the one you're already doing by hand.
