Agent skill

Gleak

by onsi in onsi/gomega

gleak goroutine leak detection — capture a Goroutines() snapshot before a test, then Eventually(Goroutines).ShouldNot(HaveLeaked(snapshot)) to assert none leaked, with the…

MITAuto-check passedDevelopment

Install Gleak

skills CLI
$ npx skills add onsi/gomega --skill gleak -a claude-code

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

GitHub CLI
$ gh skill install onsi/gomega gleak --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/onsi/gomega.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/gomega/skills/gleak .claude/skills/gleak && 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
gleak
GitHub stars
2.4k
Token cost
~1.5k tokens
SKILL.md length
529 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

gleak goroutine leak detection — capture a Goroutines() snapshot before a test, then Eventually(Goroutines).ShouldNot(HaveLeaked(snapshot)) to assert none leaked, with the…

  • A test must verify goroutines started during the test have all wound down and nothing leaked
  • SKILL.md covers Import, The canonical pattern, Gotchas and HaveLeaked([ignoring...]), plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Tasks that involve Async programming

What it does

Gleak is an agent skill from onsi/gomega. gleak goroutine leak detection — capture a Goroutines() snapshot before a test, then Eventually(Goroutines).ShouldNot(HaveLeaked(snapshot)) to assert none leaked, with the BeforeEach/AfterEach/DeferCleanup pattern, ignoring matchers IgnoringTopFunction/IgnoringInBacktrace/IgnoringGoroutines/IgnoringCreator, well-known non-leaky goroutines, goroutine IDs, ReportFilenameWithPath, and the Ginkgo -p IgnoreGinkgoParallelClient gotcha. Use when a test must verify goroutines started during the test have all wound down…

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Async programming. The repository describes itself as: Ginkgo's Preferred Matcher Library. The licence is MIT.

When your agent uses it

  • A test must verify goroutines started during the test have all wound down and nothing leaked
  • Tasks that involve Async programming

Example prompts

  • “/gleak”

What it can do on your machine

Read from SKILL.md and the folder at commit 37fa900. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are 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):

    • onsi.github.io

    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.

Context cost

Gleak loads about 1.5k tokens when it runs. Until then it costs about 136 tokens; SKILL.md has 529 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~136
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

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 onsi/gomega at commit 37fa900, republished under its MIT licence (© onsi). 529 words, ~1,507 tokens.

Download SKILL.mdSave it as .claude/skills/gleak/SKILL.md (or your agent's skills folder).
name
gleak
description
gleak goroutine leak detection — capture a Goroutines() snapshot before a test, then Eventually(Goroutines).ShouldNot(HaveLeaked(snapshot)) to assert none leaked, with the BeforeEach/AfterEach/DeferCleanup pattern, ignoring matchers IgnoringTopFunction/IgnoringInBacktrace/IgnoringGoroutines/IgnoringCreator, well-known non-leaky goroutines, goroutine IDs, ReportFilenameWithPath, and the Ginkgo -p IgnoreGinkgoParallelClient gotcha. Use when a test must verify goroutines started during the test have all wound down and nothing leaked.

gleak: detecting leaked goroutines

gleak discovers all running goroutines and fails a test if any "leaked" — i.e. are still running after the test that aren't well-known framework/runtime goroutines and aren't on your ignore list. Docs: https://onsi.github.io/gomega/#gleak-finding-leaked-goroutines. Cross-refs: gomega:async, gomega:matchers.

gleak is an experimental Gomega package.

Import

go
import (
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gleak" // often dot-imported too, for HaveLeaked/Goroutines/Ignoring*
)

The canonical pattern

Capture a baseline snapshot before the test; assert no leak after. The cleanup runs Eventually(Goroutines).ShouldNot(HaveLeaked(snapshot)):

go
BeforeEach(func() {
	goods := gleak.Goroutines()          // snapshot of "good" goroutines, taken now
	DeferCleanup(func() {
		Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
	})
})

Equivalent BeforeEach/AfterEach form (carry the snapshot in a closure variable):

go
var goods []gleak.Goroutine
BeforeEach(func() { goods = gleak.Goroutines() })
AfterEach(func()  { Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods)) })

Simplest possible form — no snapshot, relies only on the built-in well-known list:

go
AfterEach(func() {
	Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked())
})

Gotchas

ALWAYS use Eventually, never Expect. Goroutines wind down asynchronously; a synchronous Expect races their shutdown and produces false positives. Eventually re-polls until they terminate or it times out (default 1s / 10ms poll — see gomega:async to tune).

Pass Goroutines, not Goroutines(). Note the missing (). Eventually must call it repeatedly on each poll. Writing Eventually(gleak.Goroutines()) snapshots once and defeats the retry. (Calling gleak.Goroutines() with parens is correct only when taking a baseline snapshot to pass into HaveLeaked.)

Capture the baseline at the right time — in BeforeEach, before the test spins anything up, so genuinely pre-existing goroutines are filtered out.

