Agent Skills
› AjayIrkal23/agentic-mercy-10x
› backend-error-handling
backend-error-handling
GitHub规范后端错误处理,定义统一错误信封、状态码映射及集中式处理器。确保内部异常不暴露给客户端,强制安全日志记录与敏感信息脱敏,实现结构化、可预测的错误响应体系。
触发场景
定义或审查后端错误类
将领域错误映射到 HTTP 状态码
设计集中式错误处理逻辑
审查安全日志和脱敏行为
安装
npx skills add AjayIrkal23/agentic-mercy-10x --skill backend-error-handling -g -y
SKILL.md
Frontmatter
{
"name": "backend-error-handling",
"schema": 1,
"category": "backend",
"surfaces": [
"backend"
],
"triggers": {
"paths": [],
"intents": [
"backend"
],
"keywords": [
"backend",
"behavior",
"centralized",
"client-safe",
"defining",
"error",
"handler",
"handling",
"logging",
"mapping",
"redaction",
"safe",
"taxonomy"
]
},
"platforms": [
"linux",
"darwin",
"windows"
],
"token-cost": 482,
"description": "ALWAYS invoke when defining backend error taxonomy, centralized handler behavior, safe logging, redaction, or client-safe error mapping.",
"disable-model-invocation": false
}
Backend Error Handling
Overview
Backend failures must be structured, safe, and predictable.
This skill owns the error taxonomy, centralized handler behavior, and the rule that clients never see raw internal failures.
Use When
- Defining or reviewing backend error classes.
- Mapping domain errors to HTTP status codes.
- Designing centralized error handling.
- Reviewing safe logging and redaction behavior.
Do Not Use
- Service/controller boundary questions by themselves.
- API query semantics by themselves.
- Performance tuning without error-handling impact.
Standard Error Envelope
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Safe user-facing message",
"details": {}
}
}
Rules:
successmust befalseerror.codeis requiredmessagemust be safe for clientsdetailsis optional and should stay narrow
Status Code Rules
400validation401unauthorized403forbidden404not found409conflict429rate limited500internal error
Centralized Handler Rules
- Normalize internal errors into the public error envelope.
- Log safely.
- Hide stack traces and internal implementation details from clients.
- Keep controllers from building ad hoc error payloads unless they are only delegating to a shared formatter.
Service Rules
- Services throw typed domain errors.
- Services do not send transport responses.
- Services do not swallow failures silently.
Logging Rules
- Log enough context to debug.
- Do not log secrets, tokens, or sensitive payloads carelessly.
- Redact internal details before anything can surface to clients.
Combine With
api-contract-standardsfor envelope compatibility.service-layer-standardsfor where errors should originate.
References
- Use
references/full-guide.mdfor the longer strict version with class patterns and more detailed rules.
版本历史
- 581d130 当前 2026-07-19 09:04


