agentleFS
11me11me/skillbox/go-development/SKILL.md

go-development

Skill4 starsChanged 10 months agoMITView on GitHub

This skill should be used when the user is working with Go projects (go.mod, *.go files), asking about "Go patterns", "Go architecture", "services", "repositories", or mentions "Go development", "Go project", "Go handlers", "Go testing".

  • Reads credentials

6 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions6 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 6

    1. hiromaily/go-crypto-wallet★ 128same name
    2. codetesla51/skills★ 32same name
    3. netresearch/go-development-skill★ 13same name
    4. ProjAnvil/MindForge★ 3same name
    5. carloss765/agent-skills★ 1same name
    6. ibarryyan/skills-runtime★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository2 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All rules are enforced via golangci-lint (revive rules) in .golangci.yml:

    line 81
  2. Distinctive:

    After generating/modifying Go code:

    line 95
  3. Very specific:

    ALWAYS use @latest: when adding new dependencies.

    line 281

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “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 Development Guide

Production-ready patterns extracted from real projects.

Table of Contents

  • Core Principle: LESS CODE = FEWER BUGS
  • Architecture Decisions
  • Linter Enforcement
  • Enforced Project Structure
  • References
    • Core Patterns
    • HTTP Layer
    • Production Patterns
    • Best Practices
  • Examples
  • Templates
  • Commands
  • Dependencies
  • Version

Core Principle: LESS CODE = FEWER BUGS

This applies to ALL code — not just project scaffolding.

What this means:

  • ❌ Don't write error types that won't be used
  • ❌ Don't create custom error type for every error case
  • ❌ Don't add methods "for completeness"
  • ❌ Don't create helper functions that have one caller
  • ❌ Don't add validation for impossible scenarios
  • ❌ Don't implement interfaces "just in case"
  • ❌ Don't add logging/metrics that nobody reads
  • ❌ Don't create common, helpers, utils, shared, misc packages
  • ✅ Write only what the feature requires
  • ✅ Use few sentinel categories (ErrNotFound, ErrConflict) + wrap with context
  • ✅ Typed errors only when caller needs to extract data (RetryAfter, Field)
  • ✅ Add code when there's actual need
  • ✅ Delete unused code immediately
  • ✅ Prefer inline code over tiny functions
  • ✅ Trust the type system, don't over-validate
  • ✅ Name packages by what they provide, not what's in them
  • ✅ Keep helper functions close to usage (unexported)
  • ✅ If truly shared, create small purpose-named packages (internal/optional/)
  • ❌ Don't modify .golangci.yml — linting config is protected

Examples:

BadGood
Define 10 error types, use 2Define errors as you need them
Create GetByID, GetByEmail, GetByName upfrontCreate only the method you're using now
Add Update, Delete when only Create is neededAdd Update when the feature requires it
Write helper formatUserName() called onceInline the logic
Validate internal struct fieldsTrust internal code, validate at boundaries

Architecture Decisions

AspectChoice
Configcaarlos0/env (env only)
Structurecmd/, internal/, pkg/
Databasepgx/v5 + squirrel
TransactionsContext injection + retry
DIService Registry
ErrorsSentinel categories + wrap (errs package)
Loggingslog (small) / zap (large) — ask user
TracingOpenTelemetry (optional) — ask user
Migrationsgoose/v3

Linter Enforcement

All rules are enforced via golangci-lint (revive rules) in .golangci.yml:

RuleLinterDescription
userID not userIdvar-namingGo idiom: acronyms in caps
any not interface{}use-anyGo 1.18+ alias
No common/helpers/utils packagesvar-namingextraBadPackageNames
Error wrappingerr113, errorlintSentinel errors + wrap
Test helpersthelperMust use t.Helper()
Test parallelismtparallelSuggests t.Parallel()
Test env varstenvDetects os.Setenv in tests

Required Validation

After generating/modifying Go code:

golangci-lint run ./...

Do not modify .golangci.yml — linting config is protected by golangci-guard hook.

Enforced Project Structure

The skill MUST enforce this structure for all Go projects:

