# Go teams: setting up the coding agent's test loop on its own machine

> go test is cheap once the module cache and compiled packages are warm, and expensive when every agent starts from nothing. How a Go team can give each coding agent its own cloud machine: the template, the single-package commands, the test cache, and what to leave for the full suite.

go test is cheap once the module cache and compiled packages are warm, and expensive when every agent starts from nothing. How a Go team can give each coding agent its own cloud machine: the template, the single-package commands, the test cache, and what to leave for the full suite.

December 2, 2026 · 4 min read · The Sandscale team

A Go service compiles quickly once the module cache is filled, and slowly the first time an agent runs `go test ./...` on a cold machine. The first run downloads modules, builds a test binary for each package and runs `go vet` on the way. Later runs in the same module reuse that work. Two agents sharing one module cache and one laptop will step on each other; one agent with its own machine will not.

This post is about setting up that machine so the edit-test loop stays on it. The `go test` behaviour comes from the [Go command documentation](https://pkg.go.dev/cmd/go#hdr-Testing_packages), read on 2 December 2026. Sandscale commands are from CLI 1.4.1. We do not show test output, because it depends on your packages.

## Why a machine per agent suits Go

The Go documentation draws a distinction that matters for agents.

- **Local directory mode** is `go test` with no package arguments. It compiles and runs the tests in the current directory. Caching is disabled in this mode.
- **Package list mode** is `go test` with explicit package arguments, including `go test ./...` and even `go test .`. Successful package tests can be cached. When a result is reused, the documentation says `go test` prints `(cached)` in place of the elapsed time.

An agent that always runs `go test ./...` after a one-function change pays for every package, plus whatever the cache does not cover. An agent that runs `go test ./internal/billing -run TestInvoiceTotal` while it works, and `go test ./...` once before the pull request, is using the tool the way it is designed.

A Sandscale [workspace](https://sandscale.dev/workspaces) is a persistent cloud machine with its own disk, CPU and memory, per agent. The disk survives stops and starts, so the Go toolchain, the module cache and compiled packages are still there next time.

## What goes in the template

Ask whoever administers your workspace templates to put these in once:

- A pinned Go toolchain, the same version your CI uses. A `go` directive in `go.mod` records the version the module expects; the machine should have at least that version installed.
- `git`, and a C compiler if any package uses cgo.
- Whatever the tests call outside the Go toolchain.

Then each engineer creates a machine for the task:

```sh
sandscale workspace create --name go-3301-billing --template-id TEMPLATE_ID --ttl-seconds 28800
sandscale workspace ssh go-3301-billing
```

Whether the machine can reach the module proxy (by default `proxy.golang.org`) or your internal GOPROXY depends on your plan and your organization’s network policy. If the first `go test` cannot download, that is the first place to look. `GOPROXY` and `GOPRIVATE` belong in the environment, not in a prompt.

## Warm the cache once

Before handing the agent a task, download modules and compile the tests once:

```sh
go mod download
go test ./...
```

`go mod download` fills the module cache. `go test ./...` compiles and runs every package once, which also fills the test cache in package list mode. Treat this as a warm-up. A new dependency still needs the network.

## The loop: one package, one test

Teach the agent the narrow forms. These are all in the Go documentation:

```sh
go test ./internal/billing
go test ./internal/billing -run TestInvoiceTotal
go test ./internal/billing -count=1 -run TestInvoiceTotal
```

`-run` takes a regular expression and runs only the tests that match. In package list mode, passing tests may be served from the cache; `-count` is not in the documentation’s list of cacheable flags, so `-count=1` is a reliable way to force a fresh run of the test you just changed. `-failfast` stops starting new tests after the first failure, which is useful in the loop and not a way to hide a failure.

As part of building a test binary, `go test` runs a high-confidence subset of `go vet`. If vet finds a problem, the documentation says `go test` reports it and does not run the test binary. An agent that then passes `-vet=off` to get past the error should be told not to, unless the task says to.

For a machine-readable summary the agent can act on, `go test -json` is the documented flag; our post on [test results a coding agent can act on](https://sandscale.dev/blog/test-results-a-coding-agent-can-act-on) covers how to use it.

## The AGENTS.md block

```markdown
## Build and test (Go)
- Use the Go version the go.mod file expects. Do not install a different toolchain.
- While working, run only the package you changed:
  go test ./path/to/package -run TestName
- Before committing, run go test ./path/to/package for each package you touched.
- Do not delete the module cache to "fix" a build. If a download looks stuck, say so and stop.
- Do not use -vet=off to make a test command pass.
- Do not edit go.mod or go.sum unless the task says to change a dependency.
- Before opening a PR, run go test ./... once and put the result in the PR description.
```

## What the reviewer checks

A `go.mod` or `go.sum` change in a pull request is a signal. If the task did not ask for a dependency change, ask why. Our [reviewer checklist](https://sandscale.dev/blog/reviewing-an-agent-diff-checklist) covers the rest.

## The full suite

`go test ./...` before the pull request, on the agent’s machine if it fits, or on a larger leased machine if the module is heavy; see [leasing a build host for a full test suite](https://sandscale.dev/blog/build-host-lease-for-a-full-test-suite). CI on the pull request stays the merge gate, not the agent’s loop. That split is the subject of [why the edit-test loop should not wait on CI](https://sandscale.dev/blog/agent-edit-test-loop-should-not-wait-on-ci).

When the task is done, stop the machine. A running machine counts toward the plan’s hours whether the agent is busy or waiting:

```sh
sandscale workspace stop --ws-id WORKSPACE_ID
```

The disk is kept, so the next task starts with a warm module cache.

**On this page**

1. Why a machine per agent suits Go
2. What goes in the template
3. Warm the cache once
4. The loop: one package, one test
5. The AGENTS.md block
6. What the reviewer checks
7. The full suite

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [December 2, 2026 · **Auditing the MCP tool calls your team's coding agents make** · When Claude Code, Codex, Cursor or Gemini CLI call MCP tools, the record of what happened can live in three places: the client, the MCP server, and the system behind it. What each layer can see, which one to trust as the record, whether to keep arguments, and how to read Sandscale's audit log for agent calls from the CLI.](https://sandscale.dev/blog/auditing-mcp-tool-calls)
- [December 2, 2026 · **Coding agents on client projects: a team lead's checklist for one machine per agent** · Services teams run Claude Code, Codex and Cursor across several client codebases at once. When those agents share developer laptops, client code, credentials and history mix. A checklist for team leads: one machine per agent per client, secrets kept per client, who can start and stop what, the audit record a client may ask for, and a clean exit at the end of the engagement.](https://sandscale.dev/blog/client-projects-one-machine-per-agent-checklist)

---
Source: https://sandscale.dev/blog/go-teams-the-agent-test-loop-on-its-own-machine
