Golang Gopls
Samuel BertheCommunityCreated by samberDistributed by Samuel Berthe
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The golang-gopls skill provides an agent with deep semantic understanding of Go codebases by leveraging gopls, the official Go language server. Unlike text-based search tools, gopls understands the resolved build, including dependencies, build tags, and interface relationships. It supports three integration modes: a dedicated MCP server for agent-friendly interactions, a native LSP tool for editor-like diagnostics, and a CLI for one-shot tasks. This skill is essential for precise navigation, automated refactoring, and maintaining code quality within a locally resolved Go workspace.
What it does
- Performs semantic navigation like go-to-definition, implementation lookups, and call hierarchy analysis.
- Provides fuzzy workspace symbol searching to locate types, functions, and variables.
- Executes safe refactoring actions including renaming, extracting, and inlining code.
- Generates compiler diagnostics and vulnerability reports based on the local build configuration.
- Handles code formatting and import organization to maintain canonical Go style.
- Offers documentation hovers and signature help for APIs within the workspace.
When to use it
- When you need to understand the structure or dependencies of a local Go project.
- Before performing refactors to ensure interface satisfaction and safe renaming.
- To identify and fix compiler errors or linting issues after modifying code.
- When you need to trace call sites or implementation relationships across a codebase.
- To quickly locate symbols or package APIs within your current workspace.
Advantages
- Provides build-aware intelligence that accounts for build tags and dependency pinning.
- Supports automated, safe refactoring actions that preserve code integrity.
- Offers multiple integration paths to suit different agent workflows and environments.
- Reduces manual verification by providing immediate feedback on code changes via diagnostics.
- Enables deep exploration of internal packages and local dependencies.
Usage examples
- “Find all implementations of the Logger interface in this project.”
- The agent uses the implementation tool to return a list of concrete types that satisfy the Logger interface, allowing for targeted code analysis.
- “Rename the User struct to Account and update all references.”
- The agent executes a safe rename refactor, ensuring that all imports and usages across the workspace are updated without breaking the build.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/samber/golang-gopls/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip golang-gopls.zip -d .agents/skills
Documentation by samber
Persona: You are a Go engineer who reaches for semantic code intelligence instead of grep whenever a question is about the resolved build — grep finds text, gopls finds meaning (types, call graphs, shadowing, implementation relationships).
Dependencies: gopls — go install golang.org/x/tools/gopls@latest (v0.20+). The native LSP tool additionally needs ENABLE_LSP_TOOL=1 and the gopls-lsp@claude-plugins-official marketplace plugin (see references/mcp.md).
gopls is the official Go language server. It only answers questions about your specific, locally resolved build — your workspace plus every dependency exactly as pinned in go.sum, including replace directives. For a package that isn't part of that build (versions, docs, licenses, CVEs of something you haven't added yet), → See samber/cc-skills-golang@golang-pkg-go-dev skill (godig) instead.
Three ways to reach gopls
Not interchangeable — pick by what you already know and what you need back:
gopls's own MCP server (preferred for most tasks) — purpose-built for agents: tools take names, file paths, and fuzzy queries instead of raw cursor positions. Register once per machine:
claude mcp add gopls -- gopls mcp. Runs headless over stdio, no editor attached, only sees files saved to disk — the right default for an agent-only workflow. See references/mcp.md for every tool.The native
LSPtool — Claude Code's built-in editor-style integration. Off by default: setENABLE_LSP_TOOL=1, installgopls, and install the officialgopls-lsp@claude-plugins-officialmarketplace plugin to wire it as the Go language server. Operations (goToDefinition,findReferences,hover,documentSymbol,workspaceSymbol,goToImplementation, call hierarchy) are keyed byline/character, so they're most useful once you already have a location — typically right after a grep or a read. Unique value: compiler diagnostics are pushed into context automatically after every edit, no explicit call needed.The
goplsCLI — same engine, invoked asgopls <command> <file:line:col>. The Go team documents it as experimental and debugging-only — "not efficient, complete, flexible, or officially supported." Use it when neither MCP nor the native tool is wired up, or for a one-shot scripted check. Positions arefile:line:col(1-indexed, UTF-8 bytes) orfile:#offset(0-indexed). See references/cli.md.
Preference order: MCP → native LSP → CLI. MCP tools match how an agent thinks (by name/path, not cursor position); the native tool adds free automatic diagnostics; the CLI is the documented fallback of last resort. Wire as many as are available and let the task pick the tool — a query you already have a line:col for is cheap via LSP, a "where is X" query is cheap via go_search, a quick unattended check is cheap via the CLI.
Capability → CLI → MCP → native LSP
Full mapping of every capability to its CLI command, MCP tool, and native LSP op: references/matrix.md.
Use cases
Navigation — jump to a definition, an implementation, or trace a call graph before touching code you didn't write. Details: references/features.md.
Code discovery — learn a workspace's shape (
go_workspace), fuzzy-search a symbol you can't place exactly (go_search), or read a dependency's public surface (go_package_api) before using it.Documentation — hover for type/doc/size info, signature help while calling a function, or browse rendered package docs (
source.doc, including internal packages pkg.go.dev never sees).Diagnostics & safety — compiler and analyzer errors after every edit (
go_diagnostics/ automatic withLSP), plus a lightweightgo_vulncheckreachability check: once as a baseline right after detecting the workspace, and again after anygo.modchange.Formatting — canonical
gofmt-equivalent formatting and import organization, both scriptable and code-action-driven.Refactoring — safe rename (blocks a change that would break interface satisfaction), extract/inline, and the full
refactor.rewrite.*family (fill struct/switch, invert if, split/join lines, remove unused parameter, add struct tags, implement interface). Full catalog with gotchas: references/features.md.
Efficient workflows
These Read/Edit workflows encode the order that avoids redundant queries and half-applied edits — treat every step as required, not optional, even to save a round trip.
Session start — call
go_workspaceonce to detect whether this is a Go workspace at all; if it is, immediately follow with a baselinego_vulncheckto surface vulnerabilities the workspace already carries. This is unconditional, separate from the edit workflow's later check after a dependency change.
Read workflow (understand before touching anything):
go_workspace— layout (module/workspace/GOPATH); same call as the session-start check above if it hasn't run yet.go_search— fuzzy-locate a type/function/variable by name.go_file_context— right after reading any Go file for the first time, see what it pulls in from the rest of its package; re-run if that file's dependencies change.go_package_api— a third-party dependency's or sibling package's public surface, without reading every file.
Edit workflow (iterate until diagnostics are clean):
Read first (workflow above).
go_symbol_referencesbefore modifying any definition — judge the blast radius, then read every referencing file that needs a matching edit.Make all planned edits, including the reference-site edits, before moving on.
go_diagnosticson every changed file — mandatory after each modification, not an optional cleanup pass.Fix reported errors: review any suggested quick-fix diff before applying, then re-run diagnostics to confirm the fix landed. Ignore hint/info diagnostics unrelated to the task. A diagnostic message can paraphrase the surrounding source rather than quote it verbatim.
Only if
go.moddependencies changed, rungo_vulncheckon the whole workspace — after diagnostics are clean, not before.Run
go test <changed-package-paths>— not./...unless explicitly asked, since a full-repo run slows the iteration loop.
Gotchas worth knowing before you rely on a result:
referencesresults only reflect the build configuration of the queried file — a query onfoo_windows.gowill not surface matches inbar_linux.go; re-run under the relevantGOOS/build tags if a cross-platform result is missing.call_hierarchyonly shows static calls — calls through function values or interface methods are invisible to it; corroborate withreferenceswhen the call site matters.Extract/inline refactors are less rigorous than rename: comments are sometimes dropped, and generated files marked
DO NOT EDITreceive no code actions at all.refactor.rewrite.fillStructsearches only the current file above the cursor and needs the struct's package already imported — runsource.organizeImportsfirst if the type was just typed in.
gopls vs godig vs Context7 vs govulncheck
gopls only reasons about code present and resolvable in the local build:
For anything not tied to that build (version history, license, ecosystem-wide importers, CVEs of a package not yet added) → See
samber/cc-skills-golang@golang-pkg-go-devskill (godig) — it queries pkg.go.dev directly, no local checkout needed.For a comprehensive, whole-tree vulnerability audit (CI gates, periodic sweeps) rather than gopls's lightweight on-demand
go_vulncheck→ Seesamber/cc-skills-golang@golang-securityskill (govulncheck).Context7 remains a fallback for non-Go docs or a Go module not indexed on pkg.go.dev.
The full task-to-tool matrix lives in the samber/cc-skills-golang@golang-how-to skill's "godig vs gopls vs Context7 vs govulncheck" section.
Files
- ATTRIBUTION.mdAdded by AutoGineer893 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md9.6 KiB
- references/cli.md9.0 KiB
- references/features.md18.1 KiB
- references/matrix.md3.2 KiB
- references/mcp.md5.2 KiB
- references/settings.md5.3 KiB
references/mcp.md
gopls MCP server & native LSP tool reference
Table of contents
Starting the server
Registering the MCP server
MCP tools
The native
LSPtoolWhat the MCP server can and cannot do
Starting the server
A standalone gopls instance speaking MCP over stdin/stdout, launched fresh per session, no LSP client involved:
gopls mcpOnly sees files as they exist on disk — an edit made through a different tool but not yet saved is invisible to it. This is the right mode for an agent-only workflow with no attached editor.
Registering the MCP server
The underlying command that starts the server (gopls mcp) is harness-agnostic — any MCP-capable host can point at it. Claude Code registers it via its own CLI:
claude mcp add gopls -- gopls mcpOther MCP-capable harnesses (Cursor, Windsurf, and others) each have their own MCP server registration — an entry in their respective settings file pointing at gopls mcp as the launch command, not a shared config format.
MCP tools
Eight tools, all keyed by name/path/query rather than cursor position — this is the main ergonomic difference from the native LSP tool.
| Tool | Purpose | Example |
|---|---|---|
go_workspace | Learn the workspace's overall structure — module, multi-module workspace, or GOPATH project. Call this first, once per session. | go_workspace({}) |
go_vulncheck | On-demand reachability check: which known vulnerabilities does the current build actually reach. Run right after go_workspace if in a Go workspace, and again after any go.mod change. | go_vulncheck({"pattern":"./..."}) |
go_search | Fuzzy search for a type, function, or variable by name across the workspace — use when you don't know the exact location. | go_search({"query":"server"}) |
go_file_context | Summarize a file's dependencies on other files in the same package. Run this immediately after reading any Go file for the first time. | go_file_context({"file":"/path/to/server.go"}) |
go_package_api | Show a package's public API — most valuable for third-party dependencies or sibling packages in a monorepo you haven't read file-by-file. | go_package_api({"packagePaths":["example.com/internal/storage"]}) |
go_symbol_references | Find every reference to a symbol — run before modifying any definition to gauge the blast radius. | go_symbol_references({"file":"/path/to/server.go","symbol":"Server.Run"}) |
go_diagnostics | Build/analysis errors for the given files — mandatory after every edit. | go_diagnostics({"files":["/path/to/server.go"]}) |
go_rename_symbol | Rename a symbol and every reference to it, workspace-wide, with the same safety checks as LSP rename (blocks changes that would break interface satisfaction). | — |
See SKILL.md for the Read/Edit workflow order these tools are designed to be chained in.
The native LSP tool
Claude Code's built-in editor-style integration — a different mechanism from the MCP server above, worth wiring in addition to it, not instead of it.
Enabling it:
Set the environment variable
ENABLE_LSP_TOOL=1(off by default).Install
gopls(go install golang.org/x/tools/gopls@latest).Install the official
gopls-lsp@claude-plugins-officialmarketplace plugin to wiregoplsas the Go language server backing the tool.
Operations, all keyed by line/character rather than name/path:
goToDefinitionfindReferenceshoverdocumentSymbolworkspaceSymbolgoToImplementationcall hierarchy
goToTypeDefinition is intentionally absent from this list — the native tool does not expose it, so type-definition navigation has no agent-invocable path (see features.md).
Because these need a location up front, they're most efficient once you already have one — right after a grep or a file read — rather than as the first move in an investigation (that's what go_search on the MCP server is for).
Its unique value: compiler diagnostics are pushed into context automatically after every edit, with no explicit diagnostics call needed — the MCP server's go_diagnostics requires an explicit invocation each time.
What the MCP server can and cannot do
The gopls MCP server wraps LSP functionality with these boundaries:
Can: read files from the filesystem and return their contents; execute
gocommands to load package metadata (which may reachproxy.golang.organd write to the local Go module/build cache); write to gopls's own cache/configuration files; upload telemetry if the user has opted in.Cannot: make arbitrary writes to the source tree outside of the edits a tool call explicitly returns; make arbitrary network requests beyond what
goitself needs to resolve the build.
Either mode — MCP or native LSP — only ever reasons about code that is present and resolvable in the local build: the workspace plus every dependency exactly as pinned in go.sum, including replace directives. For anything outside that boundary, → See samber/cc-skills-golang@golang-pkg-go-dev skill (godig).
Requirements and compatibility
Written for: Claude Code, OpenAI Codex
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Claude Code frontmatter, Needs an MCP server
The author says: Designed for Claude Code, Codex or similar harness. Requires the gopls binary (go install golang.org/x/tools/gopls@latest) v0.20+ on PATH.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- samber
- Publisher
- Samuel Berthe (Community)
- Distributed by
- Samuel Berthe
- Source
- samber/cc-skills-golang · skills/golang-gopls · commit bb1d43d
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by samber or Samuel Berthe.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download golang-gopls.zip