golang-fullstack-error-handling
Skill15 starsChanged 9 months agoMITView on GitHub
Unified Go + GORM + PostgreSQL error handling review. Covers error wrapping, context propagation, PostgreSQL error codes (23505, 40001), errors.Is/As mapping, and retry logic. Ensures proper error chains and robust database failure recovery.
In this repository9 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Use this skill when:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 patternsDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

