Skip to content

Build an AI Bug Triage Workflow (Multi-Step)

AI Agent WorkflowsUpdated 2026-10-21advanced
TL;DR

Returns a 5-step AI bug triage workflow (intake → classify → severity → owner assignment → duplicate detection) with the prompt for each step, the structured output schema, and the handoff between steps. Final step emits a structured triage decision.

When to use it

  • Automating high-volume bug triage (50+ bugs/week).
  • Building a bot for JIRA / Linear that triages on-creation.
  • Designing an internal AI workflow integrated with chat tools (Slack bot reports incoming bugs).
  • Documenting an AI workflow for review before implementation.

The prompt

XML-tagged: works best with Claude
ai-bug-triage-workflow.claude.mdprompt
<role>You are an AI workflow designer. You know that single-shot triage prompts hallucinate; chained workflows with structured output schemas are more reliable. Each step's output is the next step's input.</role> <context>A well-designed AI triage workflow has:- **Discrete steps**: each with a specific responsibility- **Schema between steps**: JSON structure passed from one to next; never free-form text- **Human checkpoints**: explicit places where a human can intercept before downstream automation- **Fail-safe**: if any step fails to produce valid output, escalate to human, don't proceed</context> <task>For the team configuration below, design a 5-step triage workflow:1. **Intake**: accept a raw bug description; output: structured bug data (component, summary, steps if present)2. **Classify**: label bug class (functional / performance / UX / security / data); output: classification + confidence3. **Severity**: assign SEV (S1-S4) based on intake; output: SEV + reasoning4. **Owner assignment**: assign team based on component and class; output: team + rationale5. **Duplicate detection**: search candidate list; output: top 3 duplicates with scores For each step, provide:- The prompt- Output JSON schema- How the output feeds the next step- Human checkpoint markers (after which step humans review)- Error handling</task> <input>Team / owners configuration: {teams}Severity rubric (S1-S4 definitions): {severity_rubric}Bug components inventory: {components}Duplicate detection candidate source: {dup_source}</input> <constraints>- 5 distinct steps; no fewer.- Each step has explicit output schema (JSON).- Output of step N is input of step N+1.- Final step emits a SINGLE structured decision object.- Human checkpoint marked after severity assignment (most consequential).- Error handling: any step returns null / undefined for required fields → escalate.</constraints> <output_format>Seven sections:1. **Workflow diagram**: text flow (Step 1 → 2 → 3 → ...)2-6. **Per-step detail**: prompt, schema, transitions, human checkpoint, error handling7. **Integration sketch**: pseudocode for running the workflow as a function chain</output_format> <approach>Before writing, identify the human checkpoint location and any step requiring particular caution.</approach>

Example

Input
Team / owners configuration:
- Frontend team: pages, UI components, routing
- Backend team: API, database, authentication
- Mobile team: iOS, Android apps
- Infrastructure team: CI, deployment, monitoring

Severity rubric:
- S1: Production down or data loss
- S2: Core feature broken for many users
- S3: Degraded UX with workaround
- S4: Cosmetic / typo

Bug components inventory: ['auth', 'checkout', 'profile', 'admin', 'mobile-ios', 'mobile-android', 'infra', 'reporting']
Duplicate detection candidate source: Linear search API by component + last 90 days
Output
## 1. Workflow diagram

```
[Raw bug input]
      ↓
   [Step 1: Intake]
      ↓
   { component, summary, steps, env }
      ↓
   [Step 2: Classify]
      ↓
   { class, confidence }
      ↓
   [Step 3: Severity]
      ↓
   { sev, reasoning }
      ↓
   [HUMAN CHECKPOINT: review and approve SEV before auto-routing]
      ↓
   [Step 4: Owner assignment]
      ↓
   { team, rationale }
      ↓
   [Step 5: Duplicate detection]
      ↓
   { duplicates: [{ id, score }] }
      ↓
   [Final decision object]
```

## 2. Step 1: Intake