project/
├── cmd/
│   └── app/
│       └── main.go           # Entry point only
├── internal/
│   ├── config/
│   │   └── config.go         # Config with envPrefix
│   ├── errs/
│   │   └── errors.go         # Sentinel errors + helpers
│   ├── optional/
│   │   └── optional.go       # Pointer conversion helpers
│   ├── models/
│   │   └── {entity}.go       # Domain models + mappers
│   ├── services/
│   │   ├── registry.go       # Service registry
│   │   └── {entity}.go       # Business logic
│   ├── storage/
│   │   ├── storage.go        # Storage interface
│   │   ├── {entity}.go       # Repository impl
│   │   ├── main_test.go      # TestMain with testcontainers
│   │   └── testmigration/    # Test data fixtures (SQL)
│   │       ├── 100001_users.up.sql
│   │       └── 100001_users.down.sql
│   └── http/
│       └── v1/
│           ├── router.go     # Router + path constants
│           ├── {entity}_handler.go
│           ├── dto.go        # Request/Response types
│           └── json.go       # encode/decode
├── pkg/
│   ├── logger/
│   └── postgres/
├── migrations/
├── go.mod
├── .env.example
├── Makefile
├── Dockerfile
└── docker-compose.yml

Structure Rules

RuleCorrectWrong
Handler filesuser_handler.go, order_handler.gohandlers.go (all in one)
MappersIn models/{entity}.go with modelIn separate mappers/ package
DTOsIn http/v1/dto.goMixed with domain models
Path constantsIn router.goHardcoded strings in handlers
IDsstring typeuuid.UUID type
ID generationuuid.NewString() in serviceIn handler or repository
Config nestingUse envPrefix tagFull env var names in nested structs
Doc comments// User represents...// This struct...
Section organizationSeparate files// ----- Section -----

References

Core Patterns

PatternFile
Entry Pointentrypoint-pattern.md
Configurationconfig-pattern.md
Package Structurepackage-structure-decision.md
Database & Transactionsdatabase-pattern.md
Advisory Locksadvisory-lock-pattern.md
Service Layerservice-pattern.md
Repositoryrepository-pattern.md
Filter Patternfilter-pattern.md
Mappermapper-pattern.md
JSONB Typesjsonb-pattern.md
Optional Helperoptional-pattern.md
Error Handlingerror-handling.md
Logginglogging-pattern.md
Testingtesting-pattern.md
Test Fixturestest-fixtures-pattern.md
Moneymoney-pattern.md
Build & Deploybuild-deploy.md

HTTP Layer

PatternFile
HTTP Handlershttp-handler-pattern.md
Middlewaremiddleware-pattern.md
Validationvalidation-pattern.md
Authenticationauth-pattern.md

Production Patterns

PatternFile
Paginationpagination-pattern.md
Health Checkshealth-check-pattern.md
Background Workersworker-pattern.md
Tracingtracing-pattern.md

Best Practices

TopicFile
Naming Conventionsnaming-conventions.md
Package Namingpackage-naming.md
Control Structurescontrol-structures.md
Interface Designinterface-design.md
Allocation (new/make)allocation-patterns.md
Deferdefer-patterns.md
Embeddingembedding-patterns.md
Blank Identifierblank-identifier.md
Concurrencyconcurrency-pattern.md
Channel Axiomschannel-axioms.md
Lintinglinting-pattern.md
Common Pitfallscommon-pitfalls.md
Performanceperformance-tips.md
Code Qualitycode-quality.md

Examples

Core

ComponentFile
Mainmain.go
Backendbackend.go
Configconfig.go
Filterfilter.go
Common Modelscommon_models.go
Common Storagecommon_storage.go
Database Clientpg-client.go
Advisory Lockadvisory_lock.go
Repositoryrepository.go
Serviceservice.go
Mappermapper.go
JSONB Typesjsonb.go
Optional Helperoptional.go
Errorserrors.go
Logger (slog)logger_slog.go
Logger (zap)logger_zap.go
Test Setupmain_test.go
Test Fixtures (SQL)testmigration_example.sql
Repository Testsrepository_test.go
Service Testsservice_test.go
Moneymoney.go
Money Testsmoney_test.go

HTTP Layer

