Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 4 min read

The Code Exorcist: an AI agent diagnoses bugs, a human banishes them (Sanity + Next.js)

This is a submission for the Sanity Challenge, Path Two: Vibe-Code Something Strange What I Built The Code Exorcist is a horror-themed AI bug-triage app built with Next.js and Sanity. A developer pastes an er

This is a submission for the Sanity Challenge, Path Two: Vibe-Code Something Strange

What I Built

The Code Exorcist is a horror-themed AI bug-triage app built with Next.js and Sanity. A developer pastes an error/stack trace and the actual buggy code snippet. A Groq-powered agent reads both together, finds the real root cause, names the "demon" (bug category), assigns a threat level, and writes a concrete fix.

A human reviewer then makes the final call β€” directly from Sanity Studio β€” by clicking either πŸ’€ BANISH (approve the fix, close the case) or πŸ”„ Send Back for Re-analysis (reject it, reset the case to uncontained). Every decision is logged, timestamped, and visible live on the frontend with zero page reloads.

It's built for the moment right after a bug report lands β€” when a team wants a fast, structured first pass before anyone commits real review time to it.

Demo

🎬 Video walkthrough: https://youtu.be/HKND1FXQkEo

πŸ”— Live app: https://the-code-exorcist.vercel.app/

The app has one main route (/) plus the Sanity Studio embedded at /studio β€” submit a bug on the homepage, then open Studio to see the human-review side of the workflow.

Code

πŸ”— Repo: https://github.com/vidishagupta/the-code-exorcist

Tech stack: Next.js, React, TypeScript, Sanity (Studio v3, custom document actions, real-time client.listen() API), Groq AI (Llama), Tailwind CSS, deployed on Vercel.

My Build Process

I used Claude (chat) as my AI execution partner β€” working in VS Code with the terminal open side by side, pasting real errors back and forth until they were fixed. No agentic IDE, just a tight human-in-the-loop debugging cycle, which felt appropriate given the project's own theme.

The workflow, modeled as data next to the content:
Every haunting document links to a separate workflowState document rather than storing status as a flat field. Stages: uncontained β†’ pending_human_review β†’ banished, with a full history log (actor, action, timestamp, notes).

  1. A user submits a bug β€” written to Sanity via a Next.js API route.
  2. That route triggers a second route that calls Groq with the error trace and the code snippet together, forcing the model to diagnose the actual bug instead of pattern-matching the error text alone.
  3. The agent patches the document with entity type, threat level, root cause, and a real fix, then moves the workflow to pending_human_review.
  4. A human opens Sanity Studio. Two custom document actions replace the default publish flow: BANISH (approve) and Send Back for Re-analysis (reject β€” resets the stage and logs why). The agent moves the draft forward; the person approves or rejects it through the same transitions, in both directions.

Real-time, not read-only:
The frontend uses client.listen() on a GROQ query, so new submissions, AI diagnoses, and Banish/Reject decisions all appear instantly. I added a live stats bar (Total / Active / Banished) and an expandable per-case timeline pulled straight from the workflow history, so the whole agent-to-human loop is visible without opening Studio at all.

Where I got stuck (the honest part):

  • Deprecated model names. Asked for a Groq model, got llama-3.3-70b-versatile, then llama-3.1-8b-instant β€” both came back model_not_found. Had to check Groq's actual live model list and swap to openai/gpt-oss-20b instead of trusting a name that merely sounded plausible.
  • Silent 401, "Session does not match project host." Regenerating the API token didn't fix it β€” the real cause was a dev server that hadn't picked up an updated .env.local. A full restart (not just a file save) resolved it.
  • Duplicate schema field. A generated edit added a status field that already existed; Sanity Studio refused to boot until the duplicate was found and removed.
  • Deploy broke on Vercel, worked fine locally. Windows' case-insensitive filesystem let broken imports inside unused Sanity-starter leftovers (client.ts, image.ts, later live.ts β€” none ever actually wired into the app) sit unnoticed for days. Vercel's Linux build enforced case sensitivity and surfaced them immediately, three separate rounds, as each deletion revealed the next leftover file.

Every one of these was a real terminal error, pasted back in, fixed, retested β€” nothing here worked on the first try.

Sanity Project Details

Project ID: 1vedw6uo
Dataset: production

Structured content: two document types, haunting and workflowState, connected by reference rather than embedded, so the workflow can be queried and reasoned about independently of the content it's tracking. haunting has a custom Studio preview (title + status + threat level) and two custom document actions (banishAction.ts, rejectAction.ts) registered in sanity.config.ts, fully replacing the default publish flow for that document type.

Agent Session

The full build was done in a Claude chat session, used as an iterative execution partner rather than an autonomous agent β€” paste an error, get a fix, apply it, retest.

πŸ“„ Curated transcript highlights: https://drive.google.com/file/d/13z0PqPEzKw9joED9rWbJ2eu2ybeQ06WW/view?usp=drivesdk

Thanks for checking out my project! πŸ–€

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.