error-handler
Design integration error classification, retry strategies, and dead-letter handling for insurance and financial services system integrations.
What this skill does
# Error Handler
Produce a complete error handling design for a system integration. Every error category gets an explicit retry strategy, escalation path, and resolution workflow. The output is the technical specification a developer implements in the integration layer.
## Error Taxonomy
Classify every possible error into one of three categories. The category determines the retry strategy.
### Category 1: Transient Errors (Retry Eligible)
The error is temporary. The operation will likely succeed if retried.
| Error Type | HTTP Status | Example | Detection Method |
|-----------|-------------|---------|-----------------|
| Rate limit exceeded | 429 | API throttled | HTTP status + Retry-After header |
| Service temporarily unavailable | 503 | Destination system down for maintenance | HTTP status |
| Network timeout | — | Connection timed out after 30s | Exception: ConnectTimeoutError, ReadTimeoutError |
| Gateway timeout | 504 | Reverse proxy upstream timeout | HTTP status |
| Service overloaded | 500 with "retry" in body | Some APIs return 500 for transient overload | HTTP status + body inspection |
| Database deadlock | — | SQL deadlock on destination DB write | Exception: SqlException with error code 1205 |
**Retry strategy for transient errors**:
```
Algorithm: Exponential backoff with full jitter
base_delay = 1 second
max_delay = 60 seconds
max_attempts = 5
jitter = random(0, base_delay)
wait_time(attempt) = min(base_delay * 2^attempt + jitter, max_delay)
Attempt 1: 0s (immediate)
Attempt 2: ~2s (base*2 + jitter)
Attempt 3: ~4s (base*4 + jitter)
Attempt 4: ~8s (base*8 + jitter)
Attempt 5: ~16s (base*16 + jitter)
After attempt 5: Send to dead-letter queue
```
**Rate limit (429) special handling**: If the response includes a `Retry-After` header, use that value instead of the exponential backoff calculation. The `Retry-After` value is authoritative.
### Category 2: Permanent Errors (Do Not Retry)
The operation will fail regardless of how many times it is retried. Retrying wastes resources and delays detection.
| Error Type | HTTP Status | Example | Action |
|-----------|-------------|---------|--------|
| Validation failure | 400, 422 | Required field missing, invalid format | Send to exception queue for manual correction |
| Record not found | 404 | Foreign key reference points to non-existent record | Log, skip record, increment missing-reference counter |
| Duplicate record | 409 | Policy already exists in destination | Check for existing record, update instead of create |
| Authorization failure | 403 | API key lacks permission for this endpoint | Alert admin — permission configuration issue, not data issue |
| Schema mismatch | 400 | API contract changed, field rejected | Alert integration team — API upgrade may be needed |
| Business rule violation | 422 with specific error code | Destination rejects policy date in past | Send to exception queue, notify business team |
**Duplicate record (409) handling**:
```
On 409 response:
1. Extract the existing record identifier from the 409 response body
2. Issue a GET request to fetch the existing record
3. Compare key fields: if destination record matches source, mark as "already synced" and continue
4. If destination record differs, issue a PUT/PATCH to update the existing record
5. If update succeeds: log "409 resolved via update"
6. If update fails: send to exception queue
```
### Category 3: Business Errors (Route to Exception Queue)
The operation is technically valid but cannot be processed automatically due to a business rule or data quality issue.
| Error Type | Example | Exception Queue Category |
|-----------|---------|------------------------|
| Missing required reference | Policy references an unknown producer NPI | "Unknown Reference" |
| Data quality issue | Client name is blank, required by destination | "Data Quality" |
| Authorization mismatch | Policy for a client from a different agency than expected | "Business Rule Violation" |
| Out-of-bounds value | Premium amount is negative | "Data Quality" |
| Duplicate natural key | Policy number already exists with different data | "Duplicate — Requires Review" |
## Retry Implementation
### Retry Pseudocode
```typescript
async function withRetry<T>(
operation: () => Promise<T>,
config: RetryConfig
): Promise<T> {
let lastError: Error;
for (let attempt = 0; attempt <= config.maxAttempts; attempt++) {
try {
return await operation();
} catch (error) {
lastError = error;
const errorCategory = classifyError(error);
if (errorCategory !== ErrorCategory.TRANSIENT) {
// Non-transient: do not retry
throw new NonRetryableError(error, errorCategory);
}
if (attempt === config.maxAttempts) {
// Exhausted retries
throw new RetriesExhaustedError(error, attempt);
}
const delay = calculateBackoff(attempt, config, error);
logger.warn('Transient error, retrying', { attempt, delay, error: error.message });
await sleep(delay);
}
}
throw lastError!;
}
function calculateBackoff(attempt: number, config: RetryConfig, error: Error): number {
// Respect Retry-After header if present
if (error instanceof ApiError && error.retryAfterSeconds) {
return error.retryAfterSeconds * 1000;
}
const exponential = config.baseDelayMs * Math.pow(2, attempt);
const jitter = Math.random() * config.baseDelayMs;
return Math.min(exponential + jitter, config.maxDelayMs);
}
```
### Error Classification
```typescript
enum ErrorCategory {
TRANSIENT = 'TRANSIENT',
PERMANENT = 'PERMANENT',
BUSINESS = 'BUSINESS'
}
function classifyError(error: unknown): ErrorCategory {
if (error instanceof ApiError) {
if ([429, 503, 504].includes(error.status)) return ErrorCategory.TRANSIENT;
if (error.status === 500 && error.body?.includes('retry')) return ErrorCategory.TRANSIENT;
if ([400, 403, 422].includes(error.status)) return ErrorCategory.PERMANENT;
if (error.status === 409) return ErrorCategory.PERMANENT; // handled separately
if (error.status === 404) return ErrorCategory.PERMANENT;
}
if (error instanceof NetworkError) return ErrorCategory.TRANSIENT;
if (error instanceof ValidationError) return ErrorCategory.PERMANENT;
if (error instanceof BusinessRuleError) return ErrorCategory.BUSINESS;
// Unknown errors: treat as transient for safety, but cap at 2 retries
return ErrorCategory.TRANSIENT;
}
```
## Dead-Letter Queue Design
The DLQ is the landing zone for records that failed all retry attempts. It must support manual review and reprocessing.
**DLQ storage**: SharePoint list (for small integrations) or Azure Table Storage (for high-volume integrations).
**DLQ schema**:
| Column | Type | Description |
|--------|------|-------------|
| RecordId | Text | Auto-generated GUID |
| IntegrationName | Text | Which integration produced this DLQ entry |
| SourceSystem | Text | |
| DestinationSystem | Text | |
| OperationType | Choice | Create / Update / Delete / Sync |
| ErrorTimestamp | DateTime | When the final failure occurred |
| ErrorCategory | Choice | Transient-Exhausted / Permanent / Business |
| ErrorCode | Text | HTTP status or exception type |
| ErrorMessage | Text | Full error message (truncated to 2000 chars) |
| AttemptCount | Integer | Total attempts made |
| SourceRecordId | Text | ID of the record in the source system |
| SourcePayload | Multiline text | JSON payload sent to destination (redacted if contains PII) |
| ResponseBody | Multiline text | Response from destination system |
| Status | Choice | New / Under Investigation / Resolved / Discarded |
| AssignedTo | Person | |
| ResolutionNotes | Multiline text | How it was resolved |
| ResolvedAt | DateTime | |
**PII redaction in DLQ**: Before storing the SourcePayload, redact sensitive fields (SSN, account numbers, dates of birth). Replace with `[REDACTED]`. Store only enough context to identify and repRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.