Skip to content
Back to skills

Sentinel

ASecurity

Define package-level sentinel errors using errors.New

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 7, 2026
developmentgoapi

Works with

  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add JamesPrial/claudefiles --skill sentinel --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sentinel?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sentinel
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jamesprial-sentinel/badge)](https://www.skillsdirectory.com/skills/jamesprial-sentinel)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: go-sentinel-errors
description: Define package-level sentinel errors using errors.New
---

# Sentinel Errors

## Pattern
Define package-level errors as exported variables for expected error conditions.

## CORRECT
```go
package user

import "errors"

// Sentinel errors - define at package level
var (
    ErrNotFound      = errors.New("user not found")
    ErrInvalidEmail  = errors.New("invalid email format")
    ErrDuplicate     = errors.New("user already exists")
)

func Get(id int) (*User, error) {
    u, ok := db[id]
    if !ok {
        return nil, ErrNotFound
    }
    return u, nil
}
```

## WRONG
```go
// Bad: Creates new error each time (can't use errors.Is)
func Get(id int) (*User, error) {
    if _, ok := db[id]; !ok {
        return nil, errors.New("user not found")
    }
    return db[id], nil
}

// Bad: String comparison is fragile
if err.Error() == "user not found" { }
```

## Naming Convention
- Prefix with `Err`
- Use camel case: `ErrNotFound`, not `ERR_NOT_FOUND`
- Be specific: `ErrInvalidEmail`, not `ErrBadInput`

## When to Use
Use sentinel errors for:
- Expected business logic errors
- Public API boundaries
- Conditions callers need to handle differently

Avoid for:
- Unexpected/rare conditions
- Internal implementation details

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.