/ct:golangfrom ct
Diagnoses Go runtime issues: GC tuning, container scheduling, escape analysis, pprof profiling, goroutine leaks, race detector, and govulncheck. Loads when debugging performance, memory, or concurrency problems.
Ships in ct. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Concise operational pointers for Go runtime tuning, profiling, and concurrency diagnosis.
Assumes you already know goroutines, channels, error handling, and module basics. This skill covers the operational layer — the parts models tend to gloss over: race detector economics, GC/scheduler tuning under containers, profiling configuration, leak forensics, escape analysis, memory-model edges.
Load when the question is about:
GOGC, GOMEMLIMIT, gctrace interpretation, GC CPU cap)GOMAXPROCS in containers (cgroup detection, automaxprocs, Go 1.25 default)runtime/trace)goroutineleak profile in 1.26)-gcflags='-m' output, interface boxing, closure capture)sync.Pool retention, slice capacity GC retention, defer-in-loop accumulation, nil/closed channel semanticsgovulncheck reachability vs gosec / staticcheck scopego.mod replace directive scope, GOFLAGS, GOPRIVATE/GONOSUMDB, vendor caveatsDo NOT load for: writing idiomatic Go, picking between chan and sync.Mutex for a new feature, project layout debates, generic test scaffolding, basic error-wrapping style.
-race on for production binaries by default. CI lane is the right home.defer/recover retained until the goroutine exits. Long-lived goroutines with tight defer/recover loops grow without bound — invisible in runtime.ReadMemStats and runtime/pprof heap profiles.-race once is not "I checked for races" — it's "I checked the code paths I exercised this run." Pair with stress tests (go test -race -count=N).halt_on_error=1 exits on first race (CI default); history_size=N widens the per-goroutine memory history (default 1, max 7) — raise only if you see "race detected (history truncated)"; exitcode=66 is the default — set non-66 if 66 collides with your runner.linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/loong64, darwin/amd64, darwin/arm64, windows/amd64, freebsd/amd64, netbsd/amd64. No 32-bit support.-race because the binary is fundamentally different (instrumented). Don't compare benchmarks between race and non-race builds.GOGC=off disables proportional triggering entirely.runtime.MemStats.Sys - HeapReleased (i.e. total Go-managed memory, not just heap). Set via env or runtime/debug.SetMemoryLimit. Soft means "best effort" — runtime will exceed it rather than thrash.GOGC=off GOMEMLIMIT=8GiB lets the heap grow to 8GiB and only GCs to stay under that. Reduces GC frequency dramatically when memory headroom is the binding constraint.2 × GOMAXPROCS CPU-second window. Worst-case slowdown ~2x; runtime prefers OOM/limit-overshoot to indefinite stall.gc # @s %: ms clock, ms cpu, MB→MB→MB, MB goal, MB stacks, MB globals, P. →MB→MB→MB = pre-GC heap → post-GC heap → live. Goal is the next-cycle target. If goal keeps shrinking and time-in-GC % climbs, you're approaching memlimit thrash.runtime.NumCPU() returns the host's logical CPUs, ignoring cgroup CPU quota. In a 100-core node with a 2-CPU container limit, GOMAXPROCS=100 → severe throttling (cgroup CFS throttles), p99 latency tanks. Uber benchmarks: 4x p50, 25x p99 improvement when matched.GOMAXPROCS env or calling runtime.GOMAXPROCS() overrides.import _ "go.uber.org/automaxprocs" reads cpu.cfs_quota_us/cpu.cfs_period_us (cgroup v1) or cpu.max (cgroup v2). No-op on macOS/Windows. Call before any goroutine that depends on parallelism.GODEBUG=schedtrace=1000 emits scheduler state every 1 s. Watch runqueue (global) and [N M ...] (per-P local queues). Add scheddetail=1 for per-goroutine state — verbose, use briefly.runtime/pprof.Lookup / /debug/pprof/): goroutine, heap, allocs, threadcreate, block, mutex, goroutineleak (1.26+).runtime.SetMutexProfileFraction(N) — reports 1/N contention events. Common: 100 in dev, 1000-10000 in prod. 0 disables; negative reads current.runtime.SetBlockProfileRate(N) — samples 1 event per N nanoseconds blocked. 1 = every event (expensive); 10000 (10 µs) is a safer prod default; 0 disables.pprof.Do(ctx, pprof.Labels("op", "ingest", "tenant", id), func(ctx) {...}). Labels propagate through derived contexts and to goroutines spawned inside Do. Slice profiles by label in pprof: -tagfocus=op:ingest. Crucial for sharing a multi-tenant binary's profile.debug parameter: 0 = pprof protobuf (use this for go tool pprof). 1 = text with addresses. 2 = goroutine profile in panic-style stack format — best for human reading of goroutine profile.runtime/trace, go tool trace): captures scheduling, syscalls, GC pauses, network poll. Different from pprof — use for "why is wall-clock slow when CPU is fine" (lock contention, GC stalls, syscall blocking). Heavy: 100s of MB/s for busy programs. Bound runs to seconds.pprof.StartCPUProfile(w) / StopCPUProfile(). Default sampling rate ~100 Hz (10 ms). Adjust via runtime.SetCPUProfileRate before start.runtime.NumGoroutine() climbs monotonically; heap profile shows steady growth tied to goroutine-owned objects; /debug/pprof/goroutine?debug=2 reveals N goroutines on the same blocked frame.chan send forever)range over a channel that's never closed (receiver blocks chan receive)select { case <-ch: ... case <-ctx.Done(): return } where the producer goroutine still tries to send on ch after ctx cancels — the producer leaks (sender doesn't observe ctx)curl /debug/pprof/goroutine?debug=2 > goroutines.txtruntime.chansend1, runtime.gopark)goroutineleak profile: explicit leak detector (off by default; experimental). Triggers a special GC cycle, returns only goroutines whose blocking primitive is unreachable from any non-blocked goroutine. Cuts noise dramatically vs goroutine profile.defer ticker.Stop(), defer cancel() when creating time.Ticker/context.WithCancel. Failing to call cancel doesn't leak a goroutine itself but defeats deadline propagation, causing downstream leaks._, ok := context.WithTimeout(ctx, d) discards cancel. The cancel must be called (typically defer cancel()) even if the deadline fires — failing to cancel keeps the timer alive until the parent context cancels, leaking timer state. go vet catches this (lostcancel).ctx.Err() vs <-ctx.Done(): Done() is the channel for select; Err() returns context.Canceled or context.DeadlineExceeded post-cancel — nil before. Always check Err() after Done() fires to distinguish the cause.WithTimeout(parent, 10s) clamps to whichever is sooner — parent's deadline or now+10s. Never extends.errgroup.WithContext: derived ctx is canceled on first error from any Group.Go callee, or when Wait returns. Other goroutines must observe ctx.Done() themselves — errgroup does NOT preempt them. The first non-nil error is what Wait returns; later errors are dropped.SetLimit(n): Group.Go blocks when n goroutines are active. TryGo returns false instead of blocking. Must not change limit while goroutines are running.sync.WaitGroup: WaitGroup is dumb counting (no errors, no cancel). errgroup adds error capture + ctx cancellation. Don't reach for WaitGroup unless you genuinely have no error path and no cancellation need.ch = nil after observing close, so the case never fires again.for { select { case v, ok := <-ch: if !ok { ch = nil; continue } ... } } is the correct merge-and-disable idiom.sync.Pool GC cycles: pooled objects survive at least 2 GC cycles (a victim cache mechanism added in 1.13 prevents post-GC empty-pool stampede). Don't pool huge variable-sized buffers — Pool.Get returns an arbitrary item, so a 16-byte caller may get a 16 MB buffer. Discard oversized items rather than Put-ing them back.s = s[:0] keeps cap and the underlying array alive — and pointer elements past len are still referenced by GC. Set s[i] = nil for indices in [len:cap] you want released, or reslice with explicit copy: s = append([]T(nil), s[:n]...).for _, f := range files { defer f.Close() } holds N file handles. Refactor to a per-iteration function so deferreds fire each loop.time.Ticker requires explicit Stop(). Falling out of scope does not stop the underlying goroutine — leaks until program exit.go build -gcflags='-m -m' ./.... Single -m is one level; double prints reasoning chains. Look for moved to heap, escapes to heap, parameter X leaks to {return value, heap}.&local (caller may outlive callee) — escape mandatoryinterface{} — often heap because compiler can't prove the call site keeps it on the stack. Generic T any can box too if T is large or pointer-shaped.*T return value escapes the called function's frame — but doesn't necessarily heap-allocate if inlined. Check inlining decisions: -gcflags='-m=2'.interface{} boxing in fmt.Sprintf etc. — avoid in hot paths or pre-format with typed builders.-benchmem and compare allocs/op before/after. Escape analysis output is necessary but not sufficient — measure.go vet: ships with the toolchain; runs by default during go test. Checks include lostcancel, printf, nilness, copylocks, unreachable. Always-on baseline.govulncheck: official (golang.org/x/vuln). Reachability-based — only reports CVEs whose vulnerable functions are actually called by your code (static call graph). Two modes: -mode=source (gives full call stacks; needs source) and -mode=binary (symbol-table based; no call stacks). Caveats: reflection-mediated calls invisible (false negatives); unsafe may also be invisible. Exit non-zero on findings except -format=json|sarif|openvex which always exits 0.gosec: pattern-based (regex/AST) on source for CWE patterns (hardcoded creds, weak crypto, command injection). Different scope than govulncheck — gosec catches anti-patterns regardless of CVE; govulncheck catches reachable CVEs regardless of code style. Use both.staticcheck: maintained by Dominik Honnef (third-party but de-facto standard, integrated with gopls). Checks numbered SA*, S*, ST*. Includes errcheck-equivalent error-return checking. Bundled in golangci-lint.errcheck: standalone, checks all error returns are handled. Subsumed by staticcheck for most.golangci-lint: aggregator; runs many linters in parallel with shared loading — strictly faster than running them serially. Project-level config in .golangci.yml.replace directive scope: only the main module's go.mod replace lines are honored. Replaces in dependency go.mods are ignored. Means: forking a dep's dep requires replace in your top-level go.mod, even if the upstream dep also replaces it.replace to a local path (replace foo => ../foo) requires the path be outside any vendored tree. CI without that local checkout will fail unresolved.GOFLAGS=-mod=vendor uses vendor/ and ignores go.mod resolution; -mod=mod resolves; -mod=readonly forbids implicit go.mod mutation (CI-friendly).GOPROXY: comma-separated; direct means VCS, off blocks remote fetch. Common: GOPROXY=https://proxy.golang.org,direct. Use off to enforce reproducible builds with already-cached modules only.GOPRIVATE / GONOSUMDB / GONOPROXY: GOPRIVATE is a glob list; sets defaults for the other two. Modules matching skip checksum-DB verification (sumdb) and may bypass the proxy. Required for private VCS hosts.go mod why <pkg>: prints the import chain proving why <pkg> is in your build. Use to debug "why did this transitive dep show up."go mod tidy -e: continue past errors; useful when one module is unreachable but you want to clean the rest.vendor/modules.txt must match go.mod; otherwise -mod=vendor fails. Replace directives + vendor coexist but dependencies-of-replaced-modules still need to be in vendor/.sync/atomic operations are sequentially consistent. "If A is observed by B, then A happens-before B." Same model as Java volatile and C++ SC atomics. Do NOT mix with non-atomic accesses to the same variable — that's still a race.Unlock() happens-before mth Lock() returns, for n < m. RLock is similar via the n+1th Lock relationship.f happens-before any other Do(f) returns.sync.Once is correct; "double-checked" patterns with naked reads/writes are not — even if "the variable is just a pointer" and "writes are atomic on x86." The race detector flags these.Official Go docs (go.dev):
Runtime / pprof packages:
runtime — SetMutexProfileFraction, SetBlockProfileRate, NumGoroutine, GODEBUG varsruntime/pprof — profile types, labels, Dogolang.org/x/sync/errgroupgolang.org/x/vuln/cmd/govulncheckCommunity deep-dives (reliable authors):
automaxprocs — github.com/uber-go/automaxprocsBefore recommending a non-trivial operational change (GOGC/GOMEMLIMIT, profile fractions, GOMAXPROCS override, replace directive):
goroutineleak profile in 1.26)Tuning without measurement is worse than defaults.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
go-runtime, gc-tuning, pprof, goroutine-leaks, race-detector, escape-analysis
npx claudepluginhub pvillega/claude-templates --plugin ct38 skills in this plugin
/argocdDeep ArgoCD operational intuition — sync waves and hook lifecycle, ApplicationSet generators, Sync vs Health, drift root causes, sync options, AppProject constraints, rollback, multi-cluster. Load for sync ordering, hook design, drift diagnosis, generator selection, rollback planning, or multi-cluster registration. Skip for "what is GitOps", install walkthroughs, or basic Application YAML. Triggers on: "sync wave", "presync hook", "syncfail", "applicationset generator", "matrix generator", "hpa replicas drift", "ignoreDifferences", "ServerSideApply", "Replace=true", "self-heal", "app-of-apps cascade".
/audit-skillsAudit installed skills for redundancy with built-in model knowledge. Use when asked to "audit skills", "review my skills", "check skill redundancy", "which skills are useful", "clean up skills", or "are my skills teaching you anything new"./bash-hardeningDeep bash correctness — `set -euo pipefail` traps, IFS/word-splitting, trap inheritance, process substitution, array gotchas, version-gated features, ShellCheck "looks right but isn't" patterns. Load when writing or hardening non-trivial bash scripts (installers, CI, unattended ops). Skip for basic if/while/for, one-shot interactive commands, or zsh/fish/POSIX-sh work. Triggers on: "set -e not triggering", "pipefail", "trap ERR", "PIPESTATUS", "macOS bash 3.2", "shellcheck SC2086", "harden bash script", "robust bash".
/bugmagnetDiscover edge cases and test coverage gaps through systematic analysis. Use when analysing TEST coverage, hunting for edge cases, or when code-reviewer identifies test gaps. Triggers on "find holes in my tests", "what could go wrong", "is this well tested", "what edge cases am I missing". When to pick bugmagnet vs alternatives: - find-bugs → branch-diff bug scan (uses git diff, scoped to recent changes) - security-review → OWASP-categorised vulnerability audit - code-review → PR-style review with comment threads - ct:bugmagnet → test-gap edge-case discovery (THIS one) If the question is "are my TESTS missing cases?", use bugmagnet. Otherwise pick one of the three above.
/ci-failure-triageDiagnose a failing GitHub Actions run. Fetch the failing job's step logs, correlate with recent commits, and produce a ranked top-3 root-cause hypothesis plus a minimal fix proposal. Use when the user says "CI is failing", "why did the build break", "triage this GHA failure", "workflow failed", "what broke CI", or pastes a `gh run` URL / run ID. Read-only — does NOT apply fixes, restart the run, or tail logs. For workflow-file security audits use gha-security-review; for local test failures use fix-loop.
/c-languageDeep C operational intuition — undefined behavior, sanitizers (ASan/UBSan/TSan/MSan), hardening flags, atomics/memory ordering, fuzzing, ABI quirks. Load when diagnosing UB, configuring sanitizers or hardened builds, investigating data races, or debugging alignment/atomics. Skip for ordinary C coding, malloc/free, or syntax help. Triggers on: "undefined behavior", "strict aliasing", "AddressSanitizer", "UBSan", "Valgrind", "use-after-free", "_FORTIFY_SOURCE", "memory_order", "libFuzzer", "ABI".
Other plugins' skills for the same job