HaveLeaked succeeds when goroutines leaked. A success is a failure of your test — so it's almost always used with ShouldNot/NotTo. The built-in well-known list is always applied and cannot be disabled.

HaveLeaked([ignoring...])

go
gleak.HaveLeaked(NONLEAKY1, NONLEAKY2, ...)

After filtering out well-known goroutines and everything matched by the ignoring args, it matches if any goroutines remain. Each arg is either a goroutine matcher or a shorthand:

  • "foo.bar" → IgnoringTopFunction("foo.bar") (exact topmost-function name)
  • "foo.bar..." → top function name starts with prefix foo.bar.
  • "foo.bar [chan receive]" → exact top function and goroutine state begins with chan receive
  • []Goroutine (a snapshot) → IgnoringGoroutines(snapshot), filtered by goroutine ID
  • any GomegaMatcher that operates on an actual of type gleak.Goroutine (e.g. HaveField, WithTransform)
Show full SKILL.md (238 more words)Show less

Goroutine matchers (for the ignoring list)

  • IgnoringTopFunction(name) — matches a goroutine whose topmost stack function is name; supports the "name", "prefix...", and "name [state]" forms above.
  • IgnoringInBacktrace(substr) — matches if substr appears anywhere in the backtrace (lazy strings.Contains).
  • IgnoringGoroutines(snapshot) — matches goroutines that are elements of snapshot, compared by goroutine ID.
  • IgnoringCreator(name) — matches by the name of the function that created the goroutine; supports "name" and "prefix..." forms.
go
Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(
	gleak.IgnoringTopFunction("github.com/me/pkg.worker"),
	gleak.IgnoringInBacktrace("github.com/some/dep.background"),
	goods, // the snapshot, as IgnoringGoroutines shorthand
))

Ginkgo -p (parallel)

Running with ginkgo -p adds a background goroutine for Ginkgo↔package communication that will look leaked. Call gleak.IgnoreGinkgoParallelClient() at the start of each package's BeforeSuite so gleak adds it to the ignore list:

go
var _ = BeforeSuite(func() {
	gleak.IgnoreGinkgoParallelClient()
})

Well-known non-leaky goroutines (ignored by default)

Always filtered, by topmost function name (or backtrace), so you don't list them:

  • signal handling: os/signal.signal_recv, os/signal.loop, runtime.ensureSigM
  • Go testing: testing.RunTests, testing.(*T).Run, testing.(*T).Parallel (all [chan receive])
  • Ginkgo internals: (*Suite).runNode, the interrupt-handler/progress-signal goroutines, output-interceptor ResumeIntercepting, and the v1 spec-runner interrupt handler
  • anything with runtime.ReadTrace in its backtrace

Reporting

On a leak, gleak prints only the leaked goroutines (not all, unlike a panic), in a compact one-line-per-frame form. This output is not subject to format.MaxLength. By default locations show package + file + line (main.foo.func1() at foo/bar.go:123). Set gleak.ReportFilenameWithPath = true for full absolute paths.

Goroutine IDs

gleak.Goroutine values carry a goroutine ID (goid) parsed from the runtime stack; IgnoringGoroutines matches snapshots by these IDs. IDs are not reused (barring 64-bit counter wraparound) but are not densely sequential. Use them for testing/debugging only — never for program logic.

© onsi, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/gomega/skills/gleak of onsi/gomega.

Open the folder on GitHubat commit 37fa900

Compare with similar skills

Gleak 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.

Gleak compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Gleak this skillonsi/gomega2.4k—~1.5kAutomated safety check: PassMIT
YugabyteDB ASH Instrumentationyugabyte/yugabyte-db11k—~4.5kAutomated safety check: PassCustom licence
Mirage VFS Adapter Authoringstrukto-ai/mirage3.7k—~2.5kAutomated safety check: PassApache-2.0
Golang Patternsantoniopaya22/go-rest-template1729 repos~3.5kAutomated safety check: PassNone
Rust Async Patternsdiodeme/Gold-Band14310 repos~3.1kAutomated safety check: PassAGPL-3.0
Swift Concurrencyhenrypldev/react-native-nitro-mlx1003 repos~3.1kAutomated safety check: PassMIT

Similar skills

  • YugabyteDB ASH Instrumentation

    yugabyte/yugabyte-db

    Procedure for adding or changing YugabyteDB Active Session History wait states in TServer and DocDB C++ code, including the macro to use for sync and async paths.

    11k GitHub stars~4.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Builds or extends a custom Mirage virtual filesystem adapter for an API, database, object store or app data, with a working mount configuration and filesystem tests.

    3.7k GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Golang Patterns

    antoniopaya22/go-rest-template

    Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.

    172 GitHub starsUsed in 9 repos~3.5k tokens
    DevelopmentAuto-check passed
  • Rust Async Patterns

    diodeme/Gold-Band

    Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns.

    143 GitHub starsUsed in 10 repos~3.1k tokens
    DevelopmentAuto-check passed
  • Swift Concurrency

    henrypldev/react-native-nitro-mlx

    Diagnose Swift Concurrency issues, refactor callback-based code to async/await, and guide Swift 6 migration when working with tasks, actors, @MainActor, Sendable, data races, thread safety, or…

    100 GitHub starsUsed in 3 repos~3.1k tokens
    DevelopmentAuto-check passed
  • Rust Engineer

    farm-fe/farm

    Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions.

    5.6k GitHub starsUsed in 1 repo~1.5k tokens
    DevelopmentAuto-check passed

