Agent skill

Golang Samber Hot

by samber in samber/cc-skills-golang

In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing…

MITAuto-check passedDevOps & Cloud

Install Golang Samber Hot

skills CLI
$ npx skills add samber/cc-skills-golang --skill golang-samber-hot -a claude-code

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

GitHub CLI
$ gh skill install samber/cc-skills-golang golang-samber-hot --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/samber/cc-skills-golang.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/golang-samber-hot .claude/skills/golang-samber-hot && 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-hot
GitHub stars
3.4k
Token cost
~2k tokens
SKILL.md length
712 words
Files
5 (incl. references)
Skills in repo
6
Repo updated
First seen
Licence
MIT

At a glance

In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing…

  • Works in 3 steps: Estimate single-item size — estimate… → Ask the developer how much memory is… → Compute capacity — capacity =…
  • Tasks that involve Caching
  • SKILL.md covers Algorithm Selection, Core Usage, Capacity Sizing and Common Mistakes, plus 2 more sections
  • Calls go

What it does

Golang Samber Hot is an agent skill from samber/cc-skills-golang. In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics. Apply when using or adopting samber/hot, when the codebase imports github.com/samber/hot, or when the project repeatedly loads the same medium-to-low cardinality resources at high frequency and needs to reduce latency or backend pressure.

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

It sits in DevOps & Cloud, covering Caching, Monitoring and alerting and Database administration. It works with Go, GitHub and Prometheus. The repository describes itself as: 🧑🎨 A collection of Golang agentic skills that works. The licence is MIT.

When your agent uses it

  • Tasks that involve Caching
  • Tasks that involve Monitoring and alerting
  • Tasks that involve Database administration

Example prompts

  • “/golang-samber-hot”

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, AskUserQuestion, Bash(godig:*), Bash(gopls:*), LSP, mcp__gopls__*

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Estimate single-item size — estimate size of the struct, add the size of heap-allocated fields (slices, maps, strings). Include the key…
  2. Ask the developer how much memory is dedicated to this cache in production (e.g., 256 MB, 1 GB). This depends on the service's total…
  3. Compute capacity — capacity = memoryBudget / estimatedItemSize. Round down to leave headroom.

What it can do on your machine

Read from SKILL.md and the folder at commit 8e899e2. 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 7 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):

    • github.com
    • pkg.go.dev

    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 Hot loads about 2k tokens when it runs, and up to ~7.9k if it reads all its reference files. Until then it costs about 123 tokens; SKILL.md has 712 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~123
When it runs · the whole SKILL.md, loaded when a task matches
~2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.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 samber/cc-skills-golang at commit 8e899e2, republished under its MIT licence (© samber). 712 words, ~1,982 tokens.

