errors

Define and register typed error codes with HTTP status mappings for TypeScript and Go bounded contexts.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill errors-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: errors
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/errors
Command: npx skills add https://github.com/gabriellst/codm --skill errors-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Backend services need consistent, structured error handling where every domain or application failure maps to a stable error code, an HTTP status, and a frontend translation. Without a registry pattern, ad-hoc errors silently fall through to HTTP 500 and leak inconsistent responses across handlers. ## Core Features & Use Cases - Runtime error registry: Core exposes registerErrorCodes (TypeScript) and RegisterErrorCodes (Go); each bounded context plugs in its own codes at startup without core ever importing from contexts. - Language-specific playbooks: A dispatch hub routes to the TypeScript variant (type unions, BaseError<T> generics, side-effect imports in registry.ts) or the Go variant (typed errors.ErrorCode consts, init() registration, anonymous imports in module.go). - Pattern and bad-practice registries: registry.yaml files codify mandatory patterns (ERR-01 through ERR-P10, ERR-GO-01 through ERR-GO-05) and mechanical detection rules for violations like unregistered codes or fmt.Errorf misuse. - Use Case: When adding a new INVOICE_NOT_FOUND error to a billing context, the skill guides declaring the typed code, registering its 404 status, wiring the side-effect import, and adding frontend translations in pt.json and en.json. ## Quick Start Ask the agent to define and register a new domain or application error code for a specific bounded context, and it will follow the TypeScript or Go playbook matching the file you are editing.

Frequently Asked Questions about errors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom error code with an HTTP status in a Go service?

Declare a typed constant like `CodeJobNotFound errors.ErrorCode = "JOB_NOT_FOUND"` in `internal/<ctx>/errors/codes.go`, then register it inside `init()` via `errors.RegisterErrorCodes` with the desired `net/http` status. Add a blank import of the errors package in `module.go` so `init()` runs at startup.

How do I register error types in a TypeScript DDD backend?

Define context-prefixed union types extending `BaseDomainErrors` and `BaseApplicationErrors` in `<context>/errors/index.ts`, then call `registerErrorCodes({...})` at the bottom of the same file. The context's `registry.ts` must value-import `./errors` so the side-effect actually executes.

Why does my custom error code return HTTP 500 instead of 404?

Unregistered codes fall through to 500 in both languages. In Go, the `init()` registration is missing or the blank import in `module.go` is absent; in TypeScript, `registerErrorCodes` was never called or `registry.ts` only type-imports `./errors`, which is erased at runtime.

Should I use fmt.Errorf or errors.NewBaseError for business errors in Go?

Use `errors.NewBaseError(ctxerrors.CodeX, "message")` for all domain and application errors. Plain `fmt.Errorf` produces errors the HTTP mapper cannot unwrap, so the intended status code is lost and the response defaults to 500.

When should I not create a new custom error code?

Skip new codes for validation failures already handled by Zod schemas or Go `validate` struct tags, infrastructure panics caught by the framework, and cases covered by existing core codes like `CodeNotFound` or `CodeUnauthorized`, which should be reused directly.

Do backend error codes need frontend translations?

Yes, in the TypeScript stack every error code must have entries under the `"errors"` key in both `packages/app/react/src/locales/pt.json` and `en.json`. The frontend resolves messages via `getErrorTranslation`, so missing translations surface raw codes to users.