Agent skill

Gstruct

by onsi in onsi/gomega

Deep, partial matching of nested structs, slices, maps, and pointers with gstruct — MatchAllFields/MatchFields/Fields, MatchAllElements/MatchElements/Elements (idFn), MatchAllKeys/MatchKeys/Keys…

MITAuto-check passedDevelopment

Install Gstruct

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

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

GitHub CLI
$ gh skill install onsi/gomega gstruct --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/gstruct .claude/skills/gstruct && 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
gstruct
GitHub stars
2.4k
Token cost
~1.7k tokens
SKILL.md length
463 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Deep, partial matching of nested structs, slices, maps, and pointers with gstruct — MatchAllFields/MatchFields/Fields, MatchAllElements/MatchElements/Elements (idFn), MatchAllKeys/MatchKeys/Keys…

  • Asserting against large
  • SKILL.md covers Structs — Fields, Slices — Elements + an id…, Maps — Keys and Pointers — PointTo, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Deeply nested data structures where you want to apply a different matcher to each field

What it does

Gstruct is an agent skill from onsi/gomega. Deep, partial matching of nested structs, slices, maps, and pointers with gstruct — MatchAllFields/MatchFields/Fields, MatchAllElements/MatchElements/Elements (idFn), MatchAllKeys/MatchKeys/Keys, PointTo, and the IgnoreExtras/IgnoreMissing/IgnoreUnexportedExtras/AllowDuplicates options, plus Ignore()/Reject(). Use when asserting against large or deeply nested data structures where you want to apply a different matcher to each field, element, or key.

Its SKILL.md is about 1.7k 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. The repository describes itself as: Ginkgo's Preferred Matcher Library. The licence is MIT.

When your agent uses it

  • Asserting against large
  • Deeply nested data structures where you want to apply a different matcher to each field

Example prompts

  • “/gstruct”

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

Gstruct loads about 1.7k tokens when it runs. Until then it costs about 115 tokens; SKILL.md has 463 words of instructions outside code blocks.

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

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). 463 words, ~1,675 tokens.