ComponentFile
HTTP Handlerhandler.go
Middlewaremiddleware.go
HTTP Errorshttp_errors.go
Authenticationauth.go

Production

ComponentFile
Paginationpagination.go
Health Checkhealth.go
Workerworker.go
Tracingtracing.go

Templates

FilePurpose
DockerfileMulti-stage build
MakefileBuild automation
docker-compose.ymlLocal development
.env.exampleEnvironment template

Dependencies

ALWAYS use @latest when adding new dependencies.

Recommended libraries:

# Core
go get golang.org/x/sync/errgroup@latest
go get github.com/caarlos0/env/v10@latest
go get github.com/jackc/pgx/v5@latest
go get github.com/Masterminds/squirrel@latest
go get github.com/pressly/goose/v3@latest
go get github.com/avast/retry-go@latest
go get github.com/google/uuid@latest
go get github.com/shopspring/decimal@latest

# HTTP Layer
go get github.com/go-chi/chi/v5@latest
go get github.com/go-playground/validator/v10@latest
go get gopkg.in/go-jose/go-jose.v2@latest

# Testing
go get github.com/stretchr/testify@latest
go get github.com/testcontainers/testcontainers-go@latest

# Tracing (OpenTelemetry)
go get go.opentelemetry.io/otel@latest
go get go.opentelemetry.io/otel/sdk@latest
go get go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@latest
go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@latest
go get github.com/exaring/otelpgx@latest

Version

  • 1.20.0 — Advisory lock pattern for serializable transactions: Serialize() method, enforcement hook, /go-add-repository includes Serialize() by default
  • 1.19.0 — Filter pattern for database queries: XxxFilter, getXxxCondition(), /go-add-repository generates filter scaffold
  • 1.18.0 — Dependency version enforcement: PreToolUse hook for go get @latest
  • 1.17.0 — Testcontainers integration: typed closer, testmigration/ fixtures, goose with sql.Open
  • 1.16.1 — Fix golangci-lint v2 schema: imports-blocklist, remove deprecated options
  • 1.16.0 — Protected .golangci.yml (hook + documentation)
  • 1.15.0 — Package naming: no common/helpers/utils, purpose-named packages (optional/, json.go)
  • 1.14.0 — Error handling: sentinel categories + wrap (internal/errs), helpers, no re-wrap
  • 1.13.1 — golangci-lint v2 fix: typecheck is built-in, wsl (not wsl_v5), troubleshooting
  • 1.13.0 — golangci-lint v2 migration (formatters, nolintlint anti-cheat, err113)
  • 1.12.0 — Comprehensive linting configuration (revive, depguard, exclusion patterns)
  • 1.11.1 — Channel axioms (nil/closed behavior, WaitMany, broadcast signaling)
  • 1.11.0 — Effective Go patterns (control structures, interfaces, allocation, defer, embedding, blank identifier)
  • 1.10.3 — Package structure decision guide (pkg/ vs internal/)
  • 1.10.2 — Config: embedded structs only (no named fields in main Config)
  • 1.10.1 — Fix: UserColumns() in models package only (not repository)
  • 1.10.0 — Repository pattern: Save as upsert, UserColumns() function, Values() method
  • 1.9.0 — Authentication patterns (gateway-based, full JWT validation)
  • 1.8.0 — Code quality tools (deadcode analysis, make deadcode target)
  • 1.7.1 — Comment conventions (stdlib-style doc comments, no decorative separators)
  • 1.7.0 — Handler-per-entity, Optional[T], JSONB types, Mapper pattern, Config envPrefix, IDs as string
  • 1.6.1 — Money pattern: NUMERIC database storage (was TEXT)
  • 1.6.0 — Money pattern (decimal precision, currency conversion, exchange rates)
  • 1.5.0 — Enhanced testing (testcontainers, testify mock, CI/Local detection)
  • 1.4.0 — Entry point pattern (backend, errgroup, graceful shutdown)
  • 1.3.0 — Best practices (naming, concurrency, pitfalls, performance)
  • 1.2.0 — Simple errors, OpenTelemetry tracing
  • 1.1.0 — HTTP Layer, Enhanced Errors, Production Patterns (pagination, health, workers)
  • 1.0.0 — Initial release

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.