structpolicy-tune

Analyze Go struct usage and align pointer/value semantics with ptrstruct and valuestruct.

Updated Mar 16, 2026
One-click install
npx skills add https://github.com/shuymn/structpolicy --skill structpolicy-tune
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: structpolicy-tune
Source: https://github.com/shuymn/structpolicy/tree/main/skills/structpolicy-tune
Command: npx skills add https://github.com/shuymn/structpolicy --skill structpolicy-tune

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go code often suffers from mismatched struct usage semantics, leading to unnecessary allocations or copies. This Skill analyzes and tunes struct usage by enforcing pointer/value semantics with ptrstruct and valuestruct, ensuring consistent performance characteristics across APIs.

Core Features & Use Cases

  • Run ptrstruct and valuestruct analyses together to surface where value receivers, pointer parameters, or pointer returns violate consistent semantics.
  • Apply targeted fixes to receivers, parameters, and returns to reduce allocations and improve clarity.
  • Provide guidance on benchmarking and safe migration, including test updates and compatibility checks.

Quick Start

Run the structpolicy-tune workflow on your Go project to align pointer/value usage and reduce allocations.

Frequently Asked Questions about structpolicy-tune

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

FAQPage Schema
How do I fix inconsistent Go struct pointer and value semantics to reduce allocations?

You can fix inconsistent Go struct pointer and value semantics by running ptrstruct and valuestruct analyses together to identify violations across receivers, parameters, and returns, then applying targeted fixes to reduce heap allocations.

Why do mismatched pointer and value receivers cause unnecessary heap allocations in Go?

Mismatched pointer and value receivers cause heap allocations because inconsistent struct semantics force unnecessary copying or escaping to the heap when values are passed between functions with different receiver types.

How do I align struct usage in Go performance-critical packages without breaking behavior?

Align struct usage in hot paths by running static analysis to detect semantic mismatches, applying targeted fixes to receivers and parameters, and using baseline benchmarking to verify allocation reductions while preserving behavior.

Can I run ptrstruct and valuestruct analyzers simultaneously on an existing Go codebase?

Yes, you can run ptrstruct and valuestruct analyzers simultaneously on an existing Go codebase to surface where value receivers, pointer parameters, or pointer returns violate consistent semantics across APIs.

What is the best way to enforce consistent struct semantics across Go APIs?

The best way to enforce consistent struct semantics is to analyze pointer and value usage with dedicated static analyzers, apply fixes to receivers and parameters, and validate changes through baseline benchmarking and test updates.

What are the limitations of using static analysis for Go struct allocation tuning?

Static analysis for Go struct allocation tuning focuses on semantic consistency and allocation reduction, but safe migration requires manual compatibility checks, test updates, and benchmarking to ensure behavior is preserved.