Download SKILL.mdSave it as .claude/skills/gstruct/SKILL.md (or your agent's skills folder).
name
gstruct
description
Deep, partial matching of nested structs, slices, maps, and pointers with gstruct — MatchAllFields/MatchFields/Fields, MatchAllElements/MatchElements/Elements (idFn), MatchAllKeys/MatchKeys/Keys, PointTo, and the IgnoreExtras/IgnoreMissing/IgnoreUnexportedExtras/AllowDuplicates options, plus Ignore()/Reject(). Use when asserting against large or deeply nested data structures where you want to apply a different matcher to each field, element, or key.

gstruct: matching complex data types

gstruct builds composite matchers that apply a separate matcher to each field of a struct, each element of a slice, each key of a map, or the target of a pointer. It is the tool for fuzzy-matching large, deeply nested values. Docs: https://onsi.github.io/gomega/#gstruct-testing-complex-data-types.

Dot-import gomega; import gstruct normally (or dot-import it too):

go
import (
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gstruct"
)

The values in Fields/Elements/Keys are themselves matchers. That is the whole point: compose with the core catalog (gomega:matchers) and combinators like And/Or/Not/WithTransform (gomega:composing-matchers). Examples below assume gstruct is dot-imported for brevity.

If you find yourself building an overly complex gstruct matcher, consider if you should be building a custom matcher (gomega:custom-matchers) instead.

Structs — Fields

Fields is map[string]types.GomegaMatcher keyed by field name.

go
actual := struct {
	A int
	B bool
	C string
}{5, true, "foo"}

Expect(actual).To(MatchAllFields(Fields{
	"A": BeNumerically("<", 10),
	"B": BeTrue(),
	"C": Equal("foo"),
}))

MatchAllFields requires an exact 1:1 mapping — every field must have a matcher and every matcher must map to a field. This is great for maintainability: adding or removing a struct field breaks the test until you update it.

To match a subset/superset, use MatchFields(options, Fields{...}):

go
// IgnoreExtras: ignore struct fields with no matcher
Expect(actual).To(MatchFields(IgnoreExtras, Fields{
	"A": BeNumerically("<", 10),
	"B": BeTrue(), // no entry for C — fine
}))

// IgnoreMissing: ignore matchers with no corresponding field
Expect(actual).To(MatchFields(IgnoreMissing, Fields{
	"A": BeNumerically("<", 10),
	"B": BeTrue(),
	"C": Equal("foo"),
	"D": Equal("bar"), // ignored — actual has no field D
}))

IgnoreUnexportedExtras is a middle ground: it ignores only unexported extra fields (gstruct can't read them via reflect anyway) while still requiring all exported fields to be matched.

Slices — Elements + an id function

Elements is map[string]types.GomegaMatcher keyed by a string id. You supply an Identifier (func(element any) string) that maps each element to its key.

go
actual := []string{"A: foo bar baz", "B: once upon a time", "C: the end"}
id := func(element any) string { return string(element.(string)[0]) }

Expect(actual).To(MatchAllElements(id, Elements{
	"A": Not(BeZero()),
	"B": MatchRegexp("[A-Z]: [a-z ]+"),
	"C": ContainSubstring("end"),
}))

MatchAllElements requires a 1:1 mapping. Use MatchElements(id, options, Elements{...}) with IgnoreExtras/IgnoreMissing to relax, exactly as with fields. AllowDuplicates lets several elements share one key/matcher (all of them must pass).

Index-based variants MatchAllElementsWithIndex/MatchElementsWithIndex take an IdentifierWithIndex (func(index int, element any) string); the built-in IndexIdentity just uses the index as the key.

Maps — Keys

The *Fields API has a *Keys mirror for maps: MatchAllKeys(Keys{...}) and MatchKeys(options, Keys{...}).

go
actual := map[string]string{"A": "correct", "B": "incorrect"}

// MatchAllKeys requires every key be matched (this would fail without B):
Expect(actual).To(MatchAllKeys(Keys{
	"A": Equal("correct"),
	"B": Equal("incorrect"),
}))

// IgnoreMissing tolerates matchers for absent keys:
Expect(actual).To(MatchKeys(IgnoreMissing, Keys{
	"A": Equal("correct"),
	"B": Equal("incorrect"),
	"C": Equal("whatever"), // ignored — actual has no key C
}))
Show full SKILL.md (181 more words)Show less

Pointers — PointTo

PointTo(matcher) dereferences a pointer and applies matcher to the pointed-to value. It fails if the pointer is nil.

go
foo := 5
Expect(&foo).To(PointTo(Equal(5)))
var bar *int
Expect(bar).NotTo(PointTo(BeNil())) // nil pointer fails PointTo

Ignore() and Reject()

Ignore() always succeeds, Reject() always fails — use them as entries to skip a field/element or to assert one must never appear.

Putting it all together

The matchers nest arbitrarily, mixing struct/slice/map/pointer matchers with the core catalog:

go
coreID := func(element any) string { return strconv.Itoa(element.(CoreStats).Index) }

Expect(actual).To(MatchAllFields(Fields{
	"Name":      Ignore(),
	"StartTime": BeTemporally(">=", time.Now().Add(-100*time.Hour)),
	"CPU": PointTo(MatchAllFields(Fields{
		"Time":                 BeTemporally(">=", time.Now().Add(-time.Hour)),
		"UsageNanoCores":       BeNumerically("~", 1e9, 1e8),
		"UsageCoreNanoSeconds": BeNumerically(">", 1e6),
		"Cores": MatchElements(coreID, IgnoreExtras, Elements{
			"0": MatchAllFields(Fields{
				"Index":                Ignore(),
				"UsageNanoCores":       BeNumerically("<", 1e9),
				"UsageCoreNanoSeconds": BeNumerically(">", 1e5),
			}),
		}),
	})),
	"Memory": PointTo(MatchAllFields(Fields{
		"Time":            BeTemporally(">=", time.Now().Add(-time.Hour)),
		"AvailableBytes":  BeZero(),
		"UsageBytes":      BeNumerically(">", 5e6),
		"WorkingSetBytes": BeNumerically(">", 5e6),
	})),
	"Rootfs": Ignore(),
	"Logs":   Ignore(),
}))

Gotchas

  • MatchAllFields/MatchAllElements/MatchAllKeys fail on missing OR extra entries. They demand an exact 1:1 mapping. The instant you want a partial match, switch to MatchFields/MatchElements/MatchKeys and pass IgnoreExtras, IgnoreMissing, or both (IgnoreExtras|IgnoreMissing).
  • The id function must produce unique, stable keys. Two elements mapping to the same key collide and fail unless you pass AllowDuplicates. Don't derive keys from data that changes between runs.
  • Elements keys are strings. The id function returns a string, so numeric ids must be stringified (e.g. strconv.Itoa(i)), and the keys in your Elements{} literal must match those strings exactly.
  • PointTo rejects nil pointers — a nil actual fails the match outright, before the inner matcher ever runs.
  • Field/element/key matcher values are ordinary matchers, so compose freely with gomega:matchers and gomega:composing-matchers.

© 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/gstruct of onsi/gomega.

Open the folder on GitHubat commit 37fa900

Compare with similar skills

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

Gstruct compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Gstruct this skillonsi/gomega2.4k—~1.7kAutomated safety check: PassMIT
Vercel Composition Patternssupabase/supabase111k59 repos~726Automated safety check: PassMIT
Finishing a Development Branchobra/superpowers296k5 repos~1.9kAutomated safety check: PassMIT
Typescript Advanced Typesrolling-scopes/rsschool-app10k25 repos~4.2kAutomated safety check: PassMPL-2.0
PR Babysitteropeninterpreter/openinterpreter69k3 repos~4.2kAutomated safety check: PassApache-2.0
Code Review ChecklistshareAI-lab/learn-claude-code78k5 repos~1.1kAutomated safety check: PassMIT

Similar skills

  • Official

    React composition patterns that scale. An agent skill from supabase/supabase.

    111k GitHub starsUsed in 59 repos~726 tokens
    DevelopmentAuto-check passed
  • Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.

    296k GitHub starsUsed in 5 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Typescript Advanced Types

    rolling-scopes/rsschool-app

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications.

    10k GitHub starsUsed in 25 repos~4.2k tokens
    DevelopmentAuto-check passed
  • PR Babysitter

    openinterpreter/openinterpreter

    Watches an open GitHub pull request until it merges, handling review comments, diagnosing CI failures and retrying flaky checks along the way.

    69k GitHub starsUsed in 3 repos~4.2k tokens
    DevelopmentAuto-check passed
  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 5 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Greploop

    onyx-dot-app/onyx

    Iteratively improves a PR (GitHub), MR (GitLab), or shelved changelist (Perforce) until Greptile gives it a 5/5 confidence score with zero unresolved comments.

    32k GitHub starsUsed in 4 repos~3.3k 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 13 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 13 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 13 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 13 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 13 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 13 days ago
    Auto-check passed

Categories

Questions about Gstruct

What does Gstruct do?

Deep, partial matching of nested structs, slices, maps, and pointers with gstruct — MatchAllFields/MatchFields/Fields, MatchAllElements/MatchElements/Elements (idFn), MatchAllKeys/MatchKeys/Keys…. Gstruct is an agent skill from onsi/gomega. Deep, partial matching of nested structs, slices, maps, and pointers with gstruct — MatchAllFields/MatchFields/Fields, MatchAllElements/MatchElements/Elements (idFn), MatchAllKeys/MatchKeys/Keys, PointTo, and the IgnoreExtras/IgnoreMissing/IgnoreUnexportedExtras/AllowDuplicates options, plus Ignore()/Reject().

When should I use Gstruct?

Gstruct fits situations like: asserting against large; deeply nested data structures where you want to apply a different matcher to each field.

How do I install Gstruct in Claude Code?

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

How do I install Gstruct in Codex?

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

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

What does Gstruct need to run?

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

Does Gstruct 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 Gstruct 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 Gstruct use?

Gstruct 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 Gstruct use?

About 1.7k tokens (SKILL.md is roughly 6.7k 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 Gstruct?

Skills that share tags, products or a category with Gstruct: Vercel Composition Patterns (supabase/supabase, 111k stars), Finishing a Development Branch (obra/superpowers, 296k stars), Typescript Advanced Types (rolling-scopes/rsschool-app, 10k stars) and PR Babysitter (openinterpreter/openinterpreter, 69k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Gstruct?

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.