Error handling and resiliency audit: exceptions, timeouts, retry policies, circuit breakers, graceful degradation. Run on /audit-errors.
85%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Applies to code with external calls (HTTP, DB, queues, file system), asynchronous code, and event handlers. For synchronous utilities without I/O, return an empty response.
This audit is stack-agnostic: the checks are framed neutrally, and the specifics (tools, idioms, anti-patterns, examples) come from the stack profile.
Profile passed in context? If the /audit orchestrator passed
runtime=<id> and/or the profile contents, use it and skip steps 2–3.
Otherwise, detect EXACTLY ONE runtime for this directory:
if [ -f package.json ]; then echo "runtime=node"
elif [ -f go.mod ]; then echo "runtime=go"
elif [ -f pyproject.toml ] || [ -f requirements.txt ] || [ -f setup.py ]; then echo "runtime=python"
elif [ -f Cargo.toml ]; then echo "runtime=rust"
elif [ -f pom.xml ] || ls build.gradle* settings.gradle* >/dev/null 2>&1; then echo "runtime=java"
else echo "runtime=generic"; fiOne run = one runtime; do not mix backend and frontend. If several markers are found (monorepo), pick the one matching the current scope / files under analysis and record the choice in the Audit Coverage section.
Load the profile via Read: ./skills/audit/stacks/<runtime>.md
(fallback ./skills/audit/stacks/_generic.md if the file is not found).
Then use the profile:
ERR-.tier: general or runtime=generic, mark stack-specific
findings without unambiguous evidence as 🔍 UNVERIFIED rather than ❌ FAIL.
Mark checks whose mechanism is absent in the runtime as N/A.| Severity | Assignment criterion |
|---|---|
| 🔴 Critical | RCE, auth bypass, data corruption, irreversible financial risk |
| 🟠 High | production outage, privilege escalation, data leak |
| 🟡 Medium | performance or maintainability degradation without an immediate outage |
| 🟢 Low | style, readability, minor convention violation |
Rule: severity = impact × exploitability × blast radius. The same pattern → the same severity across audits.
| Check ID | Check |
|---|---|
| ERR-01 | Errors are not swallowed — a returned error is not ignored (including via _), catch blocks handle or rethrow |
| ERR-02 | Internal details (stack trace, paths, versions) do not leak into responses |
| ERR-03 | Failures inside handlers (panics/exceptions) are caught and do not crash the process/connection |
| ERR-04 | Uncaught top-level failures (panics in background tasks) are logged and do not lead to a silent crash |
| ERR-05 | External calls (HTTP client, DB) have explicit timeouts |
| ERR-06 | Graceful shutdown is implemented — SIGTERM is handled |
| ERR-07 | Error responses are consistent in structure across the whole application |
| ERR-08 | Retry strategies use exponential backoff with jitter |
| ERR-09 | A cancellation context is propagated into external calls and aborts them [⚡ dynamic] |
✅ PASS only if you explicitly verified the mechanism (found the schema, config, guard) and confirmed there is no violation — state exactly what was checked.file:line for either a violation or a confirmation, assign 🔍 UNVERIFIED.
[⚡ dynamic] cannot be confirmed statically — only 🔍 UNVERIFIED or ❌ FAIL (with explicit evidence), never ✅ PASSdocs/audit-baseline.yml → ⏸ ACCEPTED.Every ❌ FAIL must include:
file:lineNot allowed:
🔍 UNVERIFIEDAudit results must be written in plain, clear language. Avoid complex terms, jargon, and abstract concepts unless necessary. Common technical terms (Docker, HTTP, API, JSON, URL) are fine. Describe problems so they are understandable to a developer of any level, not only a narrow specialist in the area.
Before analysis:
if [ ! -f ./docs/audit-baseline.yml ]; then
mkdir -p ./docs
cp ./skills/audit/audit-baseline-template.yml ./docs/audit-baseline.yml 2>/dev/null || \
printf "accepted: []\n" > ./docs/audit-baseline.yml
fi
cat ./docs/audit-baseline.ymlThe examples below are illustrative (Node/TS). Take the specifics of the current runtime from the loaded profile (
stacks/<runtime>.md, the Idioms/Anti-patterns/Check-ID hints sections).
ERR-01 — Errors are not swallowed:
_) and not handledcatch(e) {})catch with only a log, without recovery or re-throw.catch(), or try/await without catch_ = f() / v, _ := f() swallows the error; caught by errcheck/golangci-lintERR-02 — Internal details not in responses:
ERR-03 — Failures inside handlers are caught:
middleware.Recoverer), no RecoverFunc in gqlgen, no recover in the task wrapper (asynq) — a panic crashes the connection/processERR-04 — Uncaught top-level failures:
process.on('unhandledRejection')process.on('uncaughtException')defer recover() crashes the whole process — a defer recover() is needed in every goroutineERR-05 — Explicit timeouts for external calls:
http.Client{Timeout: ...}, context.WithTimeout for requests to the DB/external servicesERR-06 — Graceful shutdown:
signal.NotifyContext + server.Shutdown(ctx) + closing pools (pgx), workers (asynq), redisERR-07 — Consistent error response structure:
Retry & Cancellation (ERR-08 / ERR-09):
context.Context is the first-class cancellation mechanism, propagated into all external calls (pgx/HTTP/asynq)audit-owasp and audit-api-contracts refer here.audit-concurrency (CON-05). Do not duplicate here.audit-performance does not duplicate it.| Check ID | Check | Status | Confidence | Evidence | Solution | Fixed |
|---|---|---|---|---|---|---|
| ERR-01 | Errors are not swallowed — a returned error is not ignored (including via _), catch blocks handle or rethrow | ✅ PASS | High | src/ — all catch blocks log or rethrow | — | — |
| ERR-05 | External calls (HTTP client, DB) have explicit timeouts | ❌ FAIL 🟠 | High | services/api.ts:18 | 1. Add a timeout to axios: { timeout: 5000 } \ 2. Use an AbortController with setTimeout \ 3. Set a global default timeout | No |
| ERR-06 | Graceful shutdown is implemented — SIGTERM is handled | ⏸ ACCEPTED | Medium | server.ts:5 | In baseline: managed by the orchestrator | — |
Statuses: ✅ PASS / ❌ FAIL 🔴 / ❌ FAIL 🟠 / ❌ FAIL 🟡 / ❌ FAIL 🟢 / ⏸ ACCEPTED / 🔍 UNVERIFIED
Confidence: High — checked several key files, the pattern is obvious / Medium — checked selectively, the pattern is likely / Low — limited context, full certainty is impossible
For ❌ FAIL: exactly 3 solution options, separated by \\, with option 1 in bold.
Fixed: FAIL → No (the developer changes it to ✅ Yes manually after the fix). PASS / ACCEPTED / UNVERIFIED → —.
Solution requirements:
At the end of the report, add a coverage section:
## Audit Coverage
Checked: src/module1/**, src/module2/**
Skipped: scripts/**, migrations/**, tests/**
Files checked: N | Skipped: NIf everything is PASS, output: ✅ Error handling is implemented correctly.
ls -dt ./docs/audits/[0-9]*/ 2>/dev/null | head -1 | sed 's|/$||'mkdir -p ./docs/audits/$(date +"%Y-%m-%d_%H-%M")<AUDIT_DIR>/audit-errors.md# Audit Report: Error Handling & Resiliency — <YYYY-MM-DD HH:MM>
<table>uxname/kodu
db733be
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.