# JetBrains go-modern-guidelines: Teaching AI Coding Agents to Write Modern Go

> go-modern-guidelines is a JetBrains repository containing a skill package that instructs AI coding agents to prefer modern Go idioms over outdated patterns. It installs into Junie, Claude Code, Codex, and Cursor, and targets Go 1.25 or newer.

**JetBrains/go-modern-guidelines** — Help AI coding agents write modern Go

- Repository: https://github.com/JetBrains/go-modern-guidelines
- Stars: 3,725 · Forks: 120
- Language: Go
- License: Apache-2.0
- Published: 2026-09-10 · Updated: 2026-09-10 · Language: en
- Canonical page: https://hysenlabs.com/projects/jetbrains-go-modern-guidelines

## The Problem: AI Agents Generate Outdated Go Code

The README identifies two root causes for why AI coding agents consistently produce older Go patterns. The first is training data lag: models trained before a certain cutoff have no exposure to features added after that date, so they cannot use constructs like `errors.AsType[T]` from Go 1.26 if none appeared in the training corpus. The second is frequency bias: even for features the model knows, older patterns appear far more often in training data. A model has seen far more `for i := 0; i < n; i++` loops than `for i := range n` range-over-integer loops, so it reproduces the older form by default.

The guidelines give the agent an explicit reference that overrides both problems. When an agent processes a Go task, it checks these guidelines and uses the modern idiom instead of the statistically probable older one.

## What the Guidelines Actually Cover

The guidelines cover features from Go 1.0 through Go 1.27, including everything targeted by Go's own `modernize` analyzer. The README gives concrete examples of the substitutions an agent makes when the guidelines are active:

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

The complete list with descriptions and code examples lives in `FEATURES.md` in the repository. The agent reads the project's `go.mod` to determine the declared Go version and applies only the features available up to and including that version. A project declaring `go 1.21` does not receive Go 1.26 patterns.

The connection to the `modernize` analyzer is explicit in the README: the Go team's `modernize` analyzer exists to update existing code to current idioms; these guidelines serve the same goal for new code generated by agents.

## Installing the Skill in Claude Code

The installation requires two commands inside a Claude Code session:

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

Then install the plugin:

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

Once installed, Claude Code invokes the skill automatically when relevant to a Go task. To trigger it explicitly, use:

```bash
/modern-go-guidelines:use-modern-go
```

Automatic updates are disabled by default for third-party marketplaces. To enable them, open `/plugin`, navigate to Marketplaces, select `goland-claude-marketplace`, and enable auto-update. After Claude Code reports a plugin update, apply it to the current session with:

```bash
/reload-plugins
```

To update manually, use:

```bash
claude plugin marketplace update goland-claude-marketplace
claude plugin update modern-go-guidelines@goland-claude-marketplace
```

## Installing in Junie, Codex, Cursor, and Other Agents

The skill package is distributed for multiple agents. In Junie CLI, add the marketplace and install the extension:

```bash
/extensions marketplace add JetBrains/go-modern-guidelines
/extensions install modern-go-guidelines
```

In Codex, the commands use `codex plugin`:

```bash
codex plugin marketplace add JetBrains/go-modern-guidelines
codex plugin add modern-go-guidelines@goland-codex-marketplace
```

For Cursor, add the marketplace via terminal then use the in-session `/plugins` command to install. Cursor does not currently provide a non-interactive CLI command for updating installed plugins, so reinstalling through `/plugins` is the documented update path.

For other agents that support the skills.sh protocol, including OpenCode:

```bash
npx skills add JetBrains/go-modern-guidelines
```

To install only the use-modern-go skill without the rest of the package, add `--skill use-modern-go` to the npx command.

## Runtime Requirements and the CLI Component

The marketplace integrations do not bundle a static guidelines file. Instead, they run a small CLI that is installed on first use with `go install`. The Go toolchain must be installed and available on PATH before the first invocation. The README states that the CLI targets Go 1.25 or newer; on older Go versions, automatic toolchain switching (`GOTOOLCHAIN=auto`, the default Go behavior) allows Go to fetch a compatible toolchain on first run.

