Install
$ agentstack add skill-saifoelloh-golang-best-practices-skill-error-handling ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Error Handling (Unified Go & DB)
Expert-level review for error handling in Go services using GORM and PostgreSQL. Ensures errors are correctly identified, preserved via wrapping, mapped to domain errors, and retried where appropriate.
When to Apply
Use this skill when:
- Reviewing general Go error propagation and context usage
- Debugging database errors (e.g., duplicate keys, serialization failures)
- Auditing error wrapping with
%wvs%v - Ensuring correct use of
errors.Is/errors.As - Adding retry logic for serializable transactions or deadlocks
Rule Categories
| Priority | Count | Focus | |---|---|---| | CRITICAL | 6 | error chains, context leaks, PgError mapping, retries | | HIGH | 6 | propagation, Is/As usage, RowsAffected, deadlock detection | | MEDIUM | 2 | sentinel errors, structured logging |
Rules Covered (14 total)
Critical Issues (6)
critical-error-wrapping— Use%w, not%v, to preserve error chainscritical-context-leak— Alwaysdefer cancel()after context creationcritical-error-shadow— Don't shadowerrin nested scopescritical-errors-is-as— Useerrors.Is/Asfor DB and wrapped errorscritical-pg-error-mapping— Map Postgres codes to domain errors at repo boundarycritical-serialization-retry— Retry transactions on40001serialization failure
High-Impact Patterns (6)
high-context-propagation— Propagate context through the call chainhigh-error-is-as— Prescriptive rule for using Is/As over string matchinghigh-interface-nil— Check for nil in interfaces correctlyhigh-rows-affected— CheckRowsAffectedafter Update/Deletehigh-wrap-with-context— Wrap DB errors with operation contexthigh-deadlock-detection— Handle40P01deadlocks as retryable
Medium Improvements (2)
medium-sentinel-error-usage— Use sentinel errors for stable categoriesmedium-structured-logging— Log DB/Go errors with structured fields
Trigger Phrases
- "Review error handling"
- "Debug this DB error"
- "23505 / 40001 / 40P01"
- "Check for context leaks"
- "Review error chains"
- "Transaction retry"
- "ErrRecordNotFound"
Output Format
## Critical Issues Found: X
### [Rule ID] (Line Y)
**Issue**: Description
**Impact**: Context leak / Lost chain / Data inconsistency
**Fix**: Suggested code
**Example**:
```go
// Corrected code
## Related Skills
- [gorm-query-patterns](../gorm-query-patterns/SKILL.md) — For `.Error` check safety
- [concurrency-safety](../concurrency-safety/SKILL.md) — For context timeout patterns
## Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- **Author:** [saifoelloh](https://github.com/saifoelloh)
- **Source:** [saifoelloh/golang-best-practices-skill](https://github.com/saifoelloh/golang-best-practices-skill)
- **License:** MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.