Back to cookbook

AI Prompt to Triage Production Errors Using Sentry's MCP Server

0 views Updated

Make this prompt yours

Share

This AI prompt is for developers and on-call engineers who connect an AI assistant to Sentry's MCP server and want a fast, consistent first pass on a batch of error reports instead of clicking through each issue manually. Once MCP exposes issue details, stack traces, affected release, and event counts, the prompt tells the model how to group related errors, judge severity, and separate what needs an immediate fix from what can wait.

The prompt deliberately avoids asking the model to "just fix the bug." Stack traces from production often point to a symptom, not the root cause, so the prompt asks for a grounded read of what the trace actually shows, which function or file is implicated, and how confident that read is, rather than a guessed fix that sounds plausible but may be wrong for an issue the model hasn't fully traced through the codebase.

Because Sentry issue payloads can be long and repetitive across similar errors, especially when the same exception fires from multiple call sites, feeding every field into the model without pruning can get expensive fast on large error batches. Running the retrieved payload through Token Optimizer before triage, to strip redundant stack frames and duplicate context, keeps the prompt focused on what's actually needed to triage severity.

Prompt template

Make this prompt yours

prompt-template
342 tokens
ROLE: You are a software engineer triaging production error reports retrieved through Sentry's MCP integration. CONTEXT: - Project: [PROJECT NAME] - Time window: [E.G. LAST 24 HOURS] - Current release/deploy: [VERSION, DEPLOY TIME] - Known pre-existing low-priority issues to exclude: [LIST OR 'NONE'] TASK: 1. Retrieve open issues for the specified project and time window via the MCP connection, including stack trace, event count, affected users, and first-seen timestamp. 2. Group issues that share the same root exception type and call path as a single item. 3. For each grouped issue, state what the stack trace shows is happening, which file/function is implicated, and your confidence level in that read (high/medium/low). 4. Rank issues by severity using event count, affected user count, and whether first-seen falls after the stated deploy time. 5. Exclude any issue listed as a known pre-existing low-priority issue, but note it was excluded. CONSTRAINTS: - Do not propose a specific code fix; describe what the trace indicates and flag it for the responsible engineer. - Do not rank an issue as high severity solely because of the error message tone; use the stated metrics. - If stack trace data is incomplete or truncated, say so instead of inferring the missing frames. OUTPUT FORMAT: - Triage Summary (total issues reviewed, number flagged as new since deploy) - Ranked Issue List (issue title, severity, event count, affected users, confidence in root cause read) - Excluded Known Issues (if any) - Issues Needing Manual Trace Review (low-confidence reads)

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
64 tokens
Review open issues in the 'checkout-service' project from the last 24 hours. We deployed v2.14.0 at 2026-10-12 09:00 UTC. Exclude the known 'PaymentGatewayTimeout' issue, which is a pre-existing low-priority item we already track separately.

When to use it

  • You're starting a shift and need a quick severity-ranked view of overnight Sentry issues
  • A new release just shipped and you want new or spiking errors flagged before they pile up
  • You're deciding which of several open issues to assign first and need a reasoned priority order
  • You want a plain-language summary of a stack trace to share with a non-engineering stakeholder

Best practices

  • Give the model the actual release version and rollout time so it can tell newly introduced errors from pre-existing ones
  • Ask it to state its confidence in identifying the root cause separately from the severity ranking
  • List any known, already-tracked low-priority issues so the model excludes them instead of re-flagging them
  • Have it group duplicate errors from different call sites into one item instead of listing each occurrence separately

Common mistakes

  • Asking the model to propose a code fix directly from a stack trace without having it read the actual implicated file first
  • Not providing release or deploy timing, so the model can't tell a new regression from a long-standing low-priority error
  • Treating every error with a high event count as automatically high severity, even when it's a known, harmless edge case
  • Skipping a check of the top 2-3 flagged issues against the raw Sentry data before escalating them

FAQs

Can an AI assistant actually read my Sentry issues without me copying stack traces manually?

Only if it's connected through Sentry's MCP server or a similar integration. Without that connection, you'd still need to paste in the issue data yourself.

Should I let the model's severity ranking override my own on-call judgment?

