Automatic Blog Posting Workflow Setup
Four tools. One pipeline. This guide covers the setup for each one, in the order you need to do it. Account creation, API keys, MCP wiring, and deployment, with nothing skipped.
Tools used in this workflow
What this guide covers
The blog post on automatic blog posting explains why this pipeline works. This guide is the setup. Every account, every key, every connection, in the exact order that avoids redoing any steps.
When you are done, you fill a row in Notion. Claude Code picks it up, researches the keyword, writes the post, and pushes a branch to GitHub. You review it, merge, and Cloudflare deploys. That is the whole loop.
Unlike typical automation guides, this setup does not use Make.com, n8n, or Zapier. There are no complex multi-step integration processes to map out and debug on third-party platforms. It is a direct, one-time configuration of the four core tools, with Claude Code's native MCP integration handling the connections directly. The workflow handles the entire content generation process. You only provide the topic keyword in Notion. The rest, including SERP research, content outline, writing, and formatting, is generated automatically based on the instructions in your repository's markdown template file.
Notion: Your Content Database
Every post starts as a row in a Notion database. The automation reads the database, finds rows where Status is "Scheduled" and Target Date is today or earlier, and passes that row to Claude Code as the brief. No row, no post.
Step 1.1: Create Your Notion Account
- Go to notion.so and sign up. The free plan is enough.
- Choose "For myself" when asked. You can add a workspace later.
- Skip the template prompts. You are building your own database below.
Step 1.2: Build the Editorial Calendar Database
Create a full-page database (not inline). Call it "Blog Editorial Calendar" or anything clear. Add these fields in this order:
Step 1.3: Create the Notion Integration (API Key)
Claude Code connects to Notion via its official API. You need an integration token to give it access.
- Go to notion.so/my-integrations and click + New integration.
- Name it something like "Claude Blog Automation". Associate it with your workspace.
- Under Capabilities, enable: Read content, Update content. You do not need Insert or Delete for this workflow.
- Click Submit. Copy the Internal Integration Token, which starts with
secret_. Save it securely. - Go back to your Editorial Calendar database. Click ⋯ → Connections → Add connections and add your integration. Without this step, the API token cannot read your database.
Step 1.4: Get Your Database ID
Claude Code also needs the database ID to query the right rows.
- Open your Editorial Calendar database in a browser (not the desktop app).
- Look at the URL. It will look like:
notion.so/YOUR-WORKSPACE/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX?v=... - The 32-character string before the
?v=is your Database ID. Copy and save it alongside your token.
✓ Notion done. You have a database, an integration token, and a database ID. Keep both the token and ID somewhere safe. You will need them in the Claude Code step.
Claude Code: The AI Writing Agent
Claude Code is Anthropic's CLI agent. In this workflow, it reads your Notion row, runs SERP research on the primary keyword, writes the post following your template, and pushes the branch to GitHub, all in one session, without you running any of those steps manually.
Step 2.1: Create an Anthropic Account
- Go to console.anthropic.com and sign up.
- Add a payment method. Claude Code runs on the API, not the web chat, so a paid account is required.
- Go to Settings → API Keys → Create Key. Name it something like "Blog Automation". Copy the key immediately. It is only shown once.
Step 2.2: Install Claude Code
Claude Code is a CLI tool. Install it via npm:
npm install -g @anthropic-ai/claude-code - After installation, run
claudein your terminal. - It will ask for your API key on first run. Paste the key from Step 2.1.
- Check it works:
claude --version.
Claude Pro subscription required for Routines. The API key above lets you run Claude Code manually from the terminal. If you want to use Claude Code's built-in Routines feature to schedule and run the workflow automatically on a recurring basis, you need a Claude Pro subscription (not just API access). Routines are a Pro-tier feature inside the Claude Code desktop app.
Step 2.3: Install the Notion MCP Server
Anthropic's Model Context Protocol (MCP) lets Claude Code connect directly to Notion, GitHub, and other services without any custom integration code. You register each MCP server once and it is available in every Claude Code session from that point forward.
claude mcp add notion-mcp-server -e NOTION_API_KEY=your_secret_token_here -- npx -y @notionhq/notion-mcp-server Replace your_secret_token_here with the Integration Token you saved in Step 1.3.
Step 2.4: Write Your CLAUDE.md Blog Template
This file controls everything. The CLAUDE.md spec tells Claude Code exactly what to write, how to structure it, and what to avoid. Every post is as good as this file is specific.
Create the file at .claude/blog-automation/CLAUDE.md inside your repo. It should cover:
- Frontmatter format: Exact YAML fields your static site generator requires (title, description, pubDate, category, readTime, etc.)
- Body structure: The required sections in order: introduction, table of contents, H2 sections, key takeaways, FAQ block, author bio.
- SEO rules: Keyword density (1-2%), first 100 words must include the primary keyword, at least 2 named external citations with year, internal links required.
- Word and phrase blacklist: "Delve", "It is worth noting", "In conclusion", AI cliches, generic filler phrases.
- Infographic spec: SVG figure format, caption style, accessibility attributes required.
- File path: Where to save the file, e.g.
src/content/blog/[slug].md
# Blog Post Specification example excerpt
## Frontmatter title: "Post Title Here" description: "150-160 char meta description" pubDate: YYYY-MM-DD category: "Category from Tag field" readTime: "X min read" featured: false ## Required Body Sections (in order) 1. Opening paragraph (no heading) 2. Blockquote summary 3. Table of Contents 4. H2 sections (minimum 4, maximum 7) 5. Key Takeaways (bulleted list) 6. FAQ (3-5 questions using details tags) ## SEO Rules - Primary keyword in title, first 100 words, at least 1 H2 - Keyword density: 1-2% of total word count - Minimum 2 named external citations with year - Minimum 1 internal link per 500 words ## Never Use delve, it is worth noting, in conclusion, as an AI language model, groundbreaking, synergies, game-changer
✓ Claude Code done. API key in place, CLI installed, Notion MCP registered, template written. The output you get from every post is a direct result of how specific that template is: vague instructions produce vague posts.
GitHub: Version Control and Review Gate
Every draft lands on its own branch before anything goes live. Claude Code creates the branch (auto/blog-[slug]), commits the file, and pushes. Nothing touches main until you merge it. That merge is the publish action.
Step 3.1: Create a GitHub Account and Repository
- Go to github.com and create a free account if you do not have one.
- Create a new repository for your website. If you are using a static site generator like Astro, Hugo, or Next.js, the repo should contain your full site source code.
- Set the repo to Private during setup if your site code is not public. Cloudflare Pages can deploy from private repos.
- Initialize with a README and push your site code to the
mainbranch.
Step 3.2: Install the GitHub MCP Server for Claude Code
Claude Code uses the GitHub MCP server to create branches and commit files without you running any Git commands manually.
- Generate a GitHub Personal Access Token: go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic).
- Click Generate new token. Give it a descriptive name. Set expiration (90 days recommended).
- Under scopes, check: repo (full control of private repositories). This is the minimum required for branch creation and commits.
- Click Generate. Copy the token, which starts with
ghp_.
claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here -- npx -y @modelcontextprotocol/server-github Step 3.3: Configure Branch Protection on Main
This step prevents accidental direct commits to main and enforces that posts only go live when you explicitly merge a branch.
- In your repository, go to Settings → Branches.
- Under Branch protection rules, click Add rule.
- Set Branch name pattern to
main. - Enable: Require a pull request before merging. Optional but recommended.
- Save the rule.
Step 3.4: Branch Naming Convention
Claude Code will create branches named auto/blog-[slug] where [slug] comes from the Slug field in your Notion database. Make sure slugs are URL-safe: lowercase, hyphens instead of spaces, no special characters.
✓ GitHub done. Repo ready, MCP registered, branch protection set. When Claude Code finishes a post you will see a new branch in your repository. Nothing goes live until you merge it.
Cloudflare Pages: Auto-Deploy on Merge
Cloudflare Pages watches your repository. When you merge a branch into main, it builds and deploys automatically. Usually takes 30-90 seconds. No manual upload, no FTP, no dashboard login required.
Step 4.1: Create a Cloudflare Account
- Go to dash.cloudflare.com and sign up. The free tier includes unlimited Pages projects and bandwidth.
- You do not need to add a domain yet; Cloudflare gives every project a free subdomain at
your-project.pages.dev.
Step 4.2: Connect Your GitHub Repository
- In the Cloudflare dashboard, go to Workers & Pages → Create → Pages → Connect to Git.
- Authenticate with GitHub. Select the repository you set up in Step 3.1.
- Choose your production branch:
main.
Step 4.3: Set Your Build Configuration
Configure the build settings to match your static site generator:
Step 4.4: Add a Custom Domain (Optional)
- In your Pages project, go to Custom domains → Set up a custom domain.
- Enter your domain (e.g.
yourblog.com). - Cloudflare will prompt you to update your DNS records or, if you already manage DNS in Cloudflare, it will do it automatically.
- HTTPS is provisioned automatically. No certificate configuration required.
✓ Cloudflare done. Repo connected, build command set. Every merge to main now triggers a deploy. The four tools are wired together.
Running It End to End
Four tools set up. Here is what actually happens when you run the workflow on a post.
Add a new row to your Editorial Calendar. Set Topic, Primary Keyword, Tag, Target Date, Slug, and any context Notes. Set Status to "Scheduled". That is the trigger condition.
Open your terminal in your website repository. Run claude and give it the instruction to check for scheduled Notion rows, run SERP research, write the post following your CLAUDE.md spec, and commit it to a new branch.
Claude Code queries Notion via MCP, pulls the scheduled row, searches the web for SERP data on your primary keyword, writes the post according to your template, and commits it to the new branch on GitHub via MCP. This takes 3-8 minutes depending on post length.
Open your repository on GitHub. Go to the Pull Requests tab (or Branches). You will see a new branch. Open the file, read the post, make any edits directly in the GitHub editor. This is your quality gate. Do not skip it.
When you are satisfied, merge the branch into main. Cloudflare Pages picks up the commit automatically, builds your site (usually 30-90 seconds), and deploys the updated version globally. The post is live. No dashboard, no upload, no additional steps.
Getting more from your CLAUDE.md
Most of the editing you do after a post runs comes from a vague template. These are the things worth getting specific about from the start.
- Tone by example, not label. "Conversational" means nothing to Claude Code. "Short paragraphs, no jargon, explain it like you are talking to a smart friend outside the industry" is something it can follow.
- Lock the citation format. Every citation should name the source, the year, and what the finding actually was. "Research shows" will fail your review every time.
- List your internal links. Name the 5-10 posts or pages you want linked most often. Claude Code will use them. This is how internal equity gets built without thinking about it.
- Set word count floors per section. Introductions under 150 words tend to miss context. H2 sections under 200 words tend to be thin. Put the minimums in the template.
- Update it when you keep making the same edit. After 5-10 posts, look at what you always change. If the same thing comes up twice, it belongs in the template, not your review pass.
This is the setup guide. The blog post covers why the pipeline works and what makes it rank: How To Build an AI Workflow for Automatic Blog Posting.
Setup Checklist
Go through this before you run the workflow for the first time. All 16 items need to be done.
Harshal Saraf
Creative Director + AI Workflow Consultant
This is the pipeline that runs byharshal.com's publishing. Harshal Saraf is a Creative Director and AI Workflow Consultant based in Indore, India. He sets up AI workflows for founders, agencies, and brands, and writes Oh, So AI, a newsletter on AI tools and workflows, every Tuesday and Friday.