AI-Generated Go Serialization: Zero Boilerplate, Maximum Speed
<p>I wanted to share a quick story about a weekend experiment.</p> <p>There is a library called <a href="https://github.com/ymz-ncnk/mok" rel="noopener noreferrer">mok</a> that lacks a code generator, so every time you want to mock an interface, it requires you to write all the boilerplate yourself. It's simple but tedious work. I usually just offload it to an AI agent, and with a small example, it completes this task exceptionally well.</p> <p>This got me thinking - could AI handle something more complex, like writing serialization code? If it could, we'd basically get the best of both worlds: the raw speed of generated code, with the same simplicity you get from reflection-based libraries.</p> <p>But is it safe to trust AI with something as sensitive as serialization logic? With all its
I wanted to share a quick story about a weekend experiment.
There is a library called mok that lacks a code generator, so every time you want to mock an interface, it requires you to write all the boilerplate yourself. It's simple but tedious work. I usually just offload it to an AI agent, and with a small example, it completes this task exceptionally well.
This got me thinking - could AI handle something more complex, like writing serialization code? If it could, we'd basically get the best of both worlds: the raw speed of generated code, with the same simplicity you get from reflection-based libraries.
But is it safe to trust AI with something as sensitive as serialization logic? With all its non-determinism and unpredictable behavior, the answer is more likely a hard "No", unless we enforce two strict requirements:
-
Provide a solid foundation — give the AI a robust library to work with.
-
Test everything — all AI-generated code must be rigorously tested.
With those guidelines in place, I decided to give it a shot. After a few late nights, and honestly, way more fun than expected, I ended up building mus-skill: an AI skill for generating MUS serialization code.
At its core, the skill is just a set of rules for combining the serialization primitives provided by the mus and mus-stream libraries. In addition to the code itself, it also generates the accompanying tests so you can be sure everything works correctly.
Because the code looks exactly like the output of a traditional code generator you can expect from it the same high-performance.
| NAME | NS/OP | B/SIZE | B/OP | ALLOCS/OP | |--------------|----------|--------|---------|-----------| | mus | 102.90 | 58.00 | 48.00 | 1 | | protobuf | 531.70 | 69.00 | 271.00 | 4 | | json | 2779.00 | 150.00 | 600.00 | 9 || NAME | NS/OP | B/SIZE | B/OP | ALLOCS/OP | |--------------|----------|--------|---------|-----------| | mus | 102.90 | 58.00 | 48.00 | 1 | | protobuf | 531.70 | 69.00 | 271.00 | 4 | | json | 2779.00 | 150.00 | 600.00 | 9 |Full benchmarks https://github.com/ymz-ncnk/go-serialization-benchmarks`
Enter fullscreen mode
Exit fullscreen mode
This approach even works flawlessly on deeply nested, complex types (where AI usually hallucinates), such as:
// mus:vl = ValidateLen // mus:elemVl = ValidateComplexMapValue type ComplexMap map[string]map[*[]int][][]float32// mus:vl = ValidateLen // mus:elemVl = ValidateComplexMapValue type ComplexMap map[string]map[*[]int][][]float32Enter fullscreen mode
Exit fullscreen mode
And supports user hints, so you can easily customize the generated code to fit your exact needs (like specifying custom validators).
Getting started is simple. Just clone this repository into your project's agent directory (e.g., .agents/skills). Or, even easier, install it using the skills CLI tool:
npx skills add github.com/mus-format/mus-skill-go
Enter fullscreen mode
Exit fullscreen mode
Once installed, simply give your AI agent a prompt like this:
Generate MUS serializers for the types found in the .go file.
Enter fullscreen mode
Exit fullscreen mode
The result? Two newly generated files: mus.ai.gen.go and mus.ai.gen_test.go. As always, just be sure to double-check that the generated tests actually cover all your edge cases.
Have you ever tried a similar approach? I'd love to hear how it went for you!
DEV Community
https://dev.to/ymz-ncnk/ai-generated-go-serialization-zero-boilerplate-maximum-speed-49f8Sign in to highlight and annotate this article

Conversation starters
Daily AI Digest
Get the top 5 AI stories delivered to your inbox every morning.
More about
benchmarkcompanyinterfaceMarch 2026 sponsors-only newsletter
<p>I just sent the March edition of my <a href="https://github.com/sponsors/simonw/">sponsors-only monthly newsletter</a>. If you are a sponsor (or if you start a sponsorship now) you can <a href="https://github.com/simonw-private/monthly/blob/main/2026-03-march.md">access it here</a>. In this month's newsletter:</p> <ul> <li>More agentic engineering patterns</li> <li>Streaming experts with MoE models on a Mac</li> <li>Model releases in March</li> <li>Vibe porting</li> <li>Supply chain attacks against PyPI and NPM</li> <li>Stuff I shipped</li> <li>What I'm using, March 2026 edition</li> <li>And a couple of museums</li> </ul> <p>Here's <a href="https://gist.github.com/simonw/8b5fa061937842659dbcd5bd676ce0e8">a copy of the February newsletter</a> as a preview of what you'll get. Pay $10/mont
How to Build Production Ready AgentScope Workflows with ReAct Agents, Custom Tools, Multi-Agent Debate, Structured Output and Concurrent Pipelines
In this tutorial, we build a complete AgentScope workflow from the ground up and run everything in Colab. We start by wiring OpenAI through AgentScope and validating a basic model call to understand how messages and responses are handled. From there, we define custom tool functions, register them in a toolkit, and inspect the auto-generated […] The post How to Build Production Ready AgentScope Workflows with ReAct Agents, Custom Tools, Multi-Agent Debate, Structured Output and Concurrent Pipelines appeared first on MarkTechPost .
Knowledge Map
Connected Articles — Knowledge Graph
This article is connected to other articles through shared AI topics and tags.
More in Products

Nvidia App adds 'Auto Shader Compilation' for faster load times in games — beta feature automatically recompiles shaders in the background after every driver update
Nvidia App adds 'Auto Shader Compilation' for faster load times in games — beta feature automatically recompiles shaders in the background after every driver update
Ensuring Trustworthiness of AI-Enhanced Embedded Systems
A road-vehicle standard-based unified AI safety lifecycle and blueprint for integrating both robustness and resilience into AI systems deployed in safety-critical domains. The post Ensuring Trustworthiness of AI-Enhanced Embedded Systems appeared first on Semiconductor Engineering .
Enabling Physical AI and Robotics: Platform for the Intelligent Edge
How physical AI systems combine sensors, edge processing, and connectivity to enable real-time, intelligent decision-making directly on devices like robots and smart edge systems. The post Enabling Physical AI and Robotics: Platform for the Intelligent Edge appeared first on Semiconductor Engineering .
How to Build Production Ready AgentScope Workflows with ReAct Agents, Custom Tools, Multi-Agent Debate, Structured Output and Concurrent Pipelines
In this tutorial, we build a complete AgentScope workflow from the ground up and run everything in Colab. We start by wiring OpenAI through AgentScope and validating a basic model call to understand how messages and responses are handled. From there, we define custom tool functions, register them in a toolkit, and inspect the auto-generated […] The post How to Build Production Ready AgentScope Workflows with ReAct Agents, Custom Tools, Multi-Agent Debate, Structured Output and Concurrent Pipelines appeared first on MarkTechPost .

Discussion
Sign in to join the discussion
No comments yet — be the first to share your thoughts!