Live
Black Hat USAAI BusinessBlack Hat AsiaAI BusinessReact Native Background Task Processing Methods (2026)DEV CommunityFlutter AI Virtual Try-On: 6-Week Build, Zero BSDEV CommunityHow to Choose the Best Speech-to-text API for Voice AgentsHackernoon AIDetecting Bots in 2026: IP Intelligence + Email Validation in One API CallDEV CommunityI built 2 free web tools to solve problems that annoyed me — here's what I learnedDEV CommunityHow to Build Production Ready AgentScope Workflows with ReAct Agents, Custom Tools, Multi-Agent Debate, Structured Output and Concurrent PipelinesMarkTechPost🌐 Beyond One Data Source: Building Scalable Data Pipelines in Power BIDEV CommunityTop LLM Gateways That Support Semantic Caching in 2026DEV CommunityDevelopers Who Don’t Adapt to AI Won’t Disappear, They’ll Be IgnoredDEV CommunityBug Hunter: I Turned Every Website Into A Debugging Horror GameDEV CommunityI voice-code from my phone while walking my dogDEV CommunityThe quest for general intelligence is hitting a wallLessWrong AIBlack Hat USAAI BusinessBlack Hat AsiaAI BusinessReact Native Background Task Processing Methods (2026)DEV CommunityFlutter AI Virtual Try-On: 6-Week Build, Zero BSDEV CommunityHow to Choose the Best Speech-to-text API for Voice AgentsHackernoon AIDetecting Bots in 2026: IP Intelligence + Email Validation in One API CallDEV CommunityI built 2 free web tools to solve problems that annoyed me — here's what I learnedDEV CommunityHow to Build Production Ready AgentScope Workflows with ReAct Agents, Custom Tools, Multi-Agent Debate, Structured Output and Concurrent PipelinesMarkTechPost🌐 Beyond One Data Source: Building Scalable Data Pipelines in Power BIDEV CommunityTop LLM Gateways That Support Semantic Caching in 2026DEV CommunityDevelopers Who Don’t Adapt to AI Won’t Disappear, They’ll Be IgnoredDEV CommunityBug Hunter: I Turned Every Website Into A Debugging Horror GameDEV CommunityI voice-code from my phone while walking my dogDEV CommunityThe quest for general intelligence is hitting a wallLessWrong AI

AI-Generated Go Serialization: Zero Boilerplate, Maximum Speed

DEV Communityby Yuri ZinchenkoApril 1, 20263 min read0 views
Source Quiz

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

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
*

Enter 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!

Was this article helpful?

Sign in to highlight and annotate this article

AI
Ask AI about this article
Powered by AI News Hub · full article context loaded
Ready

Conversation starters

Ask anything about this article…

Daily AI Digest

Get the top 5 AI stories delivered to your inbox every morning.

More about

benchmarkcompanyinterface

Knowledge Map

Knowledge Map
TopicsEntitiesSource
AI-Generate…benchmarkcompanyinterfaceagentgithubrepositoryDEV Communi…

Connected Articles — Knowledge Graph

This article is connected to other articles through shared AI topics and tags.

Knowledge Graph100 articles · 218 connections
Scroll to zoom · drag to pan · click to open

Discussion

Sign in to join the discussion

No comments yet — be the first to share your thoughts!

More in Products