go-context

go-context is a skill for Claude Code from muratmirgun/gophers. It costs 78 tokens per session (1,583 once invoked), scanned A, original, MIT.

A guide to using Go's context.Context, a value passed through a unit of work that carries cancellation, deadlines, and request-specific metadata.

In plain words
What is it for?
Use it when passing request deadlines through calls, cancelling work, starting background tasks, or attaching request IDs and authentication details.
Why use it?
It helps operations stop when a request ends, prevents stuck work, and keeps ordinary arguments and shared state in the right places.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions Claude Code; built for openclaw.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is Read [references/values-and-keys.md](../../../skills/go-context/references/values-and-keys.md) for the unexported-key pattern, typed accessors, and OpenTelemetr.

Part of the gophers plugin — 26 skills, 4 agents shipped together

Good fit Use it when passing request deadlines through calls, cancelling work, starting background tasks, or attaching request IDs and authentication details.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/muratmirgun/gophers
agentmods
npx agentmods add skills/muratmirgun/gophers/go-context

Made for: Claude Code.

Or install gophers, the plugin that ships this one along with the rest of its 26 skills, 4 agents.

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-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/muratmirgun/gophers/go-context/github.svg)](https://agentmods.dev/skills/muratmirgun/gophers/go-context)
Your own site
<a href="https://agentmods.dev/skills/muratmirgun/gophers/go-context"><img src="https://agentmods.dev/badge/skills/muratmirgun/gophers/go-context/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-context

Your own site · 80×15
<a href="https://agentmods.dev/skills/muratmirgun/gophers/go-context"><img src="https://agentmods.dev/badge/skills/muratmirgun/gophers/go-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 78 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,583 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.
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.00078 $0.01583
Opus 5.5 $0.00031 $0.00633
Sonnet 5.5 $0.00016 $0.00317
Haiku 4.5 $0.00008 $0.00158

Measured 1mo ago against content hash 328b4bc54657, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

go-context 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 1mo 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.

.claude-plugin/skills/go-context/SKILL.md · 139 lines

How it starts

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

Go Context Usage

context.Context carries the cancellation, deadline, and request-scoped values for a single unit of work. Pass it explicitly through the entire call chain — never store it, never replace it with Background() mid-flight, never use it as a side-channel for ordinary parameters.

Core Rules

  1. ctx is the first parameter, named ctx context.Context. No exceptions outside interface stubs imposed by external APIs.
  2. Propagate the caller's ctx all the way down. Do not start a new tree with context.Background() inside a request path.
  3. Do not store Context in a struct. Pass it to each method that needs it.
  4. Always defer cancel() after WithCancel/WithTimeout/WithDeadline, unless ownership is explicitly transferred.
  5. Context values are for request-scoped metadata only (request ID, auth principal, trace). Never for optional function parameters or config.
  6. Value keys must be unexported named types to prevent cross-package collisions.

Where Does Data Belong?

Pick the most explicit option that fits — context values are the last resort.

Option Use for Why
Function parameter Anything the function needs to do its job Type-checked, visible at call site
Method receiver State that belongs to the type Already in scope
Package-level config Process-wide, immutable One owner, no hidden flow
context.Value Request-scoped metadata that crosses layers without being a function arg Untyped — use sparingly

Read references/values-and-keys.md for the unexported-key pattern, typed accessors, and OpenTelemetry/trace propagation.

Constructors

Situation Use
main, init, top-level test context.Background()
Placeholder while plumbing is incomplete context.TODO()
Inside an HTTP handler r.Context()
Need manual cancellation context.WithCancel(parent)
Need a deadline / timeout context.WithTimeout(parent, d) / WithDeadline
Background work that must outlive the request (Go 1.21+) context.WithoutCancel(parent)

Read the full file on GitHub · 139 lines

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. 1mo ago First seen · 139 lines · 78 tokens per session scan A 328b4bc54657

Subscribe to this mod's changes

go-context is a skill published in the GitHub repository muratmirgun/gophers (9 stars, last pushed 2mo ago), licensed MIT. It adds 78 tokens to every session and 1,583 once invoked, about $0.0003 per session on Opus 5.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-31.

Related

Other skills, from other repositories

go

Use when writing Go services, CLIs, or libraries. Covers idiomatic error wrapping, goroutine and context discipline, interface design, table-driven tests, and the race detector. Trigger on "goroutine leak", "how should i wrap this error in go", "race detector is flagging this", "write table-driven tests for this". Do…

nimadorostkar/Claude-Skills-collection · 90 tokens

golang-pro

Implements concurrent Go patterns using goroutines and channels, designs and builds microservices with gRPC or REST, optimizes Go application performance with pprof, and enforces idiomatic Go with generics, interfaces, and robust error handling. Use when building Go applications requiring concurrent programming…

Jeffallan/claude-skills · 95 tokens

go-backend-microservices

Go backend development best practices for microservices with clean architecture, observability, and production-ready patterns.

Mindrally/skills · 26 tokens

go-programming-expert

Expert-level skill for Go programming (Go 1.24+ / 1.25+). Covers Swiss Table maps, weak pointers, synctest concurrency testing, tool directives, sqlc, net/http, and microservices in English and Indonesian.

roedyrustam/vibes-plug · 57 tokens

api-development

Guidelines for building clean, scalable APIs with Go standard library and NestJS TypeScript, covering security, validation, and modular architecture.

Mindrally/skills · 30 tokens

go-api-development

Go API development guidelines using the standard library (1.22+) with best practices for RESTful API design, error handling, and security.

Mindrally/skills · 31 tokens