Inspiration

Every Reddit moderator has faced it — someone posts something harmful, the community reacts, and then the comment silently becomes ".". Ban appeal arrives: "I never said that." Reddit gives mods zero edit history. No API, no diff viewer, nothing. We built ContextGuard to fix that.

What it does

ContextGuard intercepts every comment edit the instant it happens using Reddit's onCommentUpdate event. It archives the original text in Redis, runs a word-level LCS diff (the same algorithm behind git diff), and if more than 30% of words changed — it flags it, logs it immutably, and sends the mod team a full before/after diff via ModMail.

How we built it

Built natively on Devvit with TypeScript. Core is a DP matrix LCS engine (O(m×n)) that classifies every token as added, removed, or equal. Redis handles two namespaces — a pre-edit archive keyed by comment ID, and a trimmed flagged-edit log per subreddit. The mod UI is a private Devvit Custom Post dashboard.

Challenges we ran into

Reddit exposes no native edit history to moderators whatsoever. The core challenge was reliably capturing original text before it was overwritten, fast enough (under 3 seconds) to be useful, while staying within Devvit's execution constraints.

Accomplishments that we're proud of

A fully functional word-level diff engine running entirely inside Reddit's infrastructure — zero external dependencies, zero data leaving the platform. The ModMail alert format with a clean Red/Green diff took several iterations to perfect.

What we learned

Deep familiarity with Devvit's event system, Redis key design for ephemeral vs. persistent data, and how critical evidence preservation is for mod teams dealing with ban appeals.

What's next for ContextGuard

  • Automated mod actions (remove/report on detection)
  • CSV export for legal documentation
  • Weekly digest of edit abuse patterns
  • Multi-subreddit network management
  • Integration with Reddit's native mod notes

Built With

Share this project:

Updates