godoccli is a Go library plus a set of command-line entrypoints for fetching and formatting Go
documentation and source code.
It supports:
- local package lookups from your current Go environment
- remote package fetches through a Go module proxy
- standard library version pinning such as
fmt@go1.22.1 - third-party module version pinning such as
github.com/gorilla/mux@v1.8.0
This makes it useful for CI jobs, editor tooling, AI agents, remote debugging systems, and any environment where you want reproducible Go docs and source reads.
godoccli is the direct command-line interface for the repo's core capabilities. It is the
recommended entrypoint for scripts and skills that want to inspect Go docs or source code without
running MCP.
go install github.com/samuelncui/godoccli/cmd/godoccli@latestShow package documentation:
godoccli show -path fmtShow a symbol:
godoccli show -path net/http -symbol ListenAndServeShow an unexported symbol:
godoccli show -path net/http@go1.22.1 -symbol isNotToken -show-unexportedRead source:
godoccli read-src -path github.com/gorilla/mux@v1.8.0/mux.goRead a source slice with line numbers:
godoccli read-src \
-path github.com/gorilla/mux@v1.8.0/mux.go \
-offset 24 \
-limit 20 \
-show-line-numberList package files:
godoccli list-src -path github.com/gorilla/mux@v1.8.0List package files as JSON:
godoccli list-src -path github.com/gorilla/mux@v1.8.0 -jsonAll subcommands support these flags:
-proxy: override the Go proxy URL, defaulthttps://proxy.golang.org-remote-only: skip local package lookup and force proxy-backed reads-verbose: print diagnostic logs to stderr
This repo ships a reusable skill under .agents/skills/godoccli, not under any Trae-specific
directory.
The skill uses the godoccli binary directly and does not rely on MCP.
From the root of the workspace where you want to add the skill:
curl -fsSL https://raw.githubusercontent.com/samuelncui/godoccli/main/scripts/install-skill.sh | bashTo install into a different workspace path:
curl -fsSL https://raw.githubusercontent.com/samuelncui/godoccli/main/scripts/install-skill.sh | \
bash -s -- /path/to/workspaceThe installer will:
- download
.agents/skills/godoccli/SKILL.md - create the target
.agents/skills/godocclidirectory if needed - run
go install github.com/samuelncui/godoccli/cmd/godoccli@latest
After installation, your workspace will contain:
.agents/
skills/
godoccli/
SKILL.md
godocmcp is still available when you specifically want to expose the same functionality through
an MCP server.
go install github.com/samuelncui/godoccli/cmd/godocmcp@latestgodocmcp -verboseThe MCP server exposes three tools:
show: retrieve package or symbol documentationread_src: read a specific source file with line slicinglist_src: list files in a package directory
You can also use godoccli directly in your Go applications.
go get github.com/samuelncui/godocclipackage main
import (
"fmt"
"log"
"github.com/samuelncui/godoccli"
)
func main() {
client, err := godoccli.NewCli(
godoccli.WithGoProxyURL("https://proxy.golang.org"),
godoccli.WithRemoteOnly(true),
)
if err != nil {
log.Fatalf("Failed to create Cli client: %v", err)
}
defer client.Close()
showResp, err := client.Show(&godoccli.ShowReq{
Path: "net/http",
Symbol: "ListenAndServe",
})
if err != nil {
log.Printf("Show failed: %v", err)
return
}
fmt.Println(showResp.Doc)
}The godoccli client exposes three primary methods:
Show(*ShowReq) (*ShowResp, error): retrieves documentation for a package or symbolReadSrc(*ReadSrcReq) (*ReadSrcResp, error): retrieves source code for a fileListSrc(*ListSrcReq) (*ListSrcResp, error): lists files in a package directory
This project is licensed under the MIT License. See LICENSE for details.