golang-context

golang-context is a skill for Claude Code from shennawardana23/skillme. It costs 123 tokens per session (1,608 once invoked), scanned A, original, Apache-2.0.

A guide to using Go's context.Context, which carries cancellation signals, deadlines, and request-specific values through function calls.

In plain words
What is it for?
Adding timeouts, passing cancellation through service calls, composing deadlines, and deciding when context values or detached contexts are appropriate.
Why use it?
It helps requests stop promptly when they time out or are cancelled, while avoiding stale contexts and unsafe use of request data.

Skill for Claude Code

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

Part of the skillme plugin — 148 skills, 2 commands shipped together

Good fit Adding timeouts, passing cancellation through service calls, composing deadlines, and deciding when context values or detached contexts are appropriate.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/shennawardana23/skillme/golang-context
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 shennawardana23/skillme --skill golang-context
Clone the repo
git clone --depth 1 https://github.com/shennawardana23/skillme

Made for: Claude Code.

Or install skillme, the plugin that ships this one along with the rest of its 148 skills, 2 commands.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/shennawardana23/skillme/golang-context"><img src="https://agentmods.dev/badge/skills/shennawardana23/skillme/golang-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 123 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,608 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.00123 $0.01608
Opus 5.5 $0.00049 $0.00643
Sonnet 5.5 $0.00025 $0.00322
Haiku 4.5 $0.00012 $0.00161

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

Security

Grade A, and why

golang-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 2mo 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/golang-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 Propagation

context.Context carries three things across a call chain: a cancellation signal, an optional deadline, and request-scoped values. Each is a distinct mechanism with its own misuse pattern — this skill covers composing them correctly once a function does more than "accept ctx, pass it down," which go-service-idioms already handles.

The rules that don't have exceptions

  • Never store a context.Context in a struct field. Pass it as the first parameter, named ctx, to every function that needs it. A context stashed in a struct at construction time goes stale — it carries the deadline and cancellation state from whenever the struct was built, not from the call that's actually running. (go.dev/blog/context-and-structs)
  • Never pass nil. If there's genuinely no context yet (test setup, a main that hasn't wired one up), pass context.TODO() — it's a greppable marker meaning "this needs a real context," not a silent landmine like nil would be the first time something calls ctx.Done() on it.
  • Use WithValue only for request-scoped data that crosses API boundaries — a trace ID, a request-scoped auth principal — never for passing optional parameters a function could just take as an argument. A function whose real inputs are hidden in context values is harder to test and harder to read than one that takes them explicitly.

Composing cancellation and deadlines

WithCancel, WithDeadline, and WithTimeout each return a derived child context and a CancelFunc. Canceling a parent cancels every context derived from it; canceling a child never affects its parent or siblings. Always call the returned cancel function — typically via defer cancel() right after creation — even if the context reaches its deadline naturally; skipping it leaks the context's internal timer and goroutine until the parent is canceled, which for a long-lived parent (e.g. context.Background()) may be never. go vet flags a CancelFunc that isn't called on some path — don't ignore that warning.

Read the full file on GitHub · 139 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. 2mo ago First seen · 139 lines · 123 tokens per session scan A 4b2e313d519c

Subscribe to this mod's changes

golang-context is a skill published in the GitHub repository shennawardana23/skillme (4 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 123 tokens to every session and 1,608 once invoked, about $0.0005 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-09-03.

Related

golang-context compared with skills from other repositories

golang-context next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
golang-contextshennawardana23/skillmeSkill41mo agoApache-2.0A123Claude Code
go-servicesWrongStack/WrongStackSkill444yesterdayMITA87Claude Code
go-programming-expertroedyrustam/vibes-plugSkill1293d agoMITA45Cursor
gonimadorostkar/Claude-Skills-collectionSkill41yesterdayMITA90Claude Code
encore-go-apiencoredev/skillsSkill3110d agoApache-2.0A66Claude Code
encore-go-getting-startedencoredev/skillsSkill3110d agoApache-2.0A60Claude Code
encore-go-webhookencoredev/skillsSkill3110d agoApache-2.0A60Claude Code