Back to Skills

golang-samber-oops

Structured error handling in Golang with samber/oops — error builders, stack traces, error codes, error context, error wrapping, error attributes, user-facing vs developer messages, panic recovery, and logger integration. Apply when using or adopting samber/oops, or when the codebase already imports github.com/samber/oops.

1,807stars118forksUpdated 5/24/2026

Security Assessment

Safe(100/100)
Security Score100/100

About golang-samber-oops

The golang-samber-oops skill provides guidance for implementing structured error handling in Golang applications using the github.com/samber/oops library. It addresses the limitations of standard Go errors by enriching errors with structured metadata, stack traces, machine-readable error codes, user-safe messages, and contextual attributes that persist throughout the call stack. The skill promotes treating errors as structured operational data rather than plain strings, helping developers and on-call engineers diagnose production issues more efficiently while improving observability and error grouping in monitoring platforms.

The skill focuses on the fluent builder pattern used by samber/oops for creating and managing errors. It covers capabilities such as adding structured key-value attributes with `.With()`, attaching service or domain information with `.In()`, categorizing errors with `.Tags()`, defining machine-readable identifiers through `.Code()`, separating public-facing messages from technical details using `.Public()`, and enriching errors with hints, ownership metadata, tenant context, user context, and trace identifiers. It also documents terminal operations including creating new errors, wrapping existing errors, joining multiple errors, and converting panics into errors through recovery helpers. The guidance emphasizes low-cardinality error messages by storing variable values in attributes rather than interpolating them directly into messages.

This skill is intended for Go engineers, backend developers, platform teams, and AI coding agents working on Golang projects that already use or plan to adopt samber/oops. It is especially useful in distributed systems, APIs, microservices, and production environments where structured observability, debugging efficiency, and consistent error reporting are critical. Teams integrating with logging systems, APM platforms, or incident-response workflows can use this skill to standardize error handling practices across services while improving maintainability and operational visibility.

FAQ

What problem does samber/oops solve in Go applications?

It improves standard Go error handling by adding structured context, stack traces, error codes, user-safe messages, and persistent attributes that travel with the error across the call stack.

How are variable values supposed to be attached to errors?

Variable data should be stored in structured attributes using methods like `.With()` instead of being embedded directly into the error message string. This helps monitoring and APM tools group errors correctly.

What types of error operations are supported?

The library supports creating new errors, wrapping existing errors, joining multiple errors, and recovering from panics using fluent builder methods and terminal operations such as `.Errorf()`, `.Wrap()`, `.Wrapf()`, `.Join()`, and `.Recover()`.

Is this skill compatible with standard Golang projects?

Yes. The skill is designed for Golang projects that use or plan to use the github.com/samber/oops package and is compatible with Claude Code or similar AI coding agents.

Does the skill include complete coverage of the samber/oops library?

No. The skill provides structured guidance and common usage patterns, but it is not exhaustive. Users are encouraged to consult the official library documentation and examples for additional details.

All Files

3 files
evals/evals.json12.7 KB
View
SKILL.md9.8 KB
View
references/advanced.md1.3 KB
View

Install golang-samber-oops

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill