Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:52:14 +08:00
commit 5aa901f301
16 changed files with 1105 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# Assets
Bundled resources for api-error-handler skill
- [ ] error_response_template.json: A JSON template for consistent error responses.
- [ ] error_code_prefix_mapping.json: A mapping of error code prefixes to specific API modules or services.

View File

@@ -0,0 +1,32 @@
{
"skill": {
"name": "skill-name",
"version": "1.0.0",
"enabled": true,
"settings": {
"verbose": false,
"autoActivate": true,
"toolRestrictions": true
}
},
"triggers": {
"keywords": [
"example-trigger-1",
"example-trigger-2"
],
"patterns": []
},
"tools": {
"allowed": [
"Read",
"Grep",
"Bash"
],
"restricted": []
},
"metadata": {
"author": "Plugin Author",
"category": "general",
"tags": []
}
}

View File

@@ -0,0 +1,68 @@
{
"_comment": "Mapping of error code prefixes to API modules/services. Used for determining the origin and handling strategy for different error types.",
"mappings": {
"AUTH": {
"_comment": "Authentication-related errors",
"module": "AuthenticationService",
"http_status_code": 401,
"description": "Errors related to user authentication, authorization, or session management.",
"handling_strategy": "Retry with re-authentication if possible, otherwise log and return a 401 Unauthorized error."
},
"USER": {
"_comment": "User management errors",
"module": "UserService",
"http_status_code": 400,
"description": "Errors related to user creation, modification, or deletion.",
"handling_strategy": "Return a 400 Bad Request error with specific details about the invalid user data or operation."
},
"PROD": {
"_comment": "Product catalog errors",
"module": "ProductCatalogService",
"http_status_code": 500,
"description": "Errors related to retrieving or managing product information.",
"handling_strategy": "Retry a limited number of times. If still failing, log the error and return a 500 Internal Server Error with a generic message. Monitor for widespread issues."
},
"ORD": {
"_comment": "Order processing errors",
"module": "OrderProcessingService",
"http_status_code": 409,
"description": "Errors related to order placement, modification, or fulfillment.",
"handling_strategy": "Return a 409 Conflict error if the order is in an invalid state. For other errors, attempt to automatically correct the order if possible, otherwise notify support and return a 500 Internal Server Error."
},
"PAY": {
"_comment": "Payment processing errors",
"module": "PaymentGatewayService",
"http_status_code": 402,
"description": "Errors related to payment authorization, capture, or refund.",
"handling_strategy": "Return a 402 Payment Required error. Provide specific instructions to the user on how to resolve the payment issue."
},
"RATE": {
"_comment": "Rate limiting errors",
"module": "RateLimiter",
"http_status_code": 429,
"description": "Errors indicating that the client has exceeded their rate limit.",
"handling_strategy": "Return a 429 Too Many Requests error with a 'Retry-After' header indicating when the client can retry."
},
"DATA": {
"_comment": "Data validation or database errors",
"module": "DatabaseService",
"http_status_code": 503,
"description": "Errors related to accessing or manipulating data in the database. Includes validation failures.",
"handling_strategy": "Retry database operations with exponential backoff. If persistent, return a 503 Service Unavailable error, indicating a temporary issue. Alert the database administrators."
},
"INTEG": {
"_comment": "Integration errors with external services",
"module": "IntegrationService",
"http_status_code": 502,
"description": "Errors encountered when communicating with external APIs or services.",
"handling_strategy": "Implement circuit breaker pattern to prevent cascading failures. Return a 502 Bad Gateway error if the external service is unavailable."
},
"NOTF": {
"_comment": "Notification service errors",
"module": "NotificationService",
"http_status_code": 500,
"description": "Errors related to sending emails, SMS messages, or push notifications.",
"handling_strategy": "Queue failed notifications for retry. Log errors and monitor for persistent failures. Return a 500 Internal Server Error to the client, indicating a temporary issue with notifications."
}
}
}

View File

@@ -0,0 +1,56 @@
{
"_comment": "Template for a standardized error response.",
"error": {
"_comment": "Top-level key indicating an error occurred.",
"code": "ERR_INVALID_INPUT",
"_comment": "A unique error code for programmatic handling. Should be stable and not change even if the message changes.",
"message": "Invalid input provided.",
"_comment": "A human-readable error message. Should be helpful to the user.",
"status": 400,
"_comment": "The HTTP status code associated with the error.",
"details": {
"_comment": "Optional details about the error. Can be an object or an array.",
"field": "email",
"issue": "Email address is not valid."
},
"timestamp": "2024-10-27T10:00:00Z",
"_comment": "Timestamp of when the error occurred (ISO 8601 format)."
},
"_comment": "Example of a different error scenario (Internal Server Error)",
"example_internal_server_error": {
"error": {
"code": "ERR_INTERNAL_SERVER_ERROR",
"message": "An unexpected error occurred on the server.",
"status": 500,
"details": {
"_comment": "This can be omitted or contain sensitive information that should not be exposed to the client.",
"errorId": "a1b2c3d4e5f6g7h8"
},
"timestamp": "2024-10-27T10:01:00Z"
}
},
"_comment": "Example of a different error scenario (Unauthorized)",
"example_unauthorized": {
"error": {
"code": "ERR_UNAUTHORIZED",
"message": "Unauthorized: Invalid credentials.",
"status": 401,
"details": null,
"_comment": "Details are often omitted for unauthorized errors.",
"timestamp": "2024-10-27T10:02:00Z"
}
},
"_comment": "Example of a different error scenario (Not Found)",
"example_not_found": {
"error": {
"code": "ERR_NOT_FOUND",
"message": "Resource not found.",
"status": 404,
"details": {
"resource": "user",
"id": "123"
},
"timestamp": "2024-10-27T10:03:00Z"
}
}
}

View File

@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Claude Skill Configuration",
"type": "object",
"required": ["name", "description"],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z0-9-]+$",
"maxLength": 64,
"description": "Skill identifier (lowercase, hyphens only)"
},
"description": {
"type": "string",
"maxLength": 1024,
"description": "What the skill does and when to use it"
},
"allowed-tools": {
"type": "string",
"description": "Comma-separated list of allowed tools"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$",
"description": "Semantic version (x.y.z)"
}
}
}

View File

@@ -0,0 +1,27 @@
{
"testCases": [
{
"name": "Basic activation test",
"input": "trigger phrase example",
"expected": {
"activated": true,
"toolsUsed": ["Read", "Grep"],
"success": true
}
},
{
"name": "Complex workflow test",
"input": "multi-step trigger example",
"expected": {
"activated": true,
"steps": 3,
"toolsUsed": ["Read", "Write", "Bash"],
"success": true
}
}
],
"fixtures": {
"sampleInput": "example data",
"expectedOutput": "processed result"
}
}