Go Modules — 18 Operations for AI Agents

`go.mod` is a Go project's contract with its dependencies — module path, versions, replacements. act101 treats each directive as addressable structure, so agents audit and adjust dependencies with manifest-level precision.

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Go Modules code through the act MCP server. 18 operations available: 0 refactor, 18 query, 0 analysis. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.

18Query

Worked Go Modules examples

act101 reads a go.mod file's module directive, go-version directive, and require/replace/exclude/retract directives as declarations. skeleton captures the module path as module, the Go version as variable, an entire require block (single or multi) as one self-named import declaration — its name is the block's own source text, not an extracted package name — and each replace/exclude/retract entry as block, named for the module path or version it targets. symbols reaches inside a require or replace block instead, reporting each individual dependency and each replaced module path as its own variable-kind entry, but it does not read exclude or retract at all. Each example below is the verbatim output of the command shown, run against the file shown. Query outputs are pretty-printed with the timing block omitted.

Read the module's directives as a skeleton

go.mod declares the github.com/acme/notifier module on Go 1.22, a three-package require block plus one standalone require, a replace pointing internal/queue at a local path, an excluded old version, and a retracted release.

$ act query skeleton go.mod

Before

module github.com/acme/notifier

go 1.22

require (
	github.com/aws/aws-sdk-go-v2 v1.26.1
	github.com/redis/go-redis/v9 v9.5.1
	google.golang.org/grpc v1.63.2
)

require github.com/sirupsen/logrus v1.9.3

replace github.com/acme/notifier/internal/queue => ./internal/queue

exclude github.com/old/deprecated v1.0.0

retract v1.0.1

Output

{
    "type": "Skeleton",
    "declarations": [
        {
            "kind": "module",
            "name": "github.com/acme/notifier",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 1,
                    "column": 1,
                    "byte_offset": 0
                },
                "end": {
                    "file": "go.mod",
                    "line": 1,
                    "column": 32,
                    "byte_offset": 31
                }
            },
            "name_range": {
                "start": {
                    "file": "go.mod",
                    "line": 1,
                    "column": 8,
                    "byte_offset": 7
                },
                "end": {
                    "file": "go.mod",
                    "line": 1,
                    "column": 32,
                    "byte_offset": 31
                }
            }
        },
        {
            "kind": "variable",
            "name": "1.22",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 3,
                    "column": 1,
                    "byte_offset": 33
                },
                "end": {
                    "file": "go.mod",
                    "line": 5,
                    "column": 1,
                    "byte_offset": 42
                }
            },
            "name_range": {
                "start": {
                    "file": "go.mod",
                    "line": 3,
                    "column": 4,
                    "byte_offset": 36
                },
                "end": {
                    "file": "go.mod",
                    "line": 3,
                    "column": 8,
                    "byte_offset": 40
                }
            }
        },
        {
            "kind": "import",
            "name": "require (",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 5,
                    "column": 1,
                    "byte_offset": 42
                },
                "end": {
                    "file": "go.mod",
                    "line": 11,
                    "column": 1,
                    "byte_offset": 162
                }
            }
        },
        {
            "kind": "import",
            "name": "require github.com/sirupsen/logrus v1.9.3",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 11,
                    "column": 1,
                    "byte_offset": 162
                },
                "end": {
                    "file": "go.mod",
                    "line": 13,
                    "column": 1,
                    "byte_offset": 205
                }
            }
        },
        {
            "kind": "block",
            "name": "github.com/acme/notifier/internal/queue",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 13,
                    "column": 1,
                    "byte_offset": 205
                },
                "end": {
                    "file": "go.mod",
                    "line": 15,
                    "column": 1,
                    "byte_offset": 274
                }
            },
            "name_range": {
                "start": {
                    "file": "go.mod",
                    "line": 13,
                    "column": 9,
                    "byte_offset": 213
                },
                "end": {
                    "file": "go.mod",
                    "line": 13,
                    "column": 48,
                    "byte_offset": 252
                }
            }
        },
        {
            "kind": "block",
            "name": "github.com/old/deprecated",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 15,
                    "column": 1,
                    "byte_offset": 274
                },
                "end": {
                    "file": "go.mod",
                    "line": 17,
                    "column": 1,
                    "byte_offset": 316
                }
            },
            "name_range": {
                "start": {
                    "file": "go.mod",
                    "line": 15,
                    "column": 9,
                    "byte_offset": 282
                },
                "end": {
                    "file": "go.mod",
                    "line": 15,
                    "column": 34,
                    "byte_offset": 307
                }
            }
        },
        {
            "kind": "block",
            "name": "v1.0.1",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 17,
                    "column": 1,
                    "byte_offset": 316
                },
                "end": {
                    "file": "go.mod",
                    "line": 18,
                    "column": 1,
                    "byte_offset": 331
                }
            },
            "name_range": {
                "start": {
                    "file": "go.mod",
                    "line": 17,
                    "column": 9,
                    "byte_offset": 324
                },
                "end": {
                    "file": "go.mod",
                    "line": 17,
                    "column": 15,
                    "byte_offset": 330
                }
            }
        }
    ]
}