More from onsi/gomega

All 12 skills in this repo
  • Assertions

    onsi/gomega

    Write correct synchronous Gomega assertions — Expect/Ω notation, the To/NotTo/ToNot/Should/ShouldNot equivalences, the multi-return error idiom, Succeed vs HaveOccurred, the .Error() chaining form…

    2.4k GitHub stars~2.1k tokensUpdated 14 days ago
    Auto-check passed
  • Async

    onsi/gomega

    Polling assertions in Gomega — Eventually (poll until it passes) and Consistently (must keep passing), the func(g Gomega) callback idiom, WithTimeout/WithPolling/Within/ProbeEvery, WithContext and…

    2.4k GitHub stars~2.2k tokensUpdated 14 days ago
    Auto-check passed
  • Build compound Gomega assertions by combining matchers — And/SatisfyAll (all pass), Or/SatisfyAny (any pass), Not (negate), WithTransform to map the actual before matching, Satisfy for an ad-hoc…

    2.4k GitHub stars~1.5k tokensUpdated 14 days ago
    Auto-check passed
  • Custom Matchers

    onsi/gomega

    Writing your own Gomega matchers — the GomegaMatcher interface (Match/FailureMessage/NegatedFailureMessage), gcustom.MakeMatcher with message templates and template data, the format package helpers…

    2.4k GitHub stars~2.4k tokensUpdated 14 days ago
    Auto-check passed
  • Gbytes

    onsi/gomega

    Testing streaming io buffers with gbytes — gbytes.NewBuffer() (an io.Writer also returned by gexec sessions), the Say(regexp) matcher that forward-scans from a moving read cursor, the canonical…

    2.4k GitHub stars~1.5k tokensUpdated 14 days ago
    Auto-check passed
  • Gexec

    onsi/gomega

    Testing external processes with gexec — compile binaries with Build/BuildWithEnvironment/BuildIn and CleanupBuildArtifacts, start them with Start returning a Session, await exit with the Exit…

    2.4k GitHub stars~1.3k tokensUpdated 14 days ago
    Auto-check passed

Categories

Questions about Gleak

What does Gleak do?

gleak goroutine leak detection — capture a Goroutines() snapshot before a test, then Eventually(Goroutines).ShouldNot(HaveLeaked(snapshot)) to assert none leaked, with the…. Gleak is an agent skill from onsi/gomega.ShouldNot(HaveLeaked(snapshot)) to assert none leaked, with the BeforeEach/AfterEach/DeferCleanup pattern, ignoring matchers IgnoringTopFunction/IgnoringInBacktrace/IgnoringGoroutines/IgnoringCreator, well-known non-leaky goroutines, goroutine IDs, ReportFilenameWithPath, and the Ginkgo -p IgnoreGinkgoParallelClient gotcha.

When should I use Gleak?

Gleak fits situations like: A test must verify goroutines started during the test have all wound down and nothing leaked; tasks that involve Async programming.

How do I install Gleak in Claude Code?

Run `npx skills add onsi/gomega --skill gleak -a claude-code`. Or copy the skill folder (plugins/gomega/skills/gleak in onsi/gomega) into .claude/skills/gleak in your project. Claude Code loads it when a task matches its description.

How do I install Gleak in Codex?

Run `npx skills add onsi/gomega --skill gleak -a codex`. Or copy the skill folder (plugins/gomega/skills/gleak in onsi/gomega) into .agents/skills/gleak in your project. Codex loads it when a task matches its description.

Can I use Gleak 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 onsi/gomega --skill gleak -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/gleak, .gemini/skills/gleak, .github/skills/gleak and .opencode/skills/gleak in your project.

What does Gleak need to run?

SKILL.md names no scripts, command-line tools or credentials: Gleak is instructions for the agent only.

Does Gleak access the network?

SKILL.md names 1 domain. As links in the text: onsi.github.io. This is read from the text; nothing was executed.

Is Gleak 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 Gleak use?

Gleak is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Gleak use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Gleak?

Skills that share tags, products or a category with Gleak: YugabyteDB ASH Instrumentation (yugabyte/yugabyte-db, 11k stars), Mirage VFS Adapter Authoring (strukto-ai/mirage, 3.7k stars), Golang Patterns (antoniopaya22/go-rest-template, 172 stars) and Rust Async Patterns (diodeme/Gold-Band, 143 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Gleak?

onsi (a GitHub user) maintains it in onsi/gomega, which has 2,357 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on September 24, 2026.

Source: onsi/gomega on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.