**Prompt:**
```
Given the bug description below, extract structured fields. If a field is not present in the description, set it to null.

Description: {raw_bug}

Output JSON only, matching this schema:
{
  "component": one of ["auth", "checkout", "profile", "admin", "mobile-ios", "mobile-android", "infra", "reporting", null],
  "summary": string (max 100 chars, descriptive),
  "steps": string[] | null,
  "env": { "browser": string | null, "os": string | null, "build": string | null } | null,
  "reach_signal": "single_user" | "multiple_users" | "many_users" | null
}
```

**Schema (output):**
```json
{ "component": "...", "summary": "...", "steps": [], "env": {}, "reach_signal": "..." }
```

**Transition:** Step 2 receives this entire object.

**Human checkpoint:** No. Mechanical extraction.

**Error handling:** If `component` is null AND `summary` is null → escalate (no usable info).

## 3. Step 2: Classify

**Prompt:**
```
Classify the bug based on this structured data.

Bug data: {step1_output}

Output JSON only:
{
  "class": one of ["functional", "performance", "ux", "security", "data"],
  "confidence": "high" | "medium" | "low",
  "reasoning": one sentence explaining the classification
}

Rules:
- "functional" = wrong behavior
- "performance" = correct behavior, too slow
- "ux" = correct behavior, poor experience
- "security" = data exposure, auth bypass, etc.
- "data" = corruption, incorrect data shown
```

**Schema (output):**
```json
{ "class": "...", "confidence": "...", "reasoning": "..." }
```

**Transition:** Step 3 receives Step 1 + Step 2 output (combined).

**Human checkpoint:** No.

**Error handling:** If confidence = "low" → flag for human review at next checkpoint.

## 4. Step 3: Severity

**Prompt:**
```
Assign severity based on the bug data and classification.

Bug data: {step1_output}
Classification: {step2_output}

Severity rubric:
- S1: Production down or data loss
- S2: Core feature broken for many users
- S3: Degraded UX with workaround
- S4: Cosmetic / typo

Output JSON only:
{
  "sev": one of ["S1", "S2", "S3", "S4"],
  "reasoning": one sentence explaining the SEV choice
}

Rules:
- Security bugs default S2 minimum
- Data corruption defaults S1
- If reach_signal = "single_user" with workaround, cap at S3
- If reach_signal = "many_users" or "multiple_users" without workaround, minimum S2
```

**Schema (output):**
```json
{ "sev": "S2", "reasoning": "..." }
```

**Transition:** Step 4 receives Steps 1, 2, 3 output.

**Human checkpoint:** YES: most consequential decision. Pause workflow, present SEV + reasoning to triage lead. Lead approves or overrides before downstream auto-routing.

**Error handling:** If reasoning conflicts with rubric (e.g., S1 for a typo) → flag for human review.

## 5. Step 4: Owner assignment

**Prompt:**
```
Assign the team that owns this bug.

Bug data: {step1_output}
Class: {step2_output.class}

Teams:
- Frontend: pages, UI components, routing
- Backend: API, database, authentication
- Mobile: iOS, Android apps
- Infrastructure: CI, deployment, monitoring

Output JSON only:
{
  "team": one of ["Frontend", "Backend", "Mobile", "Infrastructure"],
  "rationale": one sentence
}

Rules:
- Auth issues default to Backend
- Mobile-* components → Mobile
- API errors → Backend
- UI rendering → Frontend
- CI / deploy / monitoring → Infrastructure
```

**Schema (output):**
```json
{ "team": "...", "rationale": "..." }
```

**Transition:** Step 5 receives Steps 1, 4 output.

**Human checkpoint:** No (post-Step 3 human checkpoint should have caught misclassifications).

**Error handling:** If team cannot be determined from inputs → route to the unassigned triage queue + flag for review (never guess a team).

## 6. Step 5: Duplicate detection

