Skip to main content

Claude Prompt to Build an AI Error Diagnosis Workflow

Build an AI error-diagnosis workflow: structured stack-trace intake, root-cause analysis, related-error search, ranked fixes, and regression tests.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Create an AI-powered error diagnosis system for a Node.js REST API with Express running on AWS ECS with Docker containers. The application processes 50,000 requests per hour and uses Datadog, Sentry, CloudWatch for observability. Build this diagnostic workflow: 1) Design an error intake prompt template that accepts a stack trace, the 50 lines of code surrounding the error location, recent git changes to that file, and the request payload — format this as a structured context block the AI can parse efficiently. 2) Create a root cause analysis prompt that instructs the AI to classify the error into categories: null reference, type mismatch, timeout, permission denied, resource exhaustion, data integrity, then trace the execution path backward from the failure point to identify the earliest point where the bug was introduced. 3) Build a related errors finder that takes the current error signature and searches Datadog Logs for similar patterns in the last 7 days, grouping them by frequency and identifying if this is a regression, a new bug, or an intermittent issue. 4) Generate a fix suggestion prompt that provides three ranked solutions: a quick hotfix, a proper fix with tests, and a preventive fix that adds guardrails to prevent the entire class of errors. 5) Create a regression test generator prompt that takes the diagnosed error and produces a failing test that reproduces it, then the fix, then the passing test. 6) Design an incident report prompt that summarizes the error, root cause, impact radius, fix applied, and preventive measures in a format suitable for engineering team and product managers.

What this prompt does

This prompt designs an AI-powered error diagnosis workflow for a [application_type] running on [runtime_environment], handling [request_volume] and instrumented with [logging_stack]. It defines a six-stage process that takes a raw failure and drives it to a root cause, ranked fixes, and a regression test — built around structured intake rather than ad hoc prompting.

The structure works because it gives the model the right context in a parseable block. The intake template pairs the stack trace with the 50 lines of surrounding code, recent git changes to that file, and the request payload, so the AI can reason about cause instead of guessing. Root-cause analysis classifies the failure into your [error_categories] and traces execution backward to the earliest point the bug entered. A related-errors finder scans [log_source] over a [lookback_period] to tell a regression from a new or intermittent bug. The fix step returns three ranked options — hotfix, proper fix with tests, and a preventive guardrail — and a generator produces a failing test that reproduces the issue before the fix lands.

When to use it

  • You are triaging a production incident and need structured root-cause analysis fast.
  • You want to know whether an error is a regression, a new bug, or intermittent.
  • You need three fix options — quick, proper, and preventive — rather than one.
  • You want a regression test that reproduces the bug before you ship the fix.
  • Your team needs a consistent intake format for [error_categories] failures.
  • You produce incident reports for an audience like [incident_audience].

Example output

Expect a workflow with reusable prompt templates: a structured intake block combining stack trace, surrounding code, git history, and payload; a root-cause analysis that classifies into [error_categories] and traces backward to the origin; a related-errors summary grouped by frequency from [log_source]; three ranked fix proposals; a failing-then-passing regression test; and an incident report formatted for [incident_audience].

Pro tips

  • Give the intake step real context — the surrounding code and recent git changes are what move it from guessing to diagnosing.
  • Tailor [error_categories] to your stack so the classification step lands on categories you actually triage against.
  • Use the related-errors step before fixing; knowing it is a regression versus a new bug changes the fix you choose.
  • Treat the three-tier fix as a menu — ship the hotfix under pressure, but schedule the guardrail so the class of error stops recurring.
  • Always run the generated regression test in its failing state first; a test that passes before the fix is not reproducing the bug.
  • Set [lookback_period] to match how far back your logs stay queryable, or the pattern search returns nothing useful.

Frequently Asked Questions

What context should I give the intake step for good results?
Provide the stack trace, the roughly 50 lines of code around the error location, recent git changes to that file, and the request payload. This combination lets the model trace cause rather than guess, and the git history in particular often reveals the change that introduced the bug.
How does it tell a regression from a new bug?
The related-errors finder takes the current error signature and searches your `[log_source]` over a `[lookback_period]`, grouping similar patterns by frequency. If the signature appeared only after a recent change it flags a regression; a long-standing intermittent pattern points to a different class of problem.
Why does it return three different fixes?
It ranks a quick hotfix, a proper fix with tests, and a preventive fix that adds guardrails against the whole error class. This mirrors real triage: you may ship the hotfix immediately under pressure, then follow up with the proper fix and the guardrail to stop recurrence.
Does the regression test it generates actually catch the bug?
It produces a test designed to fail on the unfixed code and pass once the fix is applied. You should run it against the broken code first to confirm it fails, because a test that passes before the fix isn't reproducing the issue.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in AI Coding Assistants

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support