No. Treat it as a fast first pass that uses the metrics you gave it, not a replacement for engineering judgment, especially for issues the model flagged as low-confidence on root cause.

Why does this prompt ask the model not to suggest a code fix?

A stack trace alone often shows a symptom, not the actual root cause in your codebase. Having the model guess a fix without reading the implicated file risks a plausible-sounding but wrong suggestion.

How can I check this prompt's quality before running it against a live Sentry project?

Intelligence Score — run your filled-in version through it to catch vague constraints or missing context before you point it at real production data.

Found this prompt useful? Share it.

Share

More in Code Generation & Software Engineering

Code Generation & Software Engineering

AI Prompt to Review Pull Requests for Bugs and Security Using GitHub's MCP Server

This prompt gives developers and engineering leads a repeatable way to review pull requests for bugs, security issues, and style problems by…

Role: You are a senior code reviewer with access to a GitHub MCP connection.

Context:
- Repository: [REPO_NAME]
- Pull request: [PR_NUMBER]
- Primary language/framework: [LANGUAGE_OR_FRAMEWORK]
- Team coding standards: [LIST_KEY_STANDARDS_OR_LINT_RULES]

Task:
1. Pull the current diff, changed file list, and CI status for the specified pull request.
2. Review the changes for: functional bugs, security issues (e.g. unvalidated input, hardcoded secrets, injection risks), and violations of the team's coding standards.
3. Note any missing or inadequate test coverage for the changed code.

Constraints:
- Base feedback only on the actual diff and files pulled from the repository, not assumptions about unseen code.
- Separate findings into "Blocking" and "Suggestion" categories.
- Reference the specific file and line number for each finding.
- Do not approve, merge, or close the pull request; this review is advisory only.

Output format:
- Summary: one paragraph on overall PR readiness
- Blocking issues: bulleted list with file:line and explanation
- Suggestions: bulleted list with file:line and explanation
- Test coverage notes: bulleted list

Make this prompt yours

Code Generation & Software Engineering

AI Prompt to Generate API Documentation From Source Code

This AI prompt for API documentation turns a block of source code (a function, a class, a set of REST route handlers) into clear, structured…

ROLE: You are a technical writer who specializes in developer-facing API documentation.

CONTEXT:
Language/framework: [PROGRAMMING LANGUAGE AND FRAMEWORK, e.g., Python/FastAPI]
Code to document:
[PASTE THE FULL FUNCTION, CLASS, OR ROUTE HANDLER HERE]
Audience: [e.g., external API consumers / internal engineering team / open-source contributors]

TASK:
Document the code above. Base every statement only on what the code actually does — do not assume standard behavior that isn't present in the code itself.

For each function or endpoint, produce:
1. SUMMARY: one sentence describing its purpose
2. PARAMETERS: name, type, whether required or optional, and what it's used for
3. RETURNS: the type and shape of the return value or response
4. ERRORS: every distinct error condition present in the code (exceptions raised, non-success status codes, validation failures), with the exact trigger condition
5. EXAMPLE: a realistic call or request with sample input and the resulting output

CONSTRAINTS:
- If a parameter's type or default value is ambiguous in the code, flag it as [NEEDS CLARIFICATION] rather than guessing
- Do not add a 'notes' or 'best practices' section unless explicitly asked
- Keep the summary to one sentence

OUTPUT FORMAT:
Return the documentation in [MARKDOWN / JSON / OPENAPI YAML] using this exact section order: Summary, Parameters, Returns, Errors, Example.

Make this prompt yours

Code Generation & Software Engineering

Prompt to Generate Unit Tests From a Function

This prompt turns an existing function into a set of unit tests covering its normal behavior, edge cases, and error handling, built for deve…

You are a senior software engineer writing unit tests.

Function to test:
[PASTE THE FUNCTION CODE]

Language and test framework: [E.G. TYPESCRIPT WITH VITEST, PYTHON WITH PYTEST]

Instructions:
1. Write tests covering normal, expected inputs.
2. Write tests covering edge cases: empty input, null/undefined, boundary values.
3. Write tests covering any error conditions the function should raise or handle.
4. Use clear, descriptive test names that state what is being verified.
5. Return only the test code, in a single code block, ready to run.

Output format: one fenced code block containing the complete test file.

Make this prompt yours