Agent skill

Golang Samber Do

by context-labs in context-labs/whip

Dependency injection in Go using samber/do — service containers, lifecycle, scopes, health checks, graceful shutdown, module organization.

MITAuto-check passedDevelopment

Install Golang Samber Do

skills CLI
$ npx skills add context-labs/whip --skill golang-samber-do -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install context-labs/whip golang-samber-do --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/context-labs/whip.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/golang-samber-do .claude/skills/golang-samber-do && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
golang-samber-do
GitHub stars
1.1k
Used in
1 other repo
Token cost
~2.3k tokens
SKILL.md length
615 words
Files
4 (incl. references)
Skills in repo
40
Repo updated
First seen
Licence
MIT

At a glance

Dependency injection in Go using samber/do — service containers, lifecycle, scopes, health checks, graceful shutdown, module organization.

  • Works in 5 steps: Define and Register Services → Invoke Services → Service Dependencies → …
  • Tasks that involve Design patterns
  • SKILL.md covers Core Concepts, Basic Usage, Package Organization and Full Application Setup, plus 3 more sections
  • Calls go

What it does

Golang Samber Do is an agent skill from context-labs/whip. Dependency injection in Go using samber/do — service containers, lifecycle, scopes, health checks, graceful shutdown, module organization. Apply when using or adopting samber/do, when the codebase imports github.com/samber/do(/v2), or when refactoring constructor injection into a DI container.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `evals/evals.json`, `references/advanced.md` and `references/testing.md`). Compatibility notes: Designed for Claude Code, Codex or similar harness, and for projects using Golang.

It sits in Development, covering Design patterns and Refactoring. It works with Go and GitHub. The repository describes itself as: A fast coding-agent harness in Go. Tool-use loop, bubbletea TUI, provider-routable models with live catalog discovery, MCP support, background subagents. One binary, no runtime… The licence is MIT.

When your agent uses it

  • Tasks that involve Design patterns
  • Tasks that involve Refactoring

Example prompts

  • “/golang-samber-do”

Requirements

  • Compatibility (from SKILL.md): Designed for Claude Code, Codex or similar harness, and for projects using Golang.
  • Pre-approved tools (allowed-tools): Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent, WebFetch, mcp__context7__resolve-library-id, mcp__context7__query-docs, Bash(godig:*), Bash(gopls:*), LSP, mcp__gopls__*

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Define and Register Services
  2. Invoke Services
  3. Service Dependencies
  4. Implicit Aliasing (Preferred)
  5. Named Services

What it can do on your machine

Read from SKILL.md and the folder at commit 8876467. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Edit
    • Write
    • Glob
    • Grep
    • Bash(go:*)
    • Bash(golangci-lint:*)
    • Bash(git:*)
    • Agent
    • WebFetch

    …and 6 more on the same allowed-tools line.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • go

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • pkg.go.dev
    • do.samber.dev
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code, Codex or similar harness, and for projects using Golang.

    From compatibility in the SKILL.md frontmatter.

Context cost

Golang Samber Do loads about 2.3k tokens when it runs, and up to ~3.9k if it reads all its reference files. Until then it costs about 78 tokens; SKILL.md has 615 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~78
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from context-labs/whip at commit 8876467, republished under its MIT licence (© context-labs). 615 words, ~2,268 tokens.

