# Modern Go Guidelines

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

> **TL;DR**
> Modern Go Guidelines is an open-source package for AI coding agents. It provides Go guidance that is compatible with the Go version in your project.
>
>
>
> See the [Modern Go Guidelines repository on
> GitHub](https://github.com/JetBrains/go-modern-guidelines).

## Purpose

AI coding agents can select outdated Go patterns. Their training data might not include features that were added after the model's knowledge cutoff. Even when an agent knows a newer pattern, it can choose an older pattern that appears more often in training data.

Modern Go Guidelines provides a reference for language features and standard library APIs.

## Go version support

The agent reads the Go version declared in your project's `go.mod` file. It receives guidance only for features that are available in that version.

For example, an agent working in a project that uses Go 1.25 can use `sync.WaitGroup.Go`. It does not receive guidance for `errors.AsType`, which requires Go 1.26.

## Guideline lookup

Modern Go Guidelines includes a command-line tool with the `list` and `explain` subcommands. The agent uses the tool through the installed skill.

Before it edits a Go file, the agent calls `list` for that file. The command returns short guidelines that apply to the Go version in your project:

```SHELL
go-modern-guidelines list --file-path ./internal/worker/worker.go
```

The agent can also specify a Go version directly:

```SHELL
go-modern-guidelines list --go-version 1.27
```

The output starts with the newest applicable guidelines. Each guideline has a stable ID:

```TEXT
sync_waitgroup_go: Use wg.Go when spawning goroutines tracked by a sync.WaitGroup.
testing_t_context: Use t.Context() when a test function needs a context tied to the test lifetime.
json_omitzero: Use omitzero on JSON-tagged bool, numeric, struct, and time fields whose zero value should be omitted.
```

When the agent needs more information about a guideline, it calls `explain` with the guideline ID. The command returns a description and before-and-after examples:

```SHELL
go-modern-guidelines explain sync_waitgroup_go
```

This workflow limits the guidance to the information that applies to the task.

## Guideline content

Modern Go Guidelines cover useful language features and standard library additions from Go 1.0 through Go 1.27. They also include patterns covered by the Go `modernize` analyzer.

The guidelines help an agent use modern patterns, such as:

* `slices.Contains` instead of a manual search loop.

* `min` and `max` instead of handwritten comparisons.

* `cmp.Or` instead of a chain that selects the first nonzero value.

* `sync.WaitGroup.Go` instead of separate `Add`, `go`, and `Done` calls.

For example, a guideline for Go 1.25 or later can replace manual `WaitGroup` bookkeeping:

Before:

```GO
var wg sync.WaitGroup

wg.Add(1)
go func() {
    defer wg.Done()
    process()
}()
wg.Wait()
```

After:

```GO
var wg sync.WaitGroup

wg.Go(func() {
    process()
})
wg.Wait()
```

`WaitGroup.Go` starts the goroutine and manages the matching `Add` and `Done` calls. The agent uses this pattern when the goroutine lifetime matches the `WaitGroup` lifetime.

## Install Modern Go Guidelines

Modern Go Guidelines is available for Junie, Claude Code, Codex, Cursor, and other coding agents that support skills.

Install the Go toolchain and make it available on your PATH. On first use, the integration installs its command-line tool in a local cache. It does not modify your project.

Procedure: Install from a marketplace

* Add the Modern Go Guidelines repository as a marketplace.

Claude Code:

In a Claude Code session, run:

```SHELL
/plugin marketplace add JetBrains/go-modern-guidelines
```

Codex:

In a terminal, run:

```SHELL
codex plugin marketplace add JetBrains/go-modern-guidelines
```

* Install the plugin from the marketplace.

Claude Code:

```SHELL
/plugin install modern-go-guidelines@goland-claude-marketplace
```

Codex:

```SHELL
codex plugin add modern-go-guidelines@goland-codex-marketplace
```

* Start or restart the agent in your Go project. The agent uses the installed skill when it works with Go code.

Procedure: Install from a local repository

* Get a local copy of the [Modern Go
Guidelines repository](https://github.com/JetBrains/go-modern-guidelines). Use this method to test changes before you publish them.

* Check that the repository contains the marketplace definition for your agent.

Claude Code:

The repository root must contain `.claude-plugin/marketplace.json`.

Codex:

The repository root must contain `.agents/plugins/marketplace.json`.

* Add the local repository as a marketplace. Replace the example path with the absolute path to your repository.

Claude Code:

```SHELL
claude plugin marketplace add /absolute/path/to/go-modern-guidelines
```

Codex:

```SHELL
codex plugin marketplace add /absolute/path/to/go-modern-guidelines
```

* Install the plugin from the local marketplace.

Claude Code:

```SHELL
claude plugin install modern-go-guidelines@goland-claude-marketplace
```

Codex:

```SHELL
codex plugin add modern-go-guidelines@goland-codex-marketplace
```

* Start or restart the agent in your Go project.

For Junie, Cursor, other agents, and update instructions, see the [Modern Go Guidelines repository](https://github.com/JetBrains/go-modern-guidelines).

## Update existing Go code

Modern Go Guidelines apply to new code. To find and update outdated code that is already in your project, use the [Go syntax update inspections](analyzing-code-for-syntax-updates.html).

