cleanup-defensive

Solid

Remove pointless try/catch blocks and defensive guards that hide errors or add no value. Preserves catches at true system boundaries (HTTP handlers, CLI entry, message consumers). Use when the user asks to remove try/catch, fix error hiding, clean up defensive code, or stop swallowing errors. Example queries — "remove pointless try/catch", "we're swallowing errors", "stop hiding bugs in catch blocks", "clean up the defensive code".

AI & Automation 78 stars 9 forks Updated today MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
63
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

Remove try/catch and defensive null-checks that don't serve a real role. The goal is errors that propagate cleanly to the boundary that knows how to handle them, not silent fallbacks that hide bugs. **Core principle**: catch only when you can do something more useful than the default propagation — and "log and rethrow" is rarely more useful than just letting it throw. ## Preflight 1. **Language detect**: TS/JS, Python, Go (`if err != nil` patterns), Rust (`unwrap_or`/`map_err` chains that smell defensive). 2. **Git state**: refuse on dirty tree. 3. **Report dir**: ensure exists. 4. **Identify boundary files** — preserve catches in: - HTTP request handlers (`app/api/`, `routes/`, Hono/Express/FastAPI handlers) - CLI entry points (files with `if __name__ == "__main__"`, `bin/*`, `cmd/*`) - Message/queue consumers (worker entry points, cron handlers) - Test files (test runners need failures localized) ## Detect ### TypeScript / JavaScript ```bash # Find every try/catch grep -rn --include="*.ts" --include="*.tsx" --include="*.js" -B1 -A5 "try {" \ --exclude-dir=node_modules --exclude-dir=.next . > /tmp/try-catches.txt # ESLint can flag the obvious useless ones npx eslint --rule '{"no-useless-catch": "error"}' --no-eslintrc . 2>&1 | grep no-useless-catch > /tmp/useless-catch.txt ``` Categorize each catch block by content: - **Rethrow only**: `catch (e) { throw e }` or `catch (e) { throw new Error(...) }` with no context added - **Swallow + null/empty return**:...

Details

Author
raintree-technology
Repository
raintree-technology/agent-starter
Created
7 months ago
Last Updated
today
Language
JavaScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category