Download SKILL.mdSave it as .claude/skills/golang-samber-do/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
golang-samber-do
description
Dependency injection in Go using samber/do — service containers, lifecycle, scopes, health checks, graceful shutdown, module organization. Apply when using or adopting samber/do, when the codebase imports github.com/samber/do(/v2), or when refactoring constructor injection into a DI container.
allowed-tools
Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent, WebFetch, mcp__context7__resolve-library-id, mcp__context7__query-docs, Bash(godig:*), Bash(gopls:*), LSP, mcp__gopls__*
compatibility
Designed for Claude Code, Codex or similar harness, and for projects using Golang.
user-invocable
true
license
MIT
metadata.author
samber
metadata.version
1.3.0
paths
**/*.go

Persona: You are a Go architect setting up dependency injection. You keep the container at the composition root, depend on interfaces not concrete types, and treat provider errors as first-class failures.

Using samber/do for Dependency Injection in Go

Type-safe dependency injection toolkit for Go based on Go 1.18+ generics.

Official Resources:

This skill is not exhaustive. Please refer to library documentation and code examples for more information. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See samber/cc-skills-golang@golang-pkg-go-dev skill (godig) — prefer it over Context7 for Go package facts. To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See samber/cc-skills-golang@golang-gopls skill (gopls). Context7 remains a fallback for docs not indexed on pkg.go.dev.

DO NOT USE v1 OF THIS LIBRARY. INSTALL v2 INSTEAD:

bash
go get -u github.com/samber/do/v2

Core Concepts

The Injector (Container)
go
import "github.com/samber/do/v2"

injector := do.New()
Service Types
  • Lazy (default): Created when first requested
  • Eager: Created immediately when the container starts
  • Transient: New instance created on every request
  • Value: Pre-created value, no instantiation
Provider Functions

Services MUST be registered via provider functions:

go
type Provider[T any] func(i Injector) (T, error)

Basic Usage

1. Define and Register Services

Follow "Accept Interfaces, Return Structs":

go
// Register a service (lazy by default)
do.Provide(injector, func(i do.Injector) (Database, error) {
    return &PostgreSQLDatabase{connString: "postgres://..."}, nil
})

// Register a pre-created value
do.ProvideValue(injector, &Config{Port: 8080})

// Register a transient service (new instance each time)
do.ProvideTransient(injector, func(i do.Injector) (*Logger, error) {
    return &Logger{}, nil
})

// Register an eager service (created immediately at startup)
do.ProvideValue(injector, &Config{Port: 8080})
2. Invoke Services

The container MUST only be accessed at the composition root:

go
// Invoke with error handling — reserve for call sites outside the DI graph
// (e.g. an HTTP handler that must degrade gracefully instead of crashing)
db, err := do.Invoke[Database](injector)

// MustInvoke panics on error — preferred in providers, recovered by do.Invoke on the parent call
db := do.MustInvoke[Database](injector)

Inside a provider function, always use do.MustInvoke (or MustInvokeAs/MustInvokeNamed/MustInvokeStruct) rather than the error-returning variant. A provider already returns (T, error), so propagating a dependency failure with do.Invoke costs an extra if err != nil { return nil, err } on every call. do.MustInvoke panics instead, but samber/do correctly catches and recovers that panic at the enclosing Invoke call and converts it back into a regular error — this recover happens inside the library itself, not in caller code, so MustInvoke is safe to use inside providers. The failure still surfaces as an error at the composition root, just without the manual boilerplate in every provider.

3. Service Dependencies
go
func NewUserService(i do.Injector) (UserService, error) {
    db := do.MustInvoke[Database](i)
    cache := do.MustInvoke[Cache](i)
    return &userService{db: db, cache: cache}, nil
}

do.Provide(injector, NewUserService)
4. Implicit Aliasing (Preferred)

Register a concrete type and invoke as an interface without explicit aliasing:

go
// Register concrete type
do.Provide(injector, func(i do.Injector) (*PostgreSQLDatabase, error) {
    return &PostgreSQLDatabase{}, nil
})

// Invoke directly as interface (implicit aliasing)
db := do.MustInvokeAs[Database](injector)
5. Named Services

Register multiple services of the same type:

go
do.ProvideNamed(injector, "primary-db", func(i do.Injector) (*Database, error) {
    return &Database{URL: "postgres://primary..."}, nil
})

mainDB := do.MustInvokeNamed[*Database](injector, "primary-db")

Package Organization

Use do.Package() to organize service registration by module:

go
// infrastructure/package.go
var Package = do.Package(
    do.Lazy(func(i do.Injector) (*postgres.DB, error) {
        cfg := do.MustInvoke[*Config](i)
        return postgres.Connect(cfg.DatabaseURL)
    }),
    do.Lazy(func(i do.Injector) (*redis.Client, error) {
        cfg := do.MustInvoke[*Config](i)
        return redis.NewClient(cfg.RedisURL), nil
    }),
)

// main.go
injector := do.New(infrastructure.Package, service.Package)

Full Application Setup

go
func main() {
    injector := do.New(
        infrastructure.Package,
        repository.Package,
        service.Package,
        transport.Package,
    )

    server := do.MustInvoke[*http.Server](injector)
    go server.ListenAndServe()

    _ = injector.ShutdownOnSignalsWithContext(context.Background(), os.Interrupt)
}
Show full SKILL.md (277 more words)Show less

Best Practices

  1. Depend on interfaces, not concrete types — lets you swap implementations in tests without touching production code
  2. Each service should have one job — services with multiple responsibilities are harder to test and harder to replace
  3. Keep dependency trees shallow — chains beyond 3-4 levels make initialization order fragile and errors harder to trace
  4. Handle errors in provider functions — a silently failing provider creates a broken service that crashes later in unexpected places
  5. Use scopes to organize services by lifecycle — request-scoped services prevent leaks, global services prevent redundant initialization
  6. Use do.MustInvoke* inside provider functions instead of do.Invoke* — samber/do correctly catches and recovers the panic at the outer Invoke call, turning it back into a returned error, so it's safe to use inside providers and you get the same error propagation without the boilerplate

For scopes, lifecycle management, struct injection, and debugging, see Advanced Usage.

For testing patterns (cloning, overrides, mocks), see Testing.

Quick Reference

Registration
FunctionPurpose
do.Provide[T]()Register lazy service (default)
do.ProvideNamed[T]()Register named lazy service
do.ProvideValue[T]()Register pre-created value
do.ProvideNamedValue[T]()Register named value
do.ProvideTransient[T]()Register new instance each time
do.ProvideNamedTransient[T]()Register named transient service
do.Package()Group service registrations
Invocation
FunctionPurpose
do.Invoke[T]()Get service (with error)
do.InvokeNamed[T]()Get named service
do.InvokeAs[T]()Get first service matching interface
do.InvokeStruct[T]()Inject into struct fields using tags
do.MustInvoke[T]()Get service (panic on error)
do.MustInvokeNamed[T]()Get named service (panic on error)
do.MustInvokeAs[T]()Get service by interface (panic on error)
do.MustInvokeStruct[T]()Inject into struct (panic on error)

Cross-References

  • → See samber/cc-skills-golang@golang-dependency-injection skill for DI concepts, comparison, and when to adopt a DI library
  • → See samber/cc-skills-golang@golang-structs-interfaces skill for interface design patterns
  • → See samber/cc-skills-golang@golang-testing skill for general testing patterns

© context-labs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .agents/skills/golang-samber-do of context-labs/whip.

  • SKILL.md
  • evals/evals.json
  • references/advanced.md
  • references/testing.md

Open the folder on GitHubat commit 8876467

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in context-labs/whip, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Golang Samber Do next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Golang Samber Do compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Golang Samber Do this skillcontext-labs/whip1.1k1 repos~2.3kAutomated safety check: PassMIT
Valgocohesivestack/valgo508—~2.4kAutomated safety check: PassMIT
Typed Dependencies with fp-go EffectIBM/fp-go2k—~4.3kAutomated safety check: PassApache-2.0
Golang Dependency Injectionsamber/cc-skills-golang3.4k—~3.2kAutomated safety check: PassMIT
fp-go Pattern MatchingIBM/fp-go2k—~2.8kAutomated safety check: PassApache-2.0
fp-go Pipe and FlowIBM/fp-go2k—~3.5kAutomated safety check: PassApache-2.0

Similar skills

  • Valgo

    cohesivestack/valgo

    Add, refactor, debug, review, explain, or migrate type-safe validation in consumer Go applications using github.com/cohesivestack/valgo.

    508 GitHub stars~2.4k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Teaches an agent to write fp-go v2 services with the Effect type, carrying dependencies in its type parameter instead of in context.Context or parameters.

    2k GitHub stars~4.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Golang Dependency Injection

    samber/cc-skills-golang

    Comprehensive guide for dependency injection (DI) in Golang.

    3.4k GitHub stars~3.2k tokensUpdated 10 days ago
    DevelopmentAuto-check passed
  • Official

    Guides writing or reviewing point-free, first-match-wins case lists in fp-go v2 Go code instead of switch statements and if-else chains.

    2k GitHub stars~2.8k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Shows how to compose Go functions with fp-go v2 Pipe and Flow: point-free pipelines, predicates, the reader monad, do-notation and tests for pipelines.

    2k GitHub stars~3.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Entry point for writing and reviewing Go code with the fp-go v2 library: core monad types, data-last composition, type parameter order and import conventions.

    2k GitHub stars~8.5k tokensUpdated today
    DevelopmentAuto-check passed

More from context-labs/whip

All 40 skills in this repo
  • Golang Lint

    context-labs/whip

    Linting best practices and golangci-lint configuration for Go — running linters, configuring .golangci.yml, nolint suppressions, selecting linters.

    1.1k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • Golang Project Layout

    context-labs/whip

    Golang project layouts and workspaces. An agent skill from context-labs/whip.

    1.1k GitHub starsUsed in 1 repo~1.8k tokens
    Auto-check passed
  • Golang Pkg Go Dev

    context-labs/whip

    Golang package/module docs via godig, a pkg.go.dev API client (CLI + MCP) — APIs, symbols, versions, importers, licenses, vulnerabilities.

    1.1k GitHub starsUsed in 2 repos~3k tokens
    Auto-check passed
  • Golang Stretchr Testify

    context-labs/whip

    Golang testing with stretchr/testify — assert, require, mock, suite: assertions, mock expectations, argument matchers, suite lifecycle, Eventually, JSONEq.

    1.1k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • CI/CD with GitHub Actions for Golang — testing, linting, SAST, security scanning, coverage, Dependabot, Renovate, GoReleaser, release pipelines.

    1.1k GitHub stars~3.5k tokensUpdated 6 days ago
    Auto-check passed
  • Golang Data Structures

    context-labs/whip

    Golang data structures — slices/maps internals (capacity growth, preallocation, hash buckets), slices/maps packages, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections…

    1.1k GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check passed

Works with

Categories

Questions about Golang Samber Do

What does Golang Samber Do do?

Dependency injection in Go using samber/do — service containers, lifecycle, scopes, health checks, graceful shutdown, module organization. Golang Samber Do is an agent skill from context-labs/whip. Dependency injection in Go using samber/do — service containers, lifecycle, scopes, health checks, graceful shutdown, module organization.

When should I use Golang Samber Do?

Golang Samber Do fits situations like: tasks that involve Design patterns; tasks that involve Refactoring.

How do I install Golang Samber Do in Claude Code?

Run `npx skills add context-labs/whip --skill golang-samber-do -a claude-code`. Or copy the skill folder (.agents/skills/golang-samber-do in context-labs/whip) into .claude/skills/golang-samber-do in your project. Claude Code loads it when a task matches its description.

How do I install Golang Samber Do in Codex?

Run `npx skills add context-labs/whip --skill golang-samber-do -a codex`. Or copy the skill folder (.agents/skills/golang-samber-do in context-labs/whip) into .agents/skills/golang-samber-do in your project. Codex loads it when a task matches its description.

Can I use Golang Samber Do in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add context-labs/whip --skill golang-samber-do -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/golang-samber-do, .gemini/skills/golang-samber-do, .github/skills/golang-samber-do and .opencode/skills/golang-samber-do in your project.

What does Golang Samber Do need to run?

Going by SKILL.md and its folder, Golang Samber Do needs the command-line tools its instructions call (go). Its frontmatter pre-approves these tools: Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent, WebFetch, mcp__context7__resolve-library-id, mcp__context7__query-docs, Bash(godig:*), Bash(gopls:*), LSP, mcp__gopls__*. Compatibility (from SKILL.md): Designed for Claude Code, Codex or similar harness, and for projects using Golang..

Does Golang Samber Do access the network?

SKILL.md names 3 domains. As links in the text: pkg.go.dev, do.samber.dev and github.com. This is read from the text; nothing was executed.

Is Golang Samber Do safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Golang Samber Do use?

Golang Samber Do is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Golang Samber Do use?

About 2.3k tokens (SKILL.md is roughly 9.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.7k tokens, read only when the agent opens those files.

What are the alternatives to Golang Samber Do?

Skills that share tags, products or a category with Golang Samber Do: Valgo (cohesivestack/valgo, 508 stars), Typed Dependencies with fp-go Effect (IBM/fp-go, 2k stars), Golang Dependency Injection (samber/cc-skills-golang, 3.4k stars) and fp-go Pattern Matching (IBM/fp-go, 2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Golang Samber Do?

context-labs (a GitHub organization) maintains it in context-labs/whip, which has 1,083 GitHub stars. The repository holds 40 skills in this directory. The repository was last updated on October 5, 2026.

Source: context-labs/whip on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.