>_ DevTrendsen

Language

Home

Languages

Sections

Frontend Backend Mobile DevOps AI / ML GameDev Blockchain Embedded Security
Go

How to Stop Neural Networks from Writing Bad Go Code

Anyone who has tried generating Go code through Cursor, Claude Code, or Copilot has probably encountered their specific quirks. Neural networks persistently try to drag Java patterns into Go, forget to wrap errors with %w, ignore race conditions in goroutines, and generate monstrous structures where a simple function would suffice.

Manually prompting the model every time is a dubious pleasure. You want to give the assistant a proper set of rules once and forget about constant corrections in code review. That's exactly why French developer Samuel Berthe (author of the popular samber/lo library) created the cc-skills-golang project.

image

What Are Agent Skills and Why Do You Need Them

The Agent Skills concept grew out of a simple problem: a neural network's system prompt isn't infinite. If you load a detailed style guide, security rules, database operation specifics, and framework features into the context, the model simply won't have room left for your actual code. Responses will become slower, and generation quality will drop.

Skills solve this through lazy loading. The project is a collection of small Markdown files. At the start of a session, only a brief summary of each module (about 100 tokens per skill) is loaded into the LLM's memory. As soon as you ask the assistant to "write a benchmark for this function" or "add error handling to the gRPC handler," the model sees the matching trigger and loads the detailed document with instructions specifically for that task.

No AI Slop

The main detail in the repository README is the author's honest warning: "No AI slop here."

Today, GitHub is flooded with automatically generated knowledge bases that do more harm than good. Samuel did things differently. He did use Claude for the initial distillation of rules from his commits in real Go projects, but then manually rewrote, edited, and tested every instruction.

The author even ran accuracy measurements on a test suite:

  • Without pluggable skills, the language model correctly completed test tasks 56% of the time.
  • With the ruleset enabled, the score rose to 98%.

Especially strong accuracy improvements were seen in specific topics: modernizing old code for new Go features (range-over-int, iterators), writing benchmarks, and error handling.

What's Inside the Repository

All instructions are broken down into two main categories: general language rules and working with specific libraries.

General Language and Architecture Rules

The modules cover almost the entire Go development cycle:

  • Code quality and style: naming conventions, safe operations with nil and slices, memory leak prevention, proper documentation, and golangci-lint configuration.
  • Architecture and patterns: context handling, concurrency without goroutine leaks, designing structures and interfaces, refactoring patterns through gopls.
  • Testing and debugging: table-driven tests, race detection, profiling through pprof, OpenTelemetry setup, and metrics collection.
  • Project setup: idiomatic directory structure (cmd/internal/pkg), CI/CD pipelines, and module management.

Popular Library Support

Beyond the language standards themselves, the repository embeds rules for working with common tooling:

  • CLI and configs: spf13/cobra and spf13/viper.
  • Dependency Injection: google/wire, uber/dig, uber/fx, and their own container samber/do.
  • Network protocols: gRPC, GraphQL (gqlgen), and OpenAPI/Swagger.
  • samber ecosystem: functional helpers samber/lo, monads samber/mo, logging samber/slog, and error chaining samber/oops.

An interesting point: skills are designed not to duplicate each other. If an error handling rule affects logging, it's described in the golang-error-handling module, and the golang-observability module simply references it. This saves tokens.

How to Install

The project supports almost all popular tools that work with the Agent Skills standard.

The most universal way is the skills utility:

npx skills add https://github.com/samber/cc-skills-golang --all

If you work in Cursor, simply clone the repository into the skills folder:

git clone https://github.com/samber/cc-skills-golang.git ~/.cursor/skills/cc-skills-golang

For Claude Code, installation is done with the plugin's standard command:

/plugin marketplace add samber/cc
/plugin install cc-skills-golang@samber

Copilot, Gemini CLI, OpenCode, and OpenAI's Codex are supported in the same way.

Using on CI for Auto-Review

An interesting use case described by the author is running AI agents as reviewers on GitHub Actions.

Regular linters are great at catching formatting or unused variables. However, they're helpless if a neural network quietly breaks architectural cohesion during refactoring or forgets to cancel the context when exiting a function. An agent connected to the PR with this skill set checks the code specifically for Go idiom compliance and highlights architectural issues before the PR reaches your colleagues.

Is It Worth Trying

If you actively use neural networks in Go development and are tired of fixing trivial mistakes for them, installing this set is definitely worth it. It won't turn AI into a senior architect, but it will significantly reduce the number of silly typos and non-idiomatic code.

It's especially nice that the project doesn't try to overload the context and leaves the ability to override any skill with your company's rules. Simply create your own internal module and specify that it takes priority over the standard one.

Related projects