Audit Error Boundaries and Telemetry Coverage in Code

This prompt audits your codebase for missing error boundaries, unhandled promise rejections, and incomplete telemetry traces to ensure production stability.

Agent prompt for Claude

Prompt

Prompt
You are a senior software reliability engineer. Audit the pasted code for robustness and observability. Apply these rules: 1. Identify all functions that lack a try-catch block or error boundary. 2. Flag any promise chains missing a .catch handler. 3. Check for logs that include sensitive user data like emails or tokens. 4. Verify that each major flow includes a span start and end for tracing. Output format: # Audit Findings ## High Risk Items (List with specific line numbers and risk description) ## Observability Gaps (List missing trace points) ## Recommendations (Specific refactoring steps) This is not professional legal or security advice; consult a certified security professional for production infrastructure audits. Paste your code below.

Example output

Audit findings for the auth serviceIssues found in the login token example
High risk items
2
Unhandled fetch rejection and email in logs
Observability gaps
2
Missing spans and no DB timeout event
Recommendations
4
Try-catch, log masking, spans, error events

Example for: a user authentication service handling login tokens.

Audit Findings

High Risk Items

  • Line 42: The fetch request to the auth provider lacks a try-catch block, risking an unhandled promise rejection if the network fails.
  • Line 58: The user email address is passed directly to the logger. This creates a data privacy risk if logs are stored in plain text.

Observability Gaps

  • The login function lacks a start span at line 30 and an end span at line 70, making it impossible to measure total latency for the authentication flow.
  • No error event is emitted to the telemetry provider when the database connection times out at line 45.

Recommendations

  • Wrap the network request in a standard try-catch block and implement a custom ErrorBoundary component for the UI layer.
  • Implement a masking utility for the logger to redact the email field before it hits the log stream.
  • Initialize a span at the entry point of the function using the OpenTelemetry SDK and ensure it closes in the finally block to guarantee trace completion regardless of outcome.
  • Add a dedicated error event emitter that includes the error code and trace ID to allow for faster debugging in production dashboards.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces a structured review of failure points like unhandled promises.
  • Prioritizes data security by flagging unredacted logs in plain text.
  • Ensures observability standards by checking for span lifecycle management.

Use this prompt when preparing a pull request or refactoring critical user flows. It works best in Claude or Claude Code by pasting a specific module or service file directly into the chat. Review all suggestions before applying them to your production environment.

Common edits

  • Add specific compliance standards if working in a regulated industry.
  • Expand the scope to include database query timeout checks if applicable.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

More in Claude Code
Agent OrchestrationClaude

Triage Dead-Letter Queue Logs for Failed AI Agents

Sort unhandled agent run failures into an actionable classification table separating tool downtime, invalid schema calls, and missing user context.

Agent Orchestration

Create Error Handling Contracts for AI Agents

This prompt transforms raw stack traces into structured error envelopes that provide agents with specific remediation steps and valid parameter constraints for self-correction.

Agent OrchestrationClaude

Design Idempotent API Tool Schemas and Retry Policies

Generate robust JSON tool schemas for AI agents that enforce idempotency, define safe retry status codes, and specify clear error recovery strategies for external APIs.

Coding

Find the failing line in a stack trace

Isolate your application code from noisy framework trace logs and explain the root runtime crash. Use it when debugging confusing error logs.

Audit API Route Handlers for Auth and Permission Leaks

Get a structured security audit of your API route handlers that evaluates tenant isolation, role-based access control, and input validation risks.