smithery.ai

patterns

Project patterns including functional options, must pattern, caching decorator, error handling, configuration, and HTTP clients. Use when implementing common patterns in the codebase.

First seen Mar 20, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,592 B
  • docs SUMMARY.md 199 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 5 installs

SKILL.md

Project Patterns

References: [Examples](examples.md)

Functional Options

[Example](examples.md#functional-options)

Use With* functions for configurable constructors:

func NewClient(baseURL string, options ...ClientOption) *Client {
    opts := defaultOptions()
    for _, option := range options {
        option(opts)
    }
    // create client...
}

client := NewClient(url, WithTimeout(30*time.Second), WithRetryCount(3))

Must Pattern

[Example](examples.md#must-pattern)

Allowed only in cmd/, internal/apps/ - to fail fast on misconfiguration.

func Must[T any](f func() (T, error)) T {
    v, err := f()
    if err != nil { panic(err) }
    return v
}

Caching Decorator

[Example](examples.md#caching-decorator)

Wrap clients with cache layer for transparent caching.

Error Handling

[Example](examples.md#error-handling)

Rule Example
Wrap with context fmt.Errorf("get order %s: %w", id, err)
Check with Is/As errors.Is(err, ErrNotFound)
Handle once Don't log AND return
Custom errors var ErrFoo = errors.New() or type FooError struct{}

Configuration

[Example](examples.md#configuration)

Type Path
App config config/appconfig/{env}.json
Infra config config/appconfig/infra-{env}.json
SSM /myservice/{env}/app/config

Rules: No ARNs in app config, no secrets in files, use time.Duration with custom unmarshaler

HTTP Client with Retry

[Example](examples.md#http-client)

client := tracing.NewRestyClient(baseURL,
    tracing.WithTimeout(30*time.Second),
    tracing.WithRetryCount(3),
    tracing.WithExponentialBackoff(true),
)

DynamoDB Key Design

[Example](examples.md#dynamodb)

Use composite keys (PK + SK), GSIs for query patterns.

Feature Flags

[Example](examples.md#feature-flags)

Fallback defaults, check at service layer, log evaluations.

JSON Tags

[Example](examples.md#json-tags)

Use camelCase for JSON tags and query params.

Request Validation

[Example](examples.md#validation)

Use ozzo-validation for struct validation.

Libraries

Library Purpose
chi HTTP router
samber/lo Collections/utilities
ozzo-validation Validation
resty HTTP client