The CLI is cached in a local directory: `$XDG_CACHE_HOME/go-modern-guidelines` or `~/.cache/go-modern-guidelines` on systems without `$XDG_CACHE_HOME` set. It never modifies the project directory. Developers who want to test local changes to the CLI set `GO_MODERN_GUIDELINES_DEV=1` in the environment before launching the agent:

```bash
export GO_MODERN_GUIDELINES_DEV=1
```

With this variable set, the agent runs the local build from the cache directory instead of the released version. Running `make dev-install` after edits rebuilds the local binary.

## Limitations and What the Guidelines Do Not Fix

The guidelines address generation of new code, not detection of bugs or security issues. An agent using these guidelines writes modern Go idioms from the start, but the guidelines do not substitute for code review, static analysis, or testing.

The skill applies only when the agent identifies the task as Go-related. Mixed-language repositories or tasks where the agent does not recognize the Go context may not trigger the guidelines automatically. The explicit invocation command (`/modern-go-guidelines:use-modern-go` in Claude Code) is the fallback for those cases.

Version gating depends on the project having a valid `go.mod` file with a `go` directive. Repositories without a `go.mod` or with a malformed directive may not receive accurate version-specific guidance; the README does not document the fallback behavior for this case.

## go-modern-guidelines Versus Manual go vet and golangci-lint

The alternative to a skill like this is running the `modernize` analyzer after code generation, either as a standalone tool or through golangci-lint. The `modernize` analyzer, mentioned in the README and demonstrated in a Go team talk, finds outdated patterns in existing code and suggests corrections.

The difference in approach is timing. `modernize` is a post-generation linter: it flags old patterns after the agent has written them, requiring a separate review and fix cycle. go-modern-guidelines is a pre-generation reference: the agent reads the guidelines before writing and produces modern patterns in the first pass. For teams running AI-assisted development at volume, avoiding the fix cycle is the practical advantage.

The two approaches are complementary. The README positions these guidelines as the generation-time counterpart to what `modernize` does for existing code.

## Conclusion

go-modern-guidelines is the right tool for teams whose AI coding agents produce outdated Go patterns such as manual loops in place of slices.Contains or verbose nil-check chains instead of cmp.Or. The skill installs in minutes and functions automatically when the agent detects a Go task. Before adopting it, confirm that the Go toolchain is installed and accessible on PATH, since the CLI component is fetched and installed on first use. The project targets Go 1.25 or newer; on older Go versions it depends on GOTOOLCHAIN=auto to fetch a compatible toolchain automatically. The last push was on 2026-09-10.

## FAQ

### What are the coding guidelines for Golang?

go-modern-guidelines covers features from Go 1.0 through Go 1.27, including the idioms targeted by Go's own modernize analyzer. The complete list with examples is in FEATURES.md in the repository. The agent reads the project's go.mod to apply only features available in the declared Go version.

### What IDE should I use for Go development?

The go-modern-guidelines README documents installation for Junie (JetBrains), Claude Code, Codex, and Cursor. The skill itself is IDE-agnostic: any agent that supports the skills.sh protocol can install it with npx skills.

### What are the prerequisites for using go-modern-guidelines?

The Go toolchain must be installed and available on PATH. The CLI component is fetched via go install on first use and targets Go 1.25 or newer. On older Go versions, GOTOOLCHAIN=auto must be enabled for automatic toolchain switching.

## Sources

- [Issues](https://github.com/JetBrains/go-modern-guidelines/issues)
- [JetBrains/go-modern-guidelines on GitHub](https://github.com/JetBrains/go-modern-guidelines)
- [License: Apache-2.0](https://github.com/JetBrains/go-modern-guidelines/blob/main/LICENSE)
- [README](https://github.com/JetBrains/go-modern-guidelines/blob/main/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/jetbrains-go-modern-guidelines
