> ## Documentation Index
> Fetch the complete documentation index at: https://docs.traceback.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Root Cause Analysis

> Instant diagnosis and pull-request ready fix suggestions powered by LLM code reasoning.

When an incident triggers in production, Traceback's AI engine automatically analyzes the crash telemetry to synthesize a root-cause explanation and remediation diff.

## How AI Diagnosis Works

1. **Context Aggregation**: The engine collects the symbolicated stack trace, enclosing code blocks, recent git commit diffs, telemetry span watermarks, and preceding breadcrumbs.
2. **Failure Classification**: The error is classified by category (e.g., race condition, missing null check, schema mismatch, unhandled API rejection).
3. **Patch Generation**: An actionable unified diff patch is generated against the offending repository branch.

***

## Example AI Summary

<Card title="AI Diagnostic Report" icon="sparkles">
  **Root Cause Summary**:
  The function `calculateDiscount` in `src/pricing/discounts.ts` threw a `TypeError: Cannot read properties of undefined (reading 'percentage')` because `tierConfig` was fetched without checking for newly added customer tier `'enterprise_custom'`.

  **Suggested Fix**:

  ```diff theme={null}
  - const discount = user.tierConfig.percentage ?? 0;
  + const discount = user.tierConfig?.percentage ?? 0;
  ```
</Card>

***

## Linking Your Code Repository

To enable repository-aware AI analysis:

1. Navigate to **Project Settings > Integrations > GitHub / GitLab**.
2. Grant repository read permissions.
3. Traceback will automatically link crash lines to exact repository commits and branches.
