This loop standardizes API error responses across the application to improve client-side error handling and debugging. It ensures all error responses follow a consistent structure (e.g., RFC 7807 Problem Details format) with appropriate HTTP status codes and machine-readable error codes.
Standardize API error responses
Run this loop in your coding agent to standardize API error responses. The agent will analyze current errors, implement a unified response format, apply it across all endpoints, and validate through automated tests.
Start the Loop Agent
Paste the kickoff prompt into your preferred coding agent (Cursor, Claude Code, etc.) to begin the standardization process.
Execute Check Command
After each iteration, run 'npm run test:api-errors' to validate error response consistency and structure.
Iterate Until Exit Condition
The agent will self-pace through analysis, implementation, and testing until all error validation tests pass or maximum iterations are reached.
Step 1
Review all existing error handling code to identify inconsistencies in structure, status codes, and error messages.
Step 2
Implement a centralized error handler or middleware that formats all API errors according to the chosen standard (e.g., RFC 7807).
API
Automatically detects and resolves issues in failing API integration endpoints through iterative testing and code modifications.
API
A coding loop focused on optimizing API performance to ensure P95 latency stays under a defined target threshold. This loop iteratively runs load tests, analyzes bottlenecks, and implements optimizations until the goal is achieved or maximum iterations are reached.
API
Automatically identifies and documents all undocumented API endpoints in the project. The agent iteratively generates OpenAPI/Swagger documentation until all endpoints meet the required documentation standards.
Step 3
Update all route handlers and catch blocks to use the new standardized error response format.
Step 4
Execute 'npm run test:api-errors' to verify that all error responses meet the required format and contain necessary information.
Step 5
Ensure the standardized approach handles all error scenarios including validation failures, authentication issues, and server errors.
Start the "Resolve API Error Responses" loop. Goal: Standardize API error responses Max iterations: 10 Between iterations run: npm run test:api-errors Exit when: Error validation tests pass Analyze the current API error handling in this codebase. Create a standardized error response format following RFC 7807 Problem Details specification. Apply this format consistently across all API endpoints and error scenarios. Run 'npm run test:api-errors' to validate your implementation. Continue iterating until all error validation tests pass. Self-pace this loop. After each iteration, run `npm run test:api-errors` and evaluate the output, and only continue if the exit condition is not met (Error validation tests pass). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.