go-functional-options

go-functional-options is a skill for Claude Code from cxuu/golang-skills. It costs 65 tokens per session (998 once invoked), scanned A, original, Apache-2.0.

A guide to the functional options pattern in Go, where optional settings are passed as named configuration functions to a constructor. A constructor is a function that creates a configured value.

In plain words
What is it for?
Use it when designing Go constructors or factory functions with three or more optional arguments or with configuration likely to expand.
Why use it?
It keeps constructors readable when they have several optional settings and allows an API to gain more settings without changing every existing call.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the golang-skills plugin — 20 skills shipped together

Good fit Use it when designing Go constructors or factory functions with three or more optional arguments or with configuration likely to expand.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cxuu/golang-skills/go-functional-options
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cxuu/golang-skills --skill go-functional-options
Clone the repo
git clone --depth 1 https://github.com/cxuu/golang-skills

Made for: Claude Code.

Or install golang-skills, the plugin that ships this one along with the rest of its 20 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for go-functional-options

README.md
[![agentmods](https://agentmods.dev/badge/skills/cxuu/golang-skills/go-functional-options/github.svg)](https://agentmods.dev/skills/cxuu/golang-skills/go-functional-options)
Your own site
<a href="https://agentmods.dev/skills/cxuu/golang-skills/go-functional-options"><img src="https://agentmods.dev/badge/skills/cxuu/golang-skills/go-functional-options/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for go-functional-options

Your own site · 80×15
<a href="https://agentmods.dev/skills/cxuu/golang-skills/go-functional-options"><img src="https://agentmods.dev/badge/skills/cxuu/golang-skills/go-functional-options.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 998 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 18 Mar 2026
  • Snyk pass 15 Mar 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00065 $0.00998
Opus 5 $0.00032 $0.00499
Sonnet 5 $0.00013 $0.00200
Haiku 4.5 $0.00006 $0.00100

Measured 11d ago against content hash 447cc404d900, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

go-functional-options scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/go-functional-options/SKILL.md · 111 lines

How it starts

The opening of the file, as written. The whole thing — 111 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Functional Options Pattern

Functional options is a pattern where you declare an opaque Option type that records information in an internal struct. The constructor accepts a variadic number of these options and applies them to configure the result.

Resource Routing

  • references/OPTIONS-VS-STRUCTS.md - Read when choosing between config structs and functional options, implementing the full interface-based option pattern, or evaluating hybrid constructor APIs.

When to Use

Use functional options when:

  • 3+ optional arguments on constructors or public APIs
  • Extensible APIs that may gain new options over time
  • Clean caller experience is important (no need to pass defaults)

The Pattern

Core Components

  1. Unexported options struct - holds all configuration
  2. Exported Option interface - with unexported apply method
  3. Option types - implement the interface
  4. With* constructors - create options

Option Interface

type Option interface {
    apply(*options)
}

The unexported apply method ensures only options from this package can be used.

Comparison: Functional Options vs Config Struct

Aspect Functional Options Config Struct
Extensibility Add new With* functions Add new fields (may break)
Defaults Built into constructor Zero values or separate defaults
Caller experience Only specify what differs Must construct entire struct
Testability Options are comparable Struct comparison
Complexity More boilerplate Simpler setup

Prefer Config Struct when: Fewer than 3 options, options rarely change, all options usually specified together, or internal APIs only.

Why Not Closures?

The interface approach is preferred over closure-only options because:

  1. Testability - Options can be compared in tests and mocks
  2. Debuggability - Options can implement fmt.Stringer
  3. Flexibility - Options can implement additional interfaces
  4. Visibility - Option types are visible in documentation

Read the full file on GitHub · 111 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 111 lines · 65 tokens per session scan A 447cc404d900

Subscribe to this mod's changes

go-functional-options is a skill published in the GitHub repository cxuu/golang-skills (158 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 65 tokens to every session and 998 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

go-expert

Expert-level Go development with Go 1.22+ features, concurrency, standard library, and production-grade best practices. Use when the user mentions concurrency, microservices, or backend, or when the task involves idiomatic Go, goroutines and channels, context-based cancellation, or writing an HTTP server.

personamanagmentlayer/pcl · 65 tokens

jwt

Development guide for the jwt JSON Web Token library for Go (github.com/kataras/jwt). Use this skill when signing or verifying JWTs, choosing a signing algorithm (HMAC, RSA, RSA-PSS, ECDSA, EdDSA), reading or validating standard or custom claims, setting expiry and clock-skew tolerance, rotating keys with a kid-based…

kataras/jwt · 107 tokens

go

Use when writing, reviewing, testing, or shipping Go code and HTTP services: idioms, %w error wrapping, goroutine/context/errgroup concurrency, net/http 1.22 routing, log/slog, project layout, table-driven tests, Go hardening. NOT language-agnostic threat modeling (that is secure-coding), NOT Dockerfile/CI shipping…

ericrisco/rsc-harness · 86 tokens

crawlkit

Maintain and release the crawlkit Go library, preserving downstream compatibility for gitcrawl, slacrawl, discrawl, and notcrawl.

vincentkoc/dotskills · 30 tokens

functions-development

Build serverless Go or Python functions for Falcon Foundry apps. TRIGGER when user asks to "create a function", "write a serverless function", "build backend logic", runs foundry functions create, or needs help with FDK handler patterns, function testing, or collection integration from functions. Also TRIGGER when…

CrowdStrike/foundry-skills · 195 tokens

structpages

Guide for building Go web applications with the structpages framework (struct-based routing + templ + HTMX). Use when writing routes, pages, page groups, Props methods, handler methods (ServeHTTP), page components, partials, HTMX partial rendering and nested swap levels, URL generation (URLFor/ID/IDTarget)…

jackielii/structpages · 103 tokens