Error Shape Taxonomy
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Organization-wide standard error response format covering error codes, categories, and structure that enables clients and monitoring tools to understand errors immediately.
Why This Matters
- Debuggability: รู้ทันทีว่า error มาจากไหน ทำไม
- Client handling: Frontend/mobile handle errors ได้ถูกต้อง
- Monitoring: Alert และ dashboard แยก error types ได้
- Documentation: Error catalog ที่ reference ได้
Core Concepts
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
- Depends on: None
- Compatible with: None
- Conflicts with: None
- Related Skills: None
Quick Start
export type ErrorCategory = "AUTH" | "AUTHZ" | "VAL" | "BIZ" | "RATE" | "SYS";
export interface ErrorResponse {
error: {
code: string;
category: ErrorCategory;
message: string;
status: number;
requestId: string;
timestamp: string;
path?: string;
method?: string;
retryable?: boolean;
retryAfterSeconds?: number;
details?: Record<string, unknown>;
validationErrors?: Array<{ field: string; reason: string }>;
};
}
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns
- Generic errors: "Something went wrong"
- Leaking internals: Stack traces to client
- Inconsistent shape: Different format per service
- Missing correlation: No request ID
- Changing meaning: เปลี่ยน semantics ของ code เดิม ทำให้ client/alert พัง
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: error-shape-taxonomy3description: Organization-wide standard error response format covering error codes, Use when this capability is needed.4---56# Error Shape Taxonomy78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Organization-wide standard error response format covering error codes, categories, and structure that enables clients and monitoring tools to understand errors immediately.1819## Why This Matters20- **Debuggability**: รู้ทันทีว่า error มาจากไหน ทำไม21- **Client handling**: Frontend/mobile handle errors ได้ถูกต้อง22- **Monitoring**: Alert และ dashboard แยก error types ได้23- **Documentation**: Error catalog ที่ reference ได้2425---2627## Core Concepts28#2930## Inputs / Outputs / Contracts31* **Inputs**:32 - <e.g., env vars, request payload, file paths, schema>33* **Entry Conditions**:34 - <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>35* **Outputs**:36 - <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>37* **Artifacts Required (Deliverables)**:38 - <e.g., Code Diff, Unit Tests, Migration Script, API Docs>39* **Acceptance Evidence**:40 - <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>41* **Success Criteria**:42 - <e.g., p95 < 300ms, coverage ≥ 80%>4344## Skill Composition45* **Depends on**: None46* **Compatible with**: None47* **Conflicts with**: None48* **Related Skills**: None4950## Quick Start51```typescript52export type ErrorCategory = "AUTH" | "AUTHZ" | "VAL" | "BIZ" | "RATE" | "SYS";5354export interface ErrorResponse {55 error: {56 code: string;57 category: ErrorCategory;58 message: string;59 status: number;60 requestId: string;61 timestamp: string;62 path?: string;63 method?: string;64 retryable?: boolean;65 retryAfterSeconds?: number;66 details?: Record<string, unknown>;67 validationErrors?: Array<{ field: string; reason: string }>;68 };69}70```7172## Assumptions / Constraints / Non-goals7374* **Assumptions**:75 - Development environment is properly configured76 - Required dependencies are available77 - Team has basic understanding of domain78* **Constraints**:79 - Must follow existing codebase conventions80 - Time and resource limitations81 - Compatibility requirements82* **Non-goals**:83 - This skill does not cover edge cases outside scope84 - Not a replacement for formal training858687## Compatibility & Prerequisites8889* **Supported Versions**:90 - Python 3.8+91 - Node.js 16+92 - Modern browsers (Chrome, Firefox, Safari, Edge)93* **Required AI Tools**:94 - Code editor (VS Code recommended)95 - Testing framework appropriate for language96 - Version control (Git)97* **Dependencies**:98 - Language-specific package manager99 - Build tools100 - Testing libraries101* **Environment Setup**:102 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)103104105## Test Scenario Matrix (QA Strategy)106107| Type | Focus Area | Required Scenarios / Mocks |108| :--- | :--- | :--- |109| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |110| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |111| **E2E** | User Journey | Critical user flows to test |112| **Performance** | Latency / Load | Benchmark requirements |113| **Security** | Vuln / Auth | SAST/DAST or dependency audit |114| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |115116117## Technical Guardrails & Security Threat Model118119### 1. Security & Privacy (Threat Model)120* **Top Threats**: Injection attacks, authentication bypass, data exposure121- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII122- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager123- [ ] **Authorization**: Validate user permissions before state changes124125### 2. Performance & Resources126- [ ] **Execution Efficiency**: Consider time complexity for algorithms127- [ ] **Memory Management**: Use streams/pagination for large data128- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks129130### 3. Architecture & Scalability131- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection132- [ ] **Modularity**: Decouple logic from UI/Frameworks133134### 4. Observability & Reliability135- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`136- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`137- [ ] **Error Handling**: Standardized error codes, no bare except138- [ ] **Observability Artifacts**:139 - **Log Fields**: timestamp, level, message, request_id140 - **Metrics**: request_count, error_count, response_time141 - **Dashboards/Alerts**: High Error Rate > 5%142143144## Agent Directives & Error Recovery145*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*146147- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.148- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.149- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.150- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.151152153## Definition of Done (DoD) Checklist154155- [ ] Tests passed + coverage met156- [ ] Lint/Typecheck passed157- [ ] Logging/Metrics/Trace implemented158- [ ] Security checks passed159- [ ] Documentation/Changelog updated160- [ ] Accessibility/Performance requirements met (if frontend)161162163## Anti-patterns1641. **Generic errors**: "Something went wrong"1652. **Leaking internals**: Stack traces to client1663. **Inconsistent shape**: Different format per service1674. **Missing correlation**: No request ID1685. **Changing meaning**: เปลี่ยน semantics ของ code เดิม ทำให้ client/alert พัง169170## Reference Links & Examples171172* Internal documentation and examples173* Official documentation and best practices174* Community resources and discussions175176177## Versioning & Changelog178179* **Version**: 1.0.0180* **Changelog**:181 - 2026-02-22: Initial version with complete template structure182183---184> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.185<!-- tomevault:4.0:skill_md:2026-04-13 -->