# Modern Go Guidelines

> An open-source skill package that teaches AI coding agents to write modern Go code using up-to-date language features and idioms from Go 1.0 through Go 1.27.

Modern Go Guidelines is an official JetBrains open-source project that provides structured guidelines for AI coding agents, helping them produce idiomatic, up-to-date Go code. It is licensed under Apache 2.0 and available freely on GitHub. The project addresses a well-documented problem: coding agents tend to generate outdated Go patterns due to training data lag and frequency bias toward older idioms.

## What It Is

Modern Go Guidelines is a skill package — a curated reference document and CLI wrapper — that agents can load to understand Go language features from version 1.0 through 1.27. Rather than a standalone IDE or editor, it is a plugin/skill that integrates into existing AI coding agents such as Junie, Claude Code, Codex, Cursor, and others via skills.sh. When active, the agent automatically detects the project's Go version from `go.mod` and applies only the features available up to that version.

## Why It Exists: The Outdated Go Problem

The README identifies two root causes for agents generating stale Go code:

- **Training data lag**: Models cannot use features added after their training cutoff. For example, `errors.AsType[T]` (Go 1.26) is unknown to models trained before that release.
- **Frequency bias**: Even for known features, models default to older patterns because older idioms appear more frequently in training data — e.g., `for i := 0; i < n; i++` over `for i := range n`.

The guidelines fix both by giving the agent an explicit, versioned reference. This aligns with the Go team's own `modernize` analyzer, which automatically updates existing code to newer idioms. Modern Go Guidelines serves the same goal for new code: agents write modern Go from the start.

## Concrete Examples of What It Changes

With these guidelines loaded, an agent will:

- Use `max(a, b)` instead of an if-else block
- Use `slices.Contains` instead of a manual loop
- Use `cmp.Or(a, b, c)` instead of a chain of nil checks
- Use `new(42)` to get a pointer to a value (Go 1.26)
- Use `errors.AsType[T](err)` for type-safe error matching (Go 1.26)

## Supported Agents and Setup Path

The guidelines are distributed as installable plugins or skills for multiple agents:

- **Junie** (JetBrains' own agent): install via `/extensions marketplace add` inside a Junie CLI session
- **Claude Code**: install via `/plugin marketplace add` and `/plugin install`
- **Codex**: install via `codex plugin marketplace add` and `codex plugin add`
- **Cursor**: install via `cursor-agent plugin marketplace add` and the `/plugins` command
- **Other agents** (e.g., OpenCode): install via `npx skills add JetBrains/go-modern-guidelines`

All marketplace integrations run a small CLI installed on first use via `go install`. The Go toolchain must be present on `PATH`. The CLI targets Go 1.25 or newer but works on older versions when `GOTOOLCHAIN=auto` is set (the default), allowing Go to fetch a compatible toolchain automatically.

## Open-Source Deployment Model

The project is fully open source under Apache License 2.0. The CLI is installed into a local cache (e.g., `~/.cache/go-modern-guidelines`) and never modifies the user's project. A local development mode (`GO_MODERN_GUIDELINES_DEV=1`) lets contributors test changes to the CLI across all supported agents without releasing a new version. The repository had 2,477 stars and 75 forks as of its last recorded metadata, indicating meaningful community interest for a developer tooling project.

## Features
- Provides versioned Go guidelines covering Go 1.0 through Go 1.27
- Detects project Go version from go.mod and applies appropriate features
- Integrates with Junie, Claude Code, Codex, Cursor, and other agents
- Installs via CLI with no project modifications
- Supports local development mode for contributors
- Covers all features targeted by the Go modernize analyzer
- Auto-invoked by agents when relevant to a Go task
- Supports explicit invocation commands per agent
- Works with skills.sh for other agents like OpenCode

## Integrations
Junie, Claude Code, Codex, Cursor, OpenCode, skills.sh, Go toolchain, go.mod

## Platforms
WINDOWS, API, JETBRAINS_PLUGIN, CLI

## Pricing
Open Source

## Version
main

## Links
- Website: https://github.com/JetBrains/go-modern-guidelines
- Documentation: https://github.com/JetBrains/go-modern-guidelines/blob/main/plugin/skills/use-modern-go/SKILL.md
- Repository: https://github.com/JetBrains/go-modern-guidelines
- EveryDev.ai: https://www.everydev.ai/tools/modern-go-guidelines