Download SKILL.mdSave it as .claude/skills/golang-samber-hot/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
golang-samber-hot
description
In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics. Apply when using or adopting samber/hot, when the codebase imports github.com/samber/hot, or when the project repeatedly loads the same medium-to-low cardinality resources at high frequency and needs to reduce latency or backend pressure.
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, AskUserQuestion, 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.1.2
paths
**/*.go

Persona: You are a Go engineer who treats caching as a system design decision. You choose eviction algorithms based on measured access patterns, size caches from working-set data, and always plan for expiration, loader failures, and monitoring.

Using samber/hot for In-Memory Caching in Go

Generic, type-safe in-memory caching library for Go 1.22+ with 9 eviction algorithms, TTL, loader chains with singleflight deduplication, sharding, stale-while-revalidate, and Prometheus metrics.

Official Resources:

This skill is not exhaustive — 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), preferred 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.
bash
go get -u github.com/samber/hot

Algorithm Selection

Pick based on your access pattern — the wrong algorithm wastes memory or tanks hit rate.

AlgorithmConstantBest forAvoid when
W-TinyLFUhot.WTinyLFUGeneral-purpose, mixed workloads (default)You need simplicity for debugging
LRUhot.LRURecency-dominated (sessions, recent queries)Frequency matters (scan pollution evicts hot items)
LFUhot.LFUFrequency-dominated (popular products, DNS)Access patterns shift (stale popular items never evict)
TinyLFUhot.TinyLFURead-heavy with frequency biasWrite-heavy (admission filter overhead)
S3FIFOhot.S3FIFOHigh throughput, scan-resistantSmall caches (<1000 items)
ARChot.ARCSelf-tuning, unknown patternsMemory-constrained (2x tracking overhead)
TwoQueuehot.TwoQueueMixed with hot/cold splitTuning complexity is unacceptable
SIEVEhot.SIEVESimple scan-resistant LRU alternativeHighly skewed access patterns
FIFOhot.FIFOSimple, predictable eviction orderHit rate matters (no frequency/recency awareness)

Decision shortcut: Start with hot.WTinyLFU. Switch only when profiling shows the miss rate is too high for your SLO.

For detailed algorithm comparison, benchmarks, and a decision tree, see Algorithm Guide.

Core Usage

Basic Cache with TTL
go
import "github.com/samber/hot"

cache := hot.NewHotCache[string, *User](hot.WTinyLFU, 10_000).
    WithTTL(5 * time.Minute).
    WithJanitor().
    Build()
defer cache.StopJanitor()

cache.Set("user:123", user)
cache.SetWithTTL("session:abc", session, 30*time.Minute)

value, found, err := cache.Get("user:123")
Loader Pattern (Read-Through)

Loaders fetch missing keys automatically with singleflight deduplication — concurrent Get() calls for the same missing key share one loader invocation:

go
cache := hot.NewHotCache[int, *User](hot.WTinyLFU, 10_000).
    WithTTL(5 * time.Minute).
    WithLoaders(func(ids []int) (map[int]*User, error) {
        return db.GetUsersByIDs(ctx, ids) // batch query
    }).
    WithJanitor().
    Build()
defer cache.StopJanitor()

user, found, err := cache.Get(123) // triggers loader on miss

Capacity Sizing

Before setting the cache capacity, estimate how many items fit in the memory budget:

  1. Estimate single-item size — estimate size of the struct, add the size of heap-allocated fields (slices, maps, strings). Include the key size. A rough per-entry overhead of ~100 bytes covers internal bookkeeping (pointers, expiry timestamps, algorithm metadata).
  2. Ask the developer how much memory is dedicated to this cache in production (e.g., 256 MB, 1 GB). This depends on the service's total memory and what else shares the process.
  3. Compute capacity — capacity = memoryBudget / estimatedItemSize. Round down to leave headroom.
Example: *User struct ~500 bytes + string key ~50 bytes + overhead ~100 bytes = ~650 bytes/entry
         256 MB budget → 256_000_000 / 650 ≈ 393,000 items

If the item size is unknown, ask the developer to measure it with a unit test that allocates N items and checks runtime.ReadMemStats. Guessing capacity without measuring leads to OOM or wasted memory.

Show full SKILL.md (268 more words)Show less

Common Mistakes

  1. Forgetting WithJanitor() — without it, expired entries stay in memory until the algorithm evicts them. Always chain .WithJanitor() in the builder and defer cache.StopJanitor().
  2. Calling SetMissing() without missing cache config — panics at runtime. Enable WithMissingCache(algorithm, capacity) or WithMissingSharedCache() in the builder first.
  3. WithoutLocking() + WithJanitor() — mutually exclusive, panics. WithoutLocking() is only safe for single-goroutine access without background cleanup.
  4. Oversized cache — a cache holding everything is a map with overhead. Size to your working set (typically 10-20% of total data). Monitor hit rate to validate.
  5. Ignoring loader errors — Get() returns (zero, false, err) on loader failure. Always check err, not just found.

Best Practices

  1. Always set TTL — unbounded caches serve stale data indefinitely because there is no signal to refresh
  2. Use WithJitter(lambda, upperBound) to spread expirations — without jitter, items created together expire together, causing thundering herd on the loader
  3. Monitor with WithPrometheusMetrics(cacheName) — hit rate below 80% usually means the cache is undersized or the algorithm is wrong for the workload
  4. Use WithCopyOnRead(fn) / WithCopyOnWrite(fn) for mutable values — without copies, callers mutate cached objects and corrupt shared state

For advanced patterns (revalidation, sharding, missing cache, monitoring setup), see Production Patterns.

For the complete API surface, see API Reference.

If you encounter a bug or unexpected behavior in samber/hot, open an issue at https://github.com/samber/hot/issues.

Cross-References

  • → See samber/cc-skills-golang@golang-performance skill for general caching strategy and when to use in-memory cache vs Redis vs CDN
  • → See samber/cc-skills-golang@golang-observability skill for Prometheus metrics integration and monitoring
  • → See samber/cc-skills-golang@golang-database skill for database query patterns that pair with cache loaders
  • → See samber/cc-skills@promql-cli skill for querying Prometheus cache metrics via CLI

© samber, 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 4 other files (references) in skills/golang-samber-hot of samber/cc-skills-golang.

  • SKILL.md
  • evals/evals.json
  • references/algorithm-guide.md
  • references/api-reference.md
  • references/production-patterns.md

Open the folder on GitHubat commit 8e899e2

Compare with similar skills

Golang Samber Hot 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 Hot compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Golang Samber Hot this skillsamber/cc-skills-golang3.4k—~2kAutomated safety check: PassMIT
Golang Samber Hotcontext-labs/whip1.1k—~1.9kAutomated safety check: PassMIT
Devnet Triagegeanlabs/gean177—~3.7kAutomated safety check: WarnMIT
Golang Observabilitycontext-labs/whip1.1k1 repos~3.3kAutomated safety check: PassMIT
Golang Benchmarkaiskillstore/marketplace4331 repos~3.4kAutomated safety check: PassMIT
Greptimedb Perses DashboardGreptimeTeam/dashboard111—~3.9kAutomated safety check: PassApache-2.0

Similar skills

  • Golang Samber Hot

    context-labs/whip

    In-memory caching in Go using samber/hot — eviction (LRU, LFU, TinyLFU, S3FIFO, ARC, SIEVE), TTL, loaders, sharding, stale-while-revalidate, missing-key caching, metrics.

    1.1k GitHub stars~1.9k tokensUpdated 6 days ago
    DatabasesAuto-check passed
  • Devnet Triage

    geanlabs/gean

    Diagnose a live, running lean devnet from its Prometheus and container logs, then report findings with proposed fixes and stop for approval.

    177 GitHub stars~3.7k tokensUpdated yesterday
    DevOps & CloudAuto-check: warnings
  • Golang Observability

    context-labs/whip

    Go observability — always-on production signals: slog logging, Prometheus metrics, OpenTelemetry tracing, pprof profiling, alerting, Grafana.

    1.1k GitHub starsUsed in 1 repo~3.3k tokens
    DevOps & CloudAuto-check passed
  • Golang Benchmark

    aiskillstore/marketplace

    Golang benchmarking, profiling, and performance measurement.

    433 GitHub starsUsed in 1 repo~3.4k tokens
    DevOps & CloudAuto-check passed
  • Greptimedb Perses Dashboard

    GreptimeTeam/dashboard

    Generate Perses dashboards or single panels for GreptimeDB. An agent skill from GreptimeTeam/dashboard.

    111 GitHub stars~3.9k tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • Tgf Server Dev

    thkhxm/tgf

    基于 tgf v2(github.com/thkhxm/tgf/v2)用确定性的 tgfctl 工作流创建、验证和维护 Go 游戏服务器项目。

    128 GitHub stars~1.3k tokensUpdated 2 mo ago
    DatabasesAuto-check: notes

More from samber/cc-skills-golang

  • Golang Continuous Integration

    samber/cc-skills-golang

    GitHub Actions CI/CD pipeline configuration for Golang projects — workflow files for test, lint, SAST, coverage and vulnerability-scan jobs, Dependabot and Renovate config files, GoReleaser release…

    3.4k GitHub stars~3.7k tokensUpdated 10 days ago
    Auto-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
    Auto-check passed
  • Golang Dependency Management

    samber/cc-skills-golang

    Dependency management for Golang projects — go.mod and go.sum, go get install and upgrade flows, Minimal Version Selection, conflict resolution with replace/exclude/retract, govulncheck scanning of…

    3.4k GitHub stars~2.6k tokensUpdated 10 days ago
    Auto-check passed
  • Golang Troubleshooting

    samber/cc-skills-golang

    Troubleshoot Golang programs systematically - find and fix the root cause.

    3.4k GitHub stars~3.3k tokensUpdated 10 days ago
    Auto-check passed
  • Golang Samber Mo

    samber/cc-skills-golang

    Monadic types for Golang using samber/mo — Option, Result, Either, Future, IO, Task, and State types for type-safe nullable values, error handling, and functional composition with pipeline…

    3.4k GitHub stars~2.9k tokensUpdated 10 days ago
    Auto-check passed

Questions about Golang Samber Hot

What does Golang Samber Hot do?

In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing…. Golang Samber Hot is an agent skill from samber/cc-skills-golang. In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics.

When should I use Golang Samber Hot?

Golang Samber Hot fits situations like: tasks that involve Caching; tasks that involve Monitoring and alerting; tasks that involve Database administration.

How do I install Golang Samber Hot in Claude Code?

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

How do I install Golang Samber Hot in Codex?

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

Can I use Golang Samber Hot 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 samber/cc-skills-golang --skill golang-samber-hot -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-hot, .gemini/skills/golang-samber-hot, .github/skills/golang-samber-hot and .opencode/skills/golang-samber-hot in your project.

What does Golang Samber Hot need to run?

Going by SKILL.md and its folder, Golang Samber Hot 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, AskUserQuestion, 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 Hot access the network?

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

Is Golang Samber Hot 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 Hot use?

Golang Samber Hot 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 Hot use?

About 2k tokens (SKILL.md is roughly 7.9k 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 5.9k tokens, read only when the agent opens those files.

What are the alternatives to Golang Samber Hot?

Skills that share tags, products or a category with Golang Samber Hot: Golang Samber Hot (context-labs/whip, 1.1k stars), Devnet Triage (geanlabs/gean, 177 stars), Golang Observability (context-labs/whip, 1.1k stars) and Golang Benchmark (aiskillstore/marketplace, 433 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Golang Samber Hot?

samber (a GitHub user) maintains it in samber/cc-skills-golang, which has 3,432 GitHub stars. The repository holds 6 skills in this directory. The repository was last updated on October 1, 2026.

Source: samber/cc-skills-golang on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.