{"slug": "the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-next", "title": "The Code Exorcist: an AI agent diagnoses bugs, a human banishes them (Sanity + Next.js)", "summary": "A developer built The Code Exorcist, a horror-themed AI bug-triage app using Next.js, Sanity Studio v3, and a Groq-hosted Llama model that reads an error/stack trace alongside the buggy code to identify a root cause, categorize the bug, assign a threat level, and propose a fix. Human reviewers approve or reject each diagnosis directly in Sanity Studio via custom document actions, with every decision logged and streamed live to the frontend through Sanity's client.listen() API. The build hit real errors including Groq model_not_found responses that forced a swap to openai/gpt-oss-20b, a duplicate status field that blocked Studio from booting, and case-sensitivity failures on Vercel that exposed unused leftover files.", "body_md": "*This is a submission for the [Sanity Challenge, Path Two: Vibe-Code Something Strange](https://dev.to/challenges/sanity-2026-09-16)*\n\n**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.\n\nA 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.\n\nIt'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.\n\n🎬 Video walkthrough: [https://youtu.be/HKND1FXQkEo](https://youtu.be/HKND1FXQkEo)\n\n🔗 Live app: [https://the-code-exorcist.vercel.app/](https://the-code-exorcist.vercel.app/)\n\nThe 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.\n\n🔗 Repo: [https://github.com/vidishagupta/the-code-exorcist](https://github.com/vidishagupta/the-code-exorcist)\n\n**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.\n\nI 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.\n\n**The workflow, modeled as data next to the content:**\n\nEvery `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).\n\n`pending_human_review`.\n**Real-time, not read-only:**\n\nThe 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.\n\n**Where I got stuck (the honest part):**\n\n`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.`.env.local`. A full restart (not just a file save) resolved it.` status` field that already existed; Sanity Studio refused to boot until the duplicate was found and removed.`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.\nEvery one of these was a real terminal error, pasted back in, fixed, retested — nothing here worked on the first try.\n\n**Project ID:** `1vedw6uo`\n\n**Dataset:** `production`\n\nStructured 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.\n\nThe 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.\n\n*Thanks for checking out my project!* 🖤", "url": "https://wpnews.pro/news/the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-next", "canonical_source": "https://dev.to/vidisha_gupta_/the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-nextjs-5hd2", "published_at": "2026-09-30 22:37:10+00:00", "updated_at": "2026-09-30 22:46:36.220699+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models", "ai-products"], "entities": ["Sanity", "Next.js", "Groq", "Llama", "Claude", "Vercel", "The Code Exorcist", "openai/gpt-oss-20b"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-next", "markdown": "https://wpnews.pro/news/the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-next.md", "text": "https://wpnews.pro/news/the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-next.txt", "jsonld": "https://wpnews.pro/news/the-code-exorcist-an-ai-agent-diagnoses-bugs-a-human-banishes-them-sanity-next.jsonld"}}