z-go-codegen-patterns

Installation
SKILL.md

Go Code Generation Patterns

Code generators produce Go source files from templates, AST manipulation, or a combination. The key principle: manipulate Go as a structured program, not as text.

When to Use

  • Writing or editing a code generator or scaffold tool
  • Authoring Go templates (*.go.tmpl)
  • Designing a YAML-driven manifest or block schema
  • Adding AST injection to a generator pipeline
  • Writing golden-file tests for generated output
  • Debugging injection failures or template rendering errors

AST Over String Edit

Never build generated Go source with strings.Replace or template string concatenation — it's fragile and breaks on formatting changes:

Installs
14
First Seen
Jul 2, 2026