{
  "markdown": "[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)\n\n# Modern Go Guidelines\n\nThis repository contains guidelines for code agents that help them write modern Go code.\n\nFor example, an agent with these guidelines uses `max(a, b)` instead of an if-else block, `slices.Contains` instead of a manual loop, `cmp.Or(a, b, c)` instead of a chain of nil checks. It also knows about recent additions like `new(42)` to get a pointer to a value and `errors.AsType[T](err)` for type-safe error matching—both from Go 1.26.\n\nThe guidelines cover the most useful features from Go 1.0 through Go 1.27, including everything targeted by the `modernize` analyzer. See [FEATURES.md](FEATURES.md) for the complete list with detailed descriptions and examples. An agent will:\n\n- Detect the project's Go version from `go.mod`\n- Use language features and stdlib additions available up to and including that version\n- Prefer modern idioms over older patterns\n\n## Motivation\n\nAll coding agents tend to generate outdated Go. Two reasons:\n\n1. **Training data lag.** Models don't know about features added after their training cutoff. They can't use `errors.AsType[T]` (Go 1.26) if they've never seen it.\n\n2. **Frequency bias.** Even for features the model knows, it often picks older patterns. There's more `for i := 0; i < n; i++` in the training data than `for i := range n`, so that's what comes out.\n\nThese guidelines fix both problems by giving the agent an explicit reference.\n\nThis aligns with the Go team's direction. The `modernize` analyzer exists to automatically update existing code to use newer idioms (see [this talk](https://www.youtube.com/watch?v=_VePjjjV9JU) from the Go team). These guidelines serve the same goal for new code: agents write modern Go from the start, so there's less to fix later.\n\n## Requirements\n\nThe marketplace integrations run a small CLI that is installed on first use with `go install`. Because of that, the [Go toolchain](https://go.dev/dl/) must be installed and available on your `PATH`.\n\nThe CLI is installed into a local cache (for example `~/.cache/go-modern-guidelines`) and never modifies your project. It targets **Go 1.25 or newer**; on an older Go it still works as long as automatic toolchain switching is enabled (`GOTOOLCHAIN=auto`, the default), which lets Go fetch a compatible toolchain on first run.\n\n## Instructions\n\nThe guidelines are available for Junie, Claude Code, Codex, and Cursor, and for other agents via skills.sh.\n\n### [Junie](https://junie.jetbrains.com)\n\n#### Junie CLI\n\nRun the following commands inside a Junie CLI session.\n\n1. Add this repository as a marketplace:\n```\n/extensions marketplace add JetBrains/go-modern-guidelines\n```\n\n2. Install the extension:\n```\n/extensions install modern-go-guidelines\n```\n\nJunie invokes the skill automatically when it is relevant to a Go task.\n\n#### Updating\n\nUpdate the installed extension from inside a Junie CLI session:\n\n```\n/extensions update modern-go-guidelines\n```\n\n### [Claude Code](https://claude.com/product/claude-code)\n\n#### Installation\nRun the following commands inside a Claude Code session.\n\n1. Add this repository as a marketplace:\n```\n/plugin marketplace add JetBrains/go-modern-guidelines\n```\n\n2. Install the plugin:\n```\n/plugin install modern-go-guidelines@goland-claude-marketplace\n```\n\n#### Usage\n\nClaude Code invokes the skill automatically when it is relevant to a Go task.\n\nTo invoke it explicitly:\n\n```\n/modern-go-guidelines:use-modern-go\n```\n\n#### Updating\n\nClaude Code can update the marketplace and installed plugin automatically at startup. Automatic updates are disabled by default for third-party marketplaces, so enable them once:\n\n1. Run `/plugin`.\n2. Open **Marketplaces** and select `goland-claude-marketplace`.\n3. Select **Enable auto-update**.\n\nWhen Claude Code reports that the plugin was updated, apply the new version to the current session with:\n\n```\n/reload-plugins\n```\n\nTo update it manually instead, run these commands in a terminal:\n\n```bash\nclaude plugin marketplace update goland-claude-marketplace\nclaude plugin update modern-go-guidelines@goland-claude-marketplace\n```\n\n### [Codex](https://developers.openai.com/codex/)\n\n#### Installation\nRun the following commands in a terminal.\n\n1. Add this repository as a marketplace:\n```\ncodex plugin marketplace add JetBrains/go-modern-guidelines\n```\n\n2. Install the plugin:\n```\ncodex plugin add modern-go-guidelines@goland-codex-marketplace\n```\n\n#### Updating\n\nRefresh the marketplace and reinstall the plugin so Codex replaces its cached copy:\n\n```bash\ncodex plugin marketplace upgrade goland-codex-marketplace\ncodex plugin remove modern-go-guidelines@goland-codex-marketplace\ncodex plugin add modern-go-guidelines@goland-codex-marketplace\n```\n\n### [Cursor](https://cursor.com)\n\nFor convenience, the guidelines are distributed as a Cursor plugin.\n\n#### Installation\n\n1. Add this repository as a marketplace by running the following command in a terminal:\n```\ncursor-agent plugin marketplace add https://github.com/JetBrains/go-modern-guidelines\n```\n\n2. Install the plugin with the `/plugins` command inside a Cursor session.\n\n#### Updating\n\nRefresh the marketplace from Git and reopen Cursor so it can pick up the new plugin version:\n\n```bash\ncursor-agent plugin marketplace update goland-cursor-marketplace\n```\n\nIf the installed plugin is still on the previous version, reinstall it with the `/plugins` command. Cursor does not currently provide a non-interactive CLI command for updating an installed plugin.\n\n### Other Agents (via [skills.sh](https://skills.sh))\n\nThe same skill package works across other agents such as OpenCode. Install it with:\n\n```bash\nnpx skills add JetBrains/go-modern-guidelines\n```\n\n(`--skill use-modern-go` installs only this skill.)\n\n#### Updating\n\nUpdate the project-installed skill with:\n\n```bash\nnpx skills update use-modern-go -p -y\n```\n\nFor a globally installed skill, replace `-p` with `-g`.\n\n## Contributing\n\nContributions are very welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) before proposing a change.\n\n## Local development\n\nTo try changes to the CLI in your agent, build this checkout into the tool's cache:\n\n```bash\nmake dev-install\n```\n\nThen set `GO_MODERN_GUIDELINES_DEV=1` in the environment your agent runs in. With it set, any agent using the plugin runs your local build instead of the released version, the same way across Claude Code, Codex, and Cursor. Export it before launching the agent so the agent process inherits it:\n\n```bash\nexport GO_MODERN_GUIDELINES_DEV=1\n```\n\nAfter editing the CLI, run `make dev-install` again to rebuild; the next call picks it up. To go back to the released version, unset the variable (or run `make dev-uninstall` to remove the build):\n\n```bash\nmake dev-uninstall\n```\n\nThis requires the Go toolchain. The dev build is stored in the tool's cache directory (`$XDG_CACHE_HOME/go-modern-guidelines` or `~/.cache/go-modern-guidelines`).\n\nThe build is driven by `scripts/dev-install.sh`, which is intentionally separate from the agent-facing wrapper so an agent can never trigger a build. Without `make` (for example on Windows) you can run it directly:\n\n```bash\nsh scripts/dev-install.sh install       # or: uninstall\npwsh scripts/dev-install.ps1 install    # PowerShell equivalent\n```\n",
  "bytes": 7334,
  "sha": "20eacd817e9e34f858451219d17d09e17e75866097c83e83f3604a1e5c3a504e",
  "repo_slug": "jetbrains/go-modern-guidelines",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/skl_jetbrains_go_modern_guidelines_use_moder_a087c9ec/readme"
}