Skip to content
Back to skills

Add Error Handling

ASecurity

Adds real error handling to one function: lists its failure modes, handles each with a clear message and cleans up resources.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agents

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill add-error-handling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Error Handling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Add Error Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-add-error-handling/badge)](https://www.skillsdirectory.com/skills/workspace-templates-add-error-handling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: add-error-handling
description: "Adds real error handling to one function: lists its failure modes, handles each with a clear message and cleans up resources."
argument-hint: "[function name or file:line]"
user-invocable: true
disable-model-invocation: true
---

Add error handling to: $ARGUMENTS

1. Locate the function and read it, its callers and its tests. Note how this codebase reports errors already (exceptions, Result types, error codes, HTTP responses) and copy that style.
2. List every failure mode before editing: invalid input, null or missing data, I/O and network errors, timeouts, partial writes, permission problems, and errors thrown by each dependency.
3. For each one decide: recover, retry with a limit, translate into a domain error, or let it propagate. Say which and why.
4. Write messages that name the operation and the offending value, never secrets or full payloads.
5. Make cleanup unconditional (finally, defer, using, context managers).
6. Never add an empty catch or a blanket catch that hides bugs. Do not change the function's successful behavior.

Add a test for each failure mode that can be triggered. Show the failure table and the diff, run the tests, then ask before changing any caller's signature.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.