Code review
AuraScore 85/100

Defensive API Contract and Error Handling Review Framework

Audit external-facing service contracts, input validation, and failure-handling strategies for resilience.

Apply this prompt when reviewing new API endpoints or webhook consumers. It generates an actionable review framework to guarantee predictable error envelopes, input validation, and idempotent failure handling.

Template

Role: Lead Platform Reliability Engineer specializing in resilient microservice interface design.

Context

  • Endpoint name: {{api_endpoint_name}}
  • Protocol type: {{protocol_type}}
  • Consuming clients: {{client_consumers}}
  • Code implementation: {{code_implementation}}
  • Target availability SLA: {{sla_target}}
  • Upstream retry policy: {{retry_policy}}

Task

Produce an API resilience and error handling review framework that audits {{api_endpoint_name}} for defensive contract enforcement, fault isolation, and safe retry behaviors in line with {{sla_target}}.

Method

  1. Parse {{code_implementation}} for boundary validation, payload bounds checking, and schema enforcement.
  2. Trace all upstream external calls to verify appropriate timeout and circuit breaking configurations.
  3. Audit error propagation logic to ensure internal exception traces never leak through the {{protocol_type}} interface.
  4. Evaluate idempotency mechanisms for mutating endpoints under repetitive requests matching {{retry_policy}}.
  5. Inspect status code mappings and structured error envelopes for consistency across {{client_consumers}}.
  6. Review fallback routines and partial degradation paths when downstream dependencies fail.
  7. Formulate defensive coding standards and error payload specifications for the endpoint.

Constraints

  • MUST validate idempotency handling for all non-safe HTTP/RPC methods.
  • MUST NOT permit raw database or runtime stack traces in public error envelopes.
  • Recommendations must preserve compliance with {{sla_target}}.
  • All error contracts must define structured machine-readable error codes.

Output format

  • Contract Resilience Analysis (2 paragraphs)
  • Error Handling Deficiency Matrix (Markdown table: Error Path, Current Behavior, Failure Risk, Defensive Standard)
  • Standardized Error Envelope Schema (JSON/Schema definition)
  • Client Resilience and Retry Guidance (Technical specification for {{client_consumers}})

Self-review

  • Ensure input validation edge cases (e.g., payload size, malformed types) are addressed.
  • Confirm error envelope masking conforms to security requirements for {{client_consumers}}.
  • Check that idempotency controls withstand replay scenarios under {{retry_policy}}.
AuraScore breakdown
85/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-code-review
software-engineering-debugging
api-design
reliability
error-handling