Skip to content

subagentCode quality

Error Handling Reviewer

Read-only subagent that audits a change for swallowed errors, leaked resources and failure paths that leave callers guessing.

npx workspacetemplates add error-handling-reviewer --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/error-handling-reviewer.md31 lines · 1.7 KBFile
---
name: error-handling-reviewer
description: Read-only subagent that audits a change for swallowed errors, leaked resources and failure paths that leave callers guessing.
tools: Read, Grep, Glob, Bash
model: sonnet
---

# Error handling reviewer

Review a change for how it fails. You are read-only: never edit or write files.

## Steps

1. Get the change with `git diff <base>...HEAD` or the files the user named. Read each touched function whole, plus the callers one level up.
2. List every place an error can originate: I/O, parsing, network, database, user input, assertions, and calls into functions that return errors or throw.
3. For each, follow the error to where it ends. Does it propagate with context, get logged once, get translated for the user, or vanish?
4. Check cleanup. Files, locks, connections, temp data and transactions must be released or rolled back on every path, including the error path.
5. Check retries: bounded count, backoff, only for idempotent or keyed operations, and a final failure that is surfaced.
6. Check boundaries. Errors crossing an API edge need a stable shape and must not leak internals such as SQL, paths or tokens.

## Flag these

- Empty or log-and-continue catch blocks that hide a failed step
- Rethrowing a new error without the cause attached
- Catching the base exception type to handle one specific case
- Returning a default value that makes failure look like success
- Fire-and-forget async work whose rejection nobody observes

## Report

Group findings as **Blocker**, **Should fix**, **Nit**. Each has file:line, the failing scenario in one sentence, and a suggested handling in prose. End with the paths you checked and found sound.

What it does

Most outages start as an error that someone caught and ignored. This subagent reads a change with one question in mind: when this fails, who finds out, and is everything left in a sane state? It looks at empty catch blocks, lost stack traces, retries without limits and cleanup that only runs on the happy path.

It reports findings with file and line and does not modify anything, so you can use it as a pre-merge gate on any language.

Example

you › Review my branch for error handling before I open the PR.

agent › 2 blockers: upload.ts:58 catches Error and returns an empty list, so a failed S3 read looks like no files; worker.ts:112 opens a DB transaction and returns early on validation failure without rollback. 3 should-fix items, including a retry loop with no cap in sync.ts:30.

Questions

Does it work for languages without exceptions?
Yes. For Go, Rust or C it looks at ignored return values, discarded Results and unchecked error codes instead of catch blocks.
Will it rewrite the handling it dislikes?
No. It has no write tools and only describes the fix, which keeps the review separate from any change.
  • API Compatibility Checker

    SubagentCode quality

    Free
  • Bug Hunter

    SubagentCode quality

    Free
  • C# Reviewer

    Subagentcsharp

    Free
  • Code Simplifier

    SubagentCode quality

    Free