Provides battle-tested error handling patterns for TypeScript and Python. Use when implementing error handling, creating try/catch blocks, or handling exceptions.
Implements battle-tested error handling patterns for TypeScript and Python. Use when creating try/catch blocks, handling exceptions, or building robust error systems with custom error classes and proper logging.
/plugin marketplace add benshapyro/cadre-devkit-claude/plugin install benshapyro-cadre-devkit-claude@benshapyro/cadre-devkit-claudeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/python-patterns.mdreferences/typescript-patterns.mdImplements robust error handling patterns that provide meaningful errors, graceful degradation, and proper logging.
For detailed code examples, see:
references/typescript-patterns.md - TypeScript/JavaScript patterns (Express, React)references/python-patterns.md - Python patterns (FastAPI, Flask)export class AppError extends Error {
constructor(
message: string,
public code: string,
public statusCode: number = 500,
public context?: Record<string, unknown>
) {
super(message);
this.name = this.constructor.name;
}
}
// Specific types
export class ValidationError extends AppError {
constructor(message: string, context?: Record<string, unknown>) {
super(message, 'VALIDATION_ERROR', 400, context);
}
}
export class NotFoundError extends AppError {
constructor(resource: string, id: string) {
super(`${resource} not found`, 'NOT_FOUND', 404, { resource, id });
}
}
class AppError(Exception):
def __init__(self, message: str, code: str, status_code: int = 500, context: dict | None = None):
super().__init__(message)
self.message = message
self.code = code
self.status_code = status_code
self.context = context or {}
class ValidationError(AppError):
def __init__(self, message: str, context: dict | None = None):
super().__init__(message, "VALIDATION_ERROR", 400, context)
async function fetchData(id: string): Promise<Data> {
if (!id) throw new ValidationError('Invalid ID', { id });
try {
const data = await db.find(id);
if (!data) throw new NotFoundError('Data', id);
return data;
} catch (error) {
if (error instanceof AppError) throw error;
throw new DatabaseError('Fetch failed', { id, originalError: error.message });
}
}
catch (e) {}){
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": [{ "field": "email", "message": "Invalid format" }]
}
}
Remember: Good error handling prevents debugging nightmares and provides a better user experience.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.