AI Fix Suggestions
Glassbrain's AI suggestion engine analyzes your error traces and generates actionable fix suggestions - complete with code diffs showing exactly what to change. Powered by Claude, the engine understands your stack trace, error context, and application metadata to produce targeted, high-quality fixes.
How Suggestions Work
When you request a fix suggestion for a trace, Glassbrain sends the trace data to its AI engine. The engine performs the following analysis:
- Error classification - identifies the category of error (type error, null reference, async handling, API contract violation, etc.)
- Stack trace analysis - pinpoints the exact file, line, and function where the error originated
- Context extraction - examines the metadata, input values, and surrounding code context to understand why the error occurred
- Fix generation - produces one or more code changes that address the root cause, along with an explanation and confidence score
The engine typically generates between one and three suggestions per trace, ranked by confidence score. Higher confidence suggestions address clear, well-understood error patterns. Lower confidence suggestions may address ambiguous cases where multiple fixes could be appropriate.
Suggestion Structure
Each suggestion returned by the engine follows a consistent structure:
{
"id": "sug_m1n2o3p4q5r6",
"trace_id": "trc_a1b2c3d4e5f6",
"title": "Add null check before mapping users array",
"description": "The error occurs because the 'users' prop is null when the component renders. The .map() method is called on a null value, which throws a TypeError. Adding a null check with a fallback to an empty array prevents the error and handles the loading state gracefully.",
"code_diff": "--- a/components/UserList.tsx\n+++ b/components/UserList.tsx\n@@ -12,7 +12,7 @@\n export function UserList({ users }: UserListProps) {\n return (\n <ul>\n- {users.map((user) => (\n+ {(users ?? []).map((user) => (\n <li key={user.id}>{user.name}</li>\n ))}\n </ul>",
"confidence": 0.94,
"file_path": "components/UserList.tsx",
"line_start": 15,
"line_end": 15,
"created_at": "2026-04-03T10:25:12.000Z"
}| Field | Type | Description |
|---|---|---|
| id | string | Unique suggestion identifier, prefixed with sug_ |
| trace_id | string | The trace this suggestion was generated for |
| title | string | Short, actionable summary of the fix |
| description | string | Detailed explanation of the problem and how the fix addresses it |
| code_diff | string | Unified diff format showing the before and after code change |
| confidence | number | Score between 0 and 1 indicating the engine's confidence in the fix |
| file_path | string | The file where the change should be applied |
| line_start | number | Starting line number of the affected code |
| line_end | number | Ending line number of the affected code |
| created_at | string | ISO 8601 timestamp of when the suggestion was generated |
Requesting Suggestions
Via the Dashboard
Open any error trace in your project dashboard and click the "Get AI Fix" button in the trace detail panel. Glassbrain will analyze the trace and display suggestions within a few seconds. Each suggestion appears as a card showing the title, confidence score, and a preview of the code diff.
For traces that already have suggestions, the suggestions are cached and displayed immediately without re-analysis.
Via the API
Request suggestions programmatically by sending a POST request to the suggestions endpoint:
curl -X POST https://glassbrain.dev/api/v1/suggestions \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"trace_id": "trc_a1b2c3d4e5f6"
}'400 font-semibold">const response = 400 font-semibold">await fetch(400 font-semibold">class="text-emerald-400">"https:400 font-semibold">class="text-[rgba(255,255,255,0.3)] italic">//glassbrain.dev/api/v1/suggestions", {
method: 400 font-semibold">class="text-emerald-400">"POST",
headers: {
400 font-semibold">class="text-emerald-400">"Content-Type": 400 font-semibold">class="text-emerald-400">"application/json",
400 font-semibold">class="text-emerald-400">"x-api-key": process.env.GLASSBRAIN_API_KEY!,
},
body: JSON.stringify({
trace_id: 400 font-semibold">class="text-emerald-400">"trc_a1b2c3d4e5f6",
}),
});
400 font-semibold">const data = 400 font-semibold">await response.json();
400 font-semibold">class="text-[rgba(255,255,255,0.3)] italic">// data.suggestions is an array 400 font-semibold">of suggestion objects
console.log(data.suggestions[0].title);
console.log(data.suggestions[0].confidence);The API returns suggestions within 5-15 seconds depending on trace complexity. See the API Reference for the full request and response specification.
Reviewing and Applying Suggestions
Each suggestion includes a diff view showing the exact code change. Review the diff carefully before applying - the AI engine produces high-quality suggestions, but you should always verify that the change is appropriate for your specific codebase.
When reviewing a suggestion, consider:
- Confidence score - suggestions with scores above 0.85 typically require minimal review. Scores below 0.60 may need more careful evaluation.
- Side effects - check whether the suggested change could affect other parts of your application that depend on the modified code.
- Edge cases - the suggestion addresses the specific error in the trace, but consider whether it handles other edge cases your code may encounter.
To apply a suggestion, click the "Copy Diff" button to copy the unified diff to your clipboard, then apply it to your codebase using git apply or your editor's patch functionality. You can also manually make the change based on the diff.
Plan Limits
AI fix suggestions are available on all plans with the following monthly limits:
| Plan | Suggestions per Month |
|---|---|
| Free | 10 |
| Pro | Unlimited |
| Team | Unlimited |
| Business | Unlimited |
When you reach your monthly limit on the Free plan, suggestion requests return a 429 status code. Your limit resets on the first day of each calendar month. Upgrade to any paid plan for unlimited suggestions.