msgspec-struct-gc-check

Checks Python msgspec.Struct definitions for safe gc=False usage.

20|27|Updated Oct 30, 2025
One-click install
npx skills add https://github.com/mlcommons/endpoints --skill msgspec-struct-gc-check
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: msgspec-struct-gc-check
Source: https://github.com/mlcommons/endpoints/tree/main/.claude/skills/msgspec-struct-gc-check
Command: npx skills add https://github.com/mlcommons/endpoints --skill msgspec-struct-gc-check

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps determine whether msgspec.Struct types can safely disable garbage collection without introducing reference cycles or hidden memory leaks.

Core Features & Use Cases

  • Cycle Safety Review: Checks field types, nested structs, and container relationships for leak-prone cycles.
  • Mutation Audit: Reviews whether list, dict, or set fields are ever mutated in ways that could create back-references.
  • Use Case: Use it when adding a new msgspec.Struct, refactoring an existing one, or deciding whether to add or remove gc=False.

Quick Start

Ask me to audit the msgspec.Struct definitions in this repository and tell me whether each one can safely use gc=False.

Frequently Asked Questions about msgspec-struct-gc-check

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I know if my msgspec.Struct can safely use gc=False?

To safely use gc=False on a msgspec.Struct, you must verify the object graph is cycle-free, container fields do not mutate to create back-references, and type definitions are __slots__ compatible.

When should I not disable garbage collection on a Python struct?

You should not disable garbage collection on a Python struct if its fields include nested containers that mutate, or if the object graph risks creating reference cycles that standard garbage collection would normally clean up.

How does static analysis detect reference cycles in msgspec.Struct definitions?

Static analysis detects reference cycles by reviewing field types, nested structs, and container relationships within the msgspec.Struct definition to identify leak-prone back-references before recommending gc=False.

Can I use gc=False with msgspec.Struct types that have generic mixins?

Yes, you can use gc=False with msgspec.Struct types containing generic mixins, provided the audit confirms the mixins maintain a cycle-free object graph and do not introduce mutating container behavior.

What is the best way to audit msgspec.Struct fields for hidden memory leaks?

The best way to audit for hidden memory leaks is to perform a mutation audit on list, dict, or set fields to ensure they are never mutated in ways that could create back-references, alongside cycle safety checks.

Does msgspec.Struct gc=False work with nested containers?

msgspec.Struct gc=False works with nested containers only if a static analysis audit verifies the container behavior is non-mutating and the nested relationships remain strictly cycle-free.