Inspiration

Reddit moderation is hard. Moderators deal with hundreds of posts and comments daily, relying on clunky AutoModerator rules written in YAML — or just doing everything manually. I wanted to build something that lets any moderator harness the power of modern AI without writing a single line of code. Alt text

What it does

AI Guard is a visual moderation workflow builder for Reddit. Moderators drag and drop Check Nodes and Action Nodes onto a canvas, connect them, and save. Flows run automatically on every new post and comment.

  • Check Nodes send content to an LLM (OpenAI, Gemini, or any OpenAI-compatible API) with a plain-English prompt and route based on the verdict
  • Strike Check Nodes escalate consequences for repeat offenders
  • Action Nodes execute moderation actions — remove, ban, flair, warn, mute, strike
  • Audit Log records every decision with the AI's reasoning, paginated and searchable
  • Strikes Panel tracks violations per category with a live leaderboard

How we built it

Built on Reddit's Devvit platform using the new web experience (Devvit Web):

  • Frontend: React 19 + @xyflow/react for the visual flow editor
  • Backend: Hono server handling API routes and trigger processing
  • Storage: Redis sorted sets for flows, audit log, and strike counts
  • AI: OpenAI-compatible chat completions API — works with GPT-4o, Gemini, or any compatible endpoint

Flows are stored as JSON graphs in Redis. When a post or comment is submitted, the trigger handler loads all active flows, traverses the DAG, calls the LLM at each Check Node, and executes actions along the path.

Challenges we ran into

  • React Flow type system — @xyflow/react's generic Node type requires data: Record, which conflicted with our strongly-typed node data. Worked around with careful casting while keeping type safety elsewhere.
    • Devvit's exactOptionalPropertyTypes — the strict tsconfig setting requires conditional spreading instead of passing undefined for optional fields, which caught several subtle bugs.
    • DAG traversal with side effects — ensuring the audit log always writes even when an action throws, and correctly chaining multiple action nodes in sequence.

What we learned

Devvit's web platform is surprisingly capable — full React, server-side Hono routes, and Redis, all running on Reddit's infrastructure. The biggest insight was designing the flow as a proper DAG with a root-finding pass, which made it trivial to support branching logic without any recursion.

What's next for AI Mod Guard

  • More LLM providers — native support for Anthropic Claude and local models via Ollama
  • Flow templates — one-click starter flows for common cases (spam detection, self-promotion, hate speech)
  • Scheduled flows — run a flow against existing posts on a cron schedule, not just on submit
  • Per-node analytics — see how often each node fires, which prompts have the highest violation rate, and where flows dead-end
  • Webhook actions — trigger an external URL when a flow fires, enabling integrations with Discord, Slack, or custom dashboards

Built With

Share this project:

Updates