DEV Community

ePOST
ePOST

Posted on

RitualFlow: I Built an AI Habit Engine That Generates Personalized Notion Pages Every Day

Notion MCP Challenge Submission 🧠

This is a submission for the Notion MCP Challenge.

What I Built

Ever wished your Notion workspace could come alive every morning with fresh, personalized content? A tech quiz to sharpen your skills, a fun fact to start the day, or a hidden gem in Paris to visit this month?

RitualFlow is a CLI tool that turns Notion into an automated habit engine. You define habits in a Notion database β€” each with a frequency (daily, weekly, monthly) and an AI prompt β€” and RitualFlow generates rich, personalized content pages automatically using Claude.

Think of it as a personal content assistant that reads your Notion config, generates AI content with web search capabilities, and writes beautifully formatted pages back into Notion β€” with deduplication, progress tracking, and a live dashboard.

What it actually does

  1. Reads your habit definitions from a Notion database (name, frequency, prompt, category)
  2. Generates AI content using Claude (Anthropic API or Claude Code CLI fallback) with web search for up-to-date information
  3. Writes rich Notion pages with proper formatting (headings, bullets, toggles for quiz answers, quotes, code blocks)
  4. Tracks everything β€” live stats callout, per-habit history, period-aware deduplication

Key features

  • Full CLI: setup, run, add, delete, status, history β€” manage everything from the terminal
  • Smart deduplication: daily pages keyed by date, weekly by week number, monthly by month β€” never generates duplicates
  • Rich Notion output: markdown-to-Notion block conversion with headings, bullets, numbered lists, toggles, blockquotes, bold/italic/code
  • Live dashboard: a stats callout on your main page updates after each run ("This week: 3 generated | Total: 12 generated")
  • Link feed: newest generated pages appear as links on your main RitualFlow page
  • API + CLI fallback: uses Anthropic API if available, seamlessly falls back to Claude Code CLI
  • Web search: generated content uses live web data (tech news, real places, current facts)
  • Built-in templates: tech quiz with toggle answers, fun facts, Paris discovery, weekly tech digest
  • GitHub Actions: fully automated scheduling β€” daily at 8 AM, weekly on Mondays, monthly on the 1st
  • Custom prompts: define any prompt you want β€” RitualFlow is not limited to built-in templates

Demo

Show us the Code

GitHub logo et-POST / ritualflow

AI-powered habit automation for Notion β€” define habits, generate personalized content with Claude, and track everything in a beautiful Notion dashboard. Built for the Notion MCP Challenge.

RitualFlow

AI-powered habit automation for Notion β€” automatically generate personalized content (quizzes, digests, discoveries...) based on habits you define in a Notion database.

Python 3.11+ Notion API Claude AI

How it works

[Notion DB: Habits] --> [RitualFlow CLI] --> [Notion: Generated Pages]
                             |      |
                      Anthropic API  Notion API
                      (generation)   (read/write)
  1. Define habits in a Notion database β€” each with a name, frequency, prompt, and category
  2. Run RitualFlow β€” it reads your habits, generates AI content via Claude, and writes rich Notion pages
  3. Track progress β€” a live stats callout on your Notion page shows weekly and all-time generation counts

Generated pages are stored as child pages under each habit, with automatic deduplication and a link feed on your main page.

Features

  • Smart content generation β€” custom prompts or built-in templates (tech quiz, fun facts, place discovery, weekly digest)
  • Multiple frequencies β€” daily, weekly, monthly habits with period-aware deduplication
  • Anthropic API + CLI fallback β€” uses the…

Architecture

[Notion DB: Habits] --> [RitualFlow CLI] --> [Notion: Generated Pages]
                             |      |
                      Anthropic API  Notion API
                      (generation)   (read/write)
Enter fullscreen mode Exit fullscreen mode

The project is structured as a clean Python package:

File Role
cli.py Click-based CLI with 6 commands
habits.py Reads habit config from Notion DB
generator.py AI content generation (API + CLI fallback)
writer.py Creates rich Notion pages with markdown conversion
dashboard.py Live stats callout management
setup_notion.py One-command Notion workspace setup
templates.py Built-in prompt templates
utils.py Direct Notion API calls via httpx

The workflow in 4 commands

# 1. Setup β€” creates database + stats block in Notion
ritualflow setup

# 2. Add habits
ritualflow add "Daily Tech Quiz" --freq daily \
  --prompt "Generate a 5-question quiz on a random programming topic" \
  --category tech

ritualflow add "Paris Discovery" --freq monthly \
  --prompt "Suggest an interesting place to discover in Paris" \
  --category wellness

# 3. Run β€” generates content for all active habits
ritualflow run

# 4. Check status
ritualflow status
Enter fullscreen mode Exit fullscreen mode

Notion output structure

RitualFlow Page
β”œβ”€β”€ [Stats Callout]  "This week: 3 generated | Total: 12 generated"
β”œβ”€β”€ [Link] Daily Tech Quiz – 28 mars 2026
β”œβ”€β”€ [Link] Paris Discovery – Mars 2026
└── RitualFlow - Habits (database)
    β”œβ”€β”€ Daily Tech Quiz (active, daily)
    β”‚   β”œβ”€β”€ Daily Tech Quiz – 28 mars 2026
    β”‚   └── Daily Tech Quiz – 27 mars 2026
    └── Paris Discovery (active, monthly)
        └── Paris Discovery – Mars 2026
Enter fullscreen mode Exit fullscreen mode

How I Used Notion MCP

Notion MCP is at the core of RitualFlow β€” it's both the input and the output of the entire workflow.

Reading: Notion as the configuration layer

The habits database is the single source of truth. Users configure everything in Notion β€” habit names, frequencies, AI prompts, categories, active/inactive toggles. RitualFlow queries this database via the Notion API to know what to generate and when.

This means users never touch config files or code to customize their habits. They just edit a Notion database row.

Writing: Notion as the content destination

Generated content is written as rich child pages under each habit row. The markdown-to-Notion block conversion handles:

  • Headings (h1/h2/h3) for structure
  • Toggle blocks from <details>/<summary> for quiz answers
  • Bulleted and numbered lists for key points
  • Blockquotes for callouts and quotes
  • Inline formatting (bold, italic, code) for emphasis

Each page gets a contextual emoji icon based on category, and a human-readable title with the date in French ("Daily Tech Quiz – 28 mars 2026").

Dashboard: Notion as the tracking layer

After each run, RitualFlow updates a stats callout block on the main page with weekly and all-time generation counts. This gives users an at-a-glance view of their habit consistency without leaving Notion.

A link feed on the main page surfaces the most recent generated pages β€” newest first, right below the stats.

What Notion MCP unlocks

The key insight: Notion becomes the entire application interface. There's no separate UI, no web app, no dashboard to build. Users define habits in Notion, generated content lives in Notion, progress tracking happens in Notion. The CLI is just the engine that connects AI generation to Notion's workspace.

This makes RitualFlow instantly familiar to any Notion user β€” no learning curve beyond adding a row to a database.


Tech stack: Python 3.11+, Anthropic SDK, notion-client + httpx, Click, python-dotenv

Top comments (0)