agentleFS
CsHengCsHeng/agent-skills/skills/go-guidelines/SKILL.md

go-guidelines

Skill3 starsChanged 8 days agoMITView on GitHub

Apply Go-specific policy to existing or approved Go modules, CLI tools, API services, tests, and reviews: module hygiene, standard toolchain checks, explicit errors and context, purpose-specific architecture, and delivery. Use as a language overlay; do not own language selection or lifecycle control.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 7 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use Go modules as the source of truth.

    line 22
  2. Very specific:

    Keep go.mod and go.sum tracked and consistent.

    line 23
  3. Very specific:

    Run go mod tidy when imports or tool dependencies change, then review the module diff.

    line 25
  4. Distinctive:

    Use the standard toolchain first.

    line 26
  5. Very specific:

    Run go test ./... to compile packages and execute tests.

    line 28
  6. Very specific:

    Run go vet ./... for suspicious constructs that compilation accepts.

    line 29
  7. Distinctive:

    Run project-owned analyzers such as Staticcheck or golangci-lint when configured.

    line 30
  8. Distinctive:

    Keep developer tools project-owned when reproducibility matters.

    line 31
  9. Distinctive:

    Use the repository's existing pre-1.24 mechanism when the module version requires it.

    line 33
  10. Very specific:

    Add operation context with fmt.Errorf("operation: %w", err) when propagating an underlying error.

    line 36
  11. Distinctive:

    Test behavior at the narrowest useful boundary.

    line 44
  12. Very specific:

    Use the standard testing package by default, with table-driven tests when they improve coverage and readability.

    line 45
  13. Very specific:

    Use httptest, fakes, temporary directories, and injected IO in place of global process state when practical.

    line 46
  14. Distinctive:

    Use these when the project or risk profile calls for them:

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Go Guidelines

Apply the shared baseline below, then load the reference that matches the archetype. An unfixed implementation-language decision uses references/language-selection.md in skills-routing; ad hoc command and tool choice uses references/tool-selection.md there; resilience and logging policy beyond Go-specific application belongs to error-patterns and logging-standards.

Progressive Disclosure

  • CLI tools and operator commands: references/cli-tool-patterns.md
  • API and network services: references/api-service-patterns.md
  • Producing, running, testing or delivering a Go artifact (build output, scratch, coverage or fuzz files, target-host delivery): references/build-and-delivery.md
  • Porting existing code or tests from another language: references/migration.md
  • Implementation review: references/review-checklist.md

Apply api-service-patterns to API or network services and cli-tool-patterns to CLIs; a library gets only the shared baseline. Load both profiles when one approved project owns both a CLI control surface and an API server.

Shared Baseline

  1. Use Go modules as the source of truth.
    • Keep go.mod and go.sum tracked and consistent.
    • Declare the minimum supported Go version in go.mod.
    • Run go mod tidy when imports or tool dependencies change, then review the module diff.
  2. Use the standard toolchain first.
    • Format changed Go files with gofmt and the repository's configured formatting step.
    • Run go test ./... to compile packages and execute tests.
    • Run go vet ./... for suspicious constructs that compilation accepts.
    • Run project-owned analyzers such as Staticcheck or golangci-lint when configured.
  3. Keep developer tools project-owned when reproducibility matters.
    • On Go 1.24 or newer, use a go.mod tool directive for versioned Go developer tools.
    • Use the repository's existing pre-1.24 mechanism when the module version requires it.
  4. Handle errors explicitly.
    • Handle every returned error; discard one only when the API documents the result as irrelevant, and record that reason.
    • Add operation context with fmt.Errorf("operation: %w", err) when propagating an underlying error.
    • Define sentinel or custom error types when callers need stable programmatic classification through errors.Is or errors.As.
    • Log an error once, at the boundary that owns presentation or recovery.
  5. Propagate cancellation and deadlines.
    • Accept context.Context as the first parameter for request-scoped, blocking, network, subprocess, or other IO-heavy work.
    • Pass the request context as an argument on each call.
  6. Keep abstractions demand-driven.
    • Introduce an interface or layer when a second implementation, a fake, or an isolation need exists, and define it at the consuming boundary.
  7. Test behavior at the narrowest useful boundary.
    • Use the standard testing package by default, with table-driven tests when they improve coverage and readability.
    • Use httptest, fakes, temporary directories, and injected IO in place of global process state when practical.

Optional Checks

Use these when the project or risk profile calls for them:

  • go test -race ./... for concurrent or shared-state code
  • Staticcheck for low-noise semantic analysis
  • govulncheck ./... for applications with third-party dependencies or release artifacts

Pin reproducible Go tools through the owning module.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.