StemCode for Go Developers: AI Coding with modules, gopls, and real tests.

Use StemCode with Go modules, gopls, standard tooling, web services, tests, refactoring, repository analysis, and AI code review.

PUBLISHED 2026-10-01STEMCODE DEVELOPER GUIDELOCAL-FIRST AI CODING
PROJECT INSTRUCTIONS / AGENTS.MD

Give StemCode durable repository instructions before asking it to edit.

Add an AGENTS.md file at the repository root for persistent project instructions. StemCode loads AGENTS.md or .agent/AGENTS.md from the workspace into the model context, so this is the right place for architecture boundaries, generated-file rules, coding conventions, validation expectations, and manual setup notes that should apply across sessions.

Keep AGENTS.md practical and repository-specific

Prefer concrete rules the agent can act on: where important source lives, what it must not edit, which patterns it should preserve, and which checks it should run after a change.

# Go Project Instructions

This is a Go project.

Important source and configuration paths:
- go.mod
- go.sum
- go.work
- cmd/
- internal/
- pkg/
- *_test.go

Generated or disposable paths — do not modify:
- bin/
- dist/
- coverage.out
- tmp/
- generated output not reviewed as source

Follow these rules:
- Follow standard gofmt formatting.
- Keep package dependencies acyclic and simple.
- Prefer the repository's existing error and logging conventions.
- Propagate context cancellation through request-scoped work.
- Do not edit generated Go files unless the generator workflow explicitly requires it.
- Run focused tests before repository-wide go test ./....

Validation:
- gofmt -w <changed-go-files>
- go vet ./...
- go test ./...
- go build ./...

Commit the file with the project so the same instructions are reviewable and shared by everyone using StemCode in the repository.

01 / WHY STEMCODE

Use repository-aware AI without replacing the tools your stack already needs.

StemCode works best when it can understand the repository around a task, inspect related files, use code intelligence where available, run the project's normal validation commands, and review the final diff before you accept a change.

GOOD FIT FOR GO WORK

Go services, CLIs, APIs, workers, modules and workspaces using net/http, chi, Gin, Fiber, gRPC, database/sql, common migration tools, table-driven tests, benchmarks, and normal Git workflows.

02 / SETUP

Install StemCode and open the project root.

Launch StemCode from the module or workspace root so go.mod, go.sum, workspace files, internal packages, commands, tests, generated-code rules, and Git history are available together.

npmnpm install -g stemcode
pnpmpnpm add -g stemcode
cd your-project
stemcode
/init

Keep StemCode at the repository root so project instructions, source, configuration, tests, and Git history are visible from one workspace.

03 / PROJECT CONTEXT

Expose package boundaries and tests while excluding generated binaries and caches.

Go repositories are usually easy to analyze when package structure, module files, generated-code markers, and tests remain visible. Keep temporary build output and vendored/generated data out of the search path when it is not authoritative source.

INSPECT

Keep source-of-truth files visible.

go.mod
go.sum
go.work
cmd/
internal/
pkg/
*_test.go
IGNORE

Skip generated or disposable output.

bin/
dist/
coverage.out
tmp/
generated output not reviewed as source

Add generated paths to Git ignore rules or .stemcode/.stemcodeignore so repository search stays focused.

FIRST PROMPT

Understand the project before changing it.

Analyze this Go repository. Map commands, internal packages, public packages, HTTP or RPC entry points, service boundaries, data access, background workers, tests, and configuration. Explain the dependency direction between the major packages. Do not modify files yet.

04 / CODE INTELLIGENCE

Use gopls for semantic Go navigation and diagnostics.

gopls provides definitions, references, diagnostics, implementations, and type information that are especially useful when interfaces and package boundaries spread behavior across the repository.

GOPLSgo install golang.org/x/tools/gopls@latest
/lsp refresh
/lsp
Use both semantic navigation and repository search

Combine gopls with repository search for build tags, generated files, configuration, SQL, migrations, wire-up code, and interface implementations. Keep Go’s package visibility and import-cycle constraints in mind during refactors.

05 / DEVELOPMENT WORKFLOW

Trace interfaces and package ownership before changing implementations.

Good Go changes usually preserve simple package boundaries, explicit dependencies, small interfaces, and straightforward error handling. Ask StemCode to discover those conventions before adding abstractions.

SERVICE

Trace a request

Trace this request from router or handler through validation, authorization, service logic, persistence, external calls, and tests. Identify context cancellation and error propagation along the path.

INTERFACE

Refactor an abstraction

Find every implementation and consumer of this interface. Explain whether the interface is owned by the right package and propose a staged change that avoids import cycles.

CONCURRENCY

Review goroutine lifetime

Review this workflow for goroutine leaks, blocked channels, missing cancellation, unsafe shared state, retry storms, and shutdown behavior before editing.

API

Extend an endpoint safely

Follow the repository's existing request, response, validation, error, logging, and test conventions when adding this endpoint. Avoid introducing a new framework pattern.

06 / BUILD AND TEST

Keep gofmt, vet, tests, and the real build in the loop.

Go’s standard toolchain provides a strong validation baseline. Use repository-specific Makefile, Taskfile, or CI commands when they add generated-code, race, lint, integration, or container checks.

FORMATgofmt -w <changed-go-files>
VETgo vet ./...
TESTgo test ./...
BUILDgo build ./...

For concurrency changes, run the repository’s race-enabled tests when available. For large modules, begin with the affected package and then expand to ./... after the focused checks pass.

Run the smallest relevant validation first. If it passes, run the broader project checks and review the final diff.
07 / PROJECT MEMORY

Keep longer-lived architecture context alongside your project instructions.

Use AGENTS.md for concise rules the agent should follow on every task. Keep longer architecture notes, domain context, and workflow references in repository-level StemCode memory so both stay reviewable and versionable.

Follow standard gofmt formatting.
Keep package dependencies acyclic and simple.
Prefer the repository's existing error and logging conventions.
Propagate context cancellation through request-scoped work.
Do not edit generated Go files unless the generator workflow explicitly requires it.
Run focused tests before repository-wide go test ./....
08 / REVIEW

Review the change in terms of your stack, not only the generated code.

Ask StemCode to inspect its own diff and check the integration points that are easiest to miss in a repository-wide change.

- context cancellation and deadlines
- goroutine and channel lifetime
- error wrapping and propagation
- interface ownership and package coupling
- data races and shared state
- API compatibility
- generated-code workflow
- go vet, tests, and build results
09 / FAQ

Common setup questions.

Does StemCode work with gopls?

Use gopls as the Go language-intelligence layer and combine it with repository search for configuration, generated code, SQL, migrations, and other non-Go context.

What about Gin, Fiber, chi, or gRPC?

Keep the framework already used by the repository. The workflow is the same: trace routing and middleware into service logic, persistence, external calls, and tests before editing.

Should vendor be indexed?

Only when the repository intentionally commits and reviews vendor code as part of development. In most tasks, module source and your own packages are the useful context.

NEXT STEP

Put StemCode to work in a real repository.

Install StemCode, open the project you already work in, and begin with a repository-understanding task before asking the agent to change code. That gives the model better context and keeps the workflow reviewable.

INSTALL

Start with the CLI.

npm install -g stemcode
cd your-project
stemcode
LEARN

Go deeper.

Read the full StemCode documentation for providers, permissions, LSP integrations, memory, MCP, CI review, and advanced workspace configuration.

READ THE DOCS →