# Go modules

Recommend AXM extensions from a Go module and target Go modules from an extension.

AXM reads Go extension metadata from an `agent-extensions.json` sidecar at the
module root — next to `go.mod`. This is the
[two-way linking](/docs/package-ecosystems/overview) model applied to Go
modules. Go has no package-manifest field for arbitrary metadata, so a sidecar
file carries the recommendation.

## Recommend extensions from a module

Add an `agent-extensions.json` file at the module root with an `agentExtensions`
array. Each entry is an extension reference (`@owner/<type>/<name>`):

```jsonc
// agent-extensions.json
{
  "$schema": "https://axm.sh/schemas/agent-extensions.schema.json",
  "agentExtensions": [{ "ref": "@examples/packs/go-gomod-tinyflags" }],
}
```

Because Go fetches modules by version-control contents, committing
`agent-extensions.json` beside `go.mod` makes it available to consumers in the
module cache.

Keep recommendations **identity-only** — omit `versionRange`. AXM resolves the
reference to the newest matching extension version and pins it in the user's
`axm.lock`. Prefer recommending a single **pack** so you keep one stable
reference while its contents evolve.

Add a semver `versionRange` only when your module genuinely pairs with a bounded
major line of the extension:

```jsonc
{
  "agentExtensions": [
    {
      "ref": "@examples/packs/go-gomod-tinyflags",
      "versionRange": "^1.0.0",
    },
  ],
}
```

## Target Go modules from an extension

On the extension manifest (`skill.json`, `pack.json`, `subagent.json`, …), add a
`packages` array with a Go [purl](https://github.com/package-url/purl-spec). The
Go purl type is `golang`, and the module path becomes the namespace and name:

```jsonc
// pack.json
{
  "packages": [{ "purl": "pkg:golang/github.com/agentxm/example-tinyflags" }],
}
```

### Version ranges

Default to identity-only. Add a [VERS](https://github.com/package-url/vers-spec)
`versionRange` with the `golang` scheme only when the extension depends on
module APIs introduced or removed in a known range:

```jsonc
{
  "packages": [
    {
      "purl": "pkg:golang/github.com/agentxm/example-tinyflags",
      "versionRange": "vers:golang/>=0.1.0|<1.0.0",
    },
  ],
}
```

## Official status

When the Go module recommends an extension through the AgentXM Registry **and**
that extension names the module as a companion via its purl, AXM derives
**official** status for the pair — no extra flag. See
[Official extensions](/docs/package-ecosystems/overview#official-extensions).

## Reference fixture

The
[`go-gomod-lib`](https://github.com/agentxm/polyglot-examples/tree/main/go-gomod-lib)
and
[`go-gomod-app`](https://github.com/agentxm/polyglot-examples/tree/main/go-gomod-app)
directories in `polyglot-examples` are the working fixtures for everything
above. The module publishes a TinyFlags companion pack and recommends it from
the `agent-extensions.json` sidecar beside `go.mod`; the pack and each skill
declare the module's `pkg:golang` purl as an identity-only companion package.