**Prompt:**
```
Find likely duplicates among the candidate list.

New bug:
- Component: {step1_output.component}
- Summary: {step1_output.summary}
- Class: {step2_output.class}

Candidate bugs (last 90 days, same component):
{candidate_list}

Output JSON only:
{
  "duplicates": [
    { "id": "BUG-123", "score": 0-100, "evidence": "one sentence why this is a duplicate" },
    { "id": "BUG-456", "score": 0-100, "evidence": "..." }
  ],
  "no_duplicates_found": boolean
}

Score on root-cause similarity, not surface text. Return top 3 only.
```

**Schema (output):**
```json
{ "duplicates": [{ "id": "BUG-403", "score": 92, "evidence": "Same endpoint returns discount 0 above the same cart value" }], "no_duplicates_found": false }
```

**Transition:** Final decision object combines all outputs.

**Human checkpoint:** No.

**Error handling:** If no candidates available → `no_duplicates_found: true` and proceed.

## 7. Integration sketch (pseudocode)

```typescript
async function triageBug(rawBug: string, candidates: BugCandidate[]) {
  const step1 = await llm.json(intakePrompt(rawBug));
  if (!step1.component && !step1.summary) {
    return escalate('No usable info in bug description');
  }

  const flags: string[] = [];
  const step2 = await llm.json(classifyPrompt(step1));
  if (step2.confidence === 'low') flags.push('Low confidence classification');

  const step3 = await llm.json(severityPrompt(step1, step2));
  if (isSevConflict(step2, step3)) flags.push('Severity reasoning conflicts with rubric');

  // HUMAN CHECKPOINT: the lead sees the flags and approves or overrides the SEV
  const review = await humanReview({ ...step1, ...step2, ...step3, flags });
  const sev = review.overrideSev ?? step3.sev;

  const step4 = await llm.json(ownerPrompt(step1, step2));
  const step5 = await llm.json(dupePrompt(step1, step2, candidates));

  return {
    structured: { ...step1, ...step2, ...step3, sev, ...step4, ...step5 },
    actions: [
      { type: 'assign', team: step4.team },
      { type: 'set-sev', sev },
      // Only confident matches are linked; 50-79 go to the triage lead as "possible duplicate"
      { type: 'link-dupes', ids: step5.duplicates.filter(d => d.score >= 80).map(d => d.id) },
    ],
  };
}
```

The workflow runs autonomously through Steps 1-2, pauses at the human checkpoint after Step 3, then proceeds through Steps 4-5. Each LLM call gets only the structured data it needs: only Step 1 sees the raw bug text, which also limits how far instructions hidden in a bug report can travel. Low-confidence or conflicting results don't stop the run; they are shown to the human at the checkpoint.

Common pitfalls

  • Model produces a monolithic single prompt instead of distinct steps: defeats the chain benefit.
  • Schemas missing between steps; downstream code can't parse output reliably.
  • Human checkpoint omitted: automation runs unsupervised through the most consequential decision.
  • Error handling glossed; what happens when a step fails to produce valid JSON?

Tips

  • Implement step-by-step in production; validate one before adding the next.
  • Log every step's input + output to a database for later audit and improvement.
  • Pair with `duplicate-bug-detector` to deepen Step 5; this prompt sketches it but doesn't give full reasoning rigor.
  • Add a 'kill switch' env var to disable the workflow during outages of LLM or bug tracker.

FAQ

JIRA / Linear integration?

Both have APIs for create / update / link bugs. Workflow runs as a webhook handler. After Step 5, write the structured decision back to the bug tracker as fields + linked-issue relationships. Subscribe to creation events to trigger.

Human review checkpoints: how many?

Best practice: ONE checkpoint after the most consequential decision (severity). More checkpoints add friction; fewer let mistakes propagate. Start with one; add another only if you see consistent mistakes downstream.

Hallucination mitigation?

Structured output schemas at every step force the model into a narrow output space. Combined with rubric constraints inside prompts, hallucination drops significantly. Still: log everything; review weekly for systematic mistakes.

What if Step 3 conflicts with Step 2?

Build conflict detection (e.g., security bug classified but assigned S4 severity). The error-handling section of each step catches this and escalates to human.