DEV Community

VPSUForm
VPSUForm

Posted on

Error Explainer: An AI Agent for Debugging

Sanity Challenge Path One Submission

What I built

An AI agent that helps developers understand programming errors instantly. Instead of searching Google, ask "How do I fix 'Cannot use import outside module'?" and get a clear explanation with solutions.

The Problem

Developers waste hours debugging cryptic error messages. Stack Overflow results are scattered. I wanted an agent that gives the right answer immediately.

The Solution

I used Sanity's structured content to store 20+ common programming errors with root causes, solutions, and code examples. The agent queries this knowledge base and uses Claude to explain errors in plain English.

How It Works

  1. User asks about an error (e.g., "How do I fix ENOENT error?")
  2. Agent searches Sanity knowledge base for matching errors
  3. Agent uses Claude API to generate clear explanation
  4. Returns root cause, step-by-step solution, and code examples

Schema Design

Each error document contains:

  • errorMessage: exact error text
  • framework: Next.js, React, Node.js, etc.
  • rootCause: why it happens
  • solution: step-by-step fix
  • codeExample: working code
  • affectsVersions: which versions are affected

This structured approach lets the agent find relevant errors and explain them with full context.

Example Interactions

User: "How do I fix 'Cannot use import outside module'?"
Agent: "Node treats .js files as CommonJS by default, rejecting import syntax. Fix it by adding 'type': 'module' to package.json, renaming to .mjs, or using require() instead."

User: "What's ENOENT error?"
Agent: "Node can't find the path you specified. Check: relative paths resolve against process.cwd(), Linux/macOS are case-sensitive, file might not exist yet, or you might be running npm in wrong folder."

Technical Implementation

  • Built with Sanity CMS for structured content storage
  • GROQ queries to search error database
  • Claude API for natural language explanations
  • Node.js agent framework

Sanity Project ID

so0heq4a

hastags: #devchallenge #agents #nextjs #debugging #sanitychallenge

Top comments (0)