The skeleton reports seven declarations: github.com/acme/notifier as module, 1.22 as variable, the require block and the standalone require both as import — the block's name is its own source text ("require ("), truncated to its first line — and the replace/exclude/retract entries as block, each named for the module path or version it targets.

List each individual dependency and the replaced module as symbols

The require block lists aws-sdk-go-v2, go-redis, and grpc; the standalone require adds logrus; the replace substitutes internal/queue for a local path.

$ act query symbols go.mod

Before

module github.com/acme/notifier

go 1.22

require (
	github.com/aws/aws-sdk-go-v2 v1.26.1
	github.com/redis/go-redis/v9 v9.5.1
	google.golang.org/grpc v1.63.2
)

require github.com/sirupsen/logrus v1.9.3

replace github.com/acme/notifier/internal/queue => ./internal/queue

exclude github.com/old/deprecated v1.0.0

retract v1.0.1

Output

{
    "type": "Symbols",
    "symbols": [
        {
            "name": "github.com/acme/notifier",
            "kind": "module",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 1,
                    "column": 8,
                    "byte_offset": 7
                },
                "end": {
                    "file": "go.mod",
                    "line": 1,
                    "column": 32,
                    "byte_offset": 31
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "github.com/aws/aws-sdk-go-v2",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 6,
                    "column": 2,
                    "byte_offset": 53
                },
                "end": {
                    "file": "go.mod",
                    "line": 6,
                    "column": 30,
                    "byte_offset": 81
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "github.com/redis/go-redis/v9",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 7,
                    "column": 2,
                    "byte_offset": 91
                },
                "end": {
                    "file": "go.mod",
                    "line": 7,
                    "column": 30,
                    "byte_offset": 119
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "google.golang.org/grpc",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 8,
                    "column": 2,
                    "byte_offset": 128
                },
                "end": {
                    "file": "go.mod",
                    "line": 8,
                    "column": 24,
                    "byte_offset": 150
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "github.com/sirupsen/logrus",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 11,
                    "column": 9,
                    "byte_offset": 170
                },
                "end": {
                    "file": "go.mod",
                    "line": 11,
                    "column": 35,
                    "byte_offset": 196
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "github.com/acme/notifier/internal/queue",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "go.mod",
                    "line": 13,
                    "column": 9,
                    "byte_offset": 213
                },
                "end": {
                    "file": "go.mod",
                    "line": 13,
                    "column": 48,
                    "byte_offset": 252
                }
            },
            "visibility": "unknown"
        }
    ]
}

symbols reports six entries — the module plus five individual paths, one per require/replace spec — all as kind variable; the exclude and retract directives are not read at this level at all.

Query

18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.

callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch

← GoGo Templates →