Skip to content
Languages

Go AGENTS.md

Go leaves little room for a second style. This file tells the agent to format with gofmt, to keep the module path in go.mod, and to run go test on the packages it touched.

Paste, then editGo MCP servers

A new framework, a global variable, or a panic for an ordinary error will fight the rest of the module.

In this stack

What to tell the agent

Do

  • Name the package under cmd/ that holds the binary, when there is one.
  • Tell the agent which build tags CI uses.
  • Ask for a table test when the change is a pure function.
  • Point at the context parameter the handlers already take.

Leave alone

  • Ignoring an error with a blank identifier.
  • Starting a goroutine without a way to stop it.
  • Adding a web framework to a module that uses net/http.
Starter file

AGENTS.md to copy

Save this as AGENTS.md at the root of the repository, or next to the package it covers. Replace the commands with the ones in this repo. See which agents read the file.

AGENTS.md
# Go

## Style
- Format with gofmt. Do not introduce another formatter.
- Return errors. Do not panic for a condition the caller can handle.
- Accept interfaces and return structs when the surrounding package already does.

## Modules
- Keep the module path in go.mod. Add a dependency with go get, not by pasting a require block.
- Do not bump the Go version in go.mod unless the task needs a language feature from that version.

## Checks
- gofmt -l . should print nothing for the files you changed.
- go test ./... from the module root, or go test on the package you edited when the full suite is slow.
- go vet ./... when the change touches concurrency or unsafe code.

## Leave alone
- Do not rewrite unrelated packages to a new error type.
- Do not add an init() that connects to a network.
Commands to confirm

Checks named in the file

Confirm each command exists here before you rely on it. Delete the ones this repository does not use.

  • Format check. gofmt -l .
  • Test the module. go test ./...
  • Vet. go vet ./...
FAQ

Questions

What is the Go AGENTS.md for?

It keeps a Go agent on gofmt, the existing module, and go test instead of a new framework.

Should an agent reformat every Go file it opens?

Format the files it changed, with gofmt. A drive-by reformat of the whole module hides the real diff and fights whoever owns the next pull request.

How should a Go change report a failure?

Return an error that includes the operation, or wrap the error you got. A panic is for a programmer mistake, not for a missing file or a refused connection.

Keep going

Related on MCPpedia