Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
cxuu avatar

Go Packages

  • 895 installs
  • 137 repo stars
  • Updated June 20, 2026
  • cxuu/golang-skills

go-packages is a Go agent skill that enforces standard import grouping and ordering conventions so developers produce readable, consistently structured Go source files.

About

go-packages is a Go agent skill from cxuu/golang-skills that standardizes how agents organize import blocks in generated and edited Go files. The skill documents minimal Uber-style grouping—standard library first, then everything else—and extended Google-style grouping that separates external packages, protocol buffers, and side-effect imports with blank lines between groups. Developers reach for go-packages when agents produce messy import blocks, mix stdlib with third-party paths, or omit proto aliases and side-effect import sections expected by team style guides. Examples show correct grouping for fmt and os alongside go.uber.org and golang.org/x dependencies, plus fuller layouts with protobuf and blank-import packages. The skill keeps import hygiene consistent across backend services and CLI tools without requiring manual goimports cleanup on every agent edit.

  • Enforces standard library first, followed by external packages with blank-line separation
  • Supports both minimal Uber-style and extended Google-style grouping including protocol buffers and side-effect imports
  • Defines precise renaming rules: must rename for collisions and generated protos (pb suffix), may rename for uninformativ
  • Provides concrete before-and-after code examples for import blocks and collision handling
  • Reduces import-related review comments and merge conflicts in Go projects

Go Packages by the numbers

  • 895 all-time installs (skills.sh)
  • +39 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #450 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cxuu/golang-skills --skill go-packages

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs895
repo stars137
Security audit3 / 3 scanners passed
Last updatedJune 20, 2026
Repositorycxuu/golang-skills

How should Go imports be grouped and ordered?

Enforce consistent, readable import organization in every Go file their agents produce.

Who is it for?

Go teams enforcing Uber or Google import grouping across agent-generated backend and CLI code.

Skip if: Repositories that rely solely on goimports or gofmt without custom multi-group import style requirements.

When should I use this skill?

User asks to organize Go imports, fix import grouping, or match Uber/Google Go style in .go files

What you get

Consistently grouped Go import blocks following Uber or Google conventions in edited .go files

  • Grouped Go import blocks
  • Style-consistent .go file edits

By the numbers

  • Covers 2 import styles: Uber minimal grouping and Google extended grouping
  • Google extended layout uses 4 import groups including protos and side-effects

Files

SKILL.mdMarkdownGitHub ↗

Go Packages and Imports

Resource Routing

  • references/IMPORTS.md - Read when grouping imports, using blank imports, dot imports, or import aliases.
  • references/PACKAGE-SIZE.md - Read when splitting packages, avoiding init, structuring main, or designing CLI flags/subcommands.
When this skill does NOT apply: For naming individual identifiers within a package, see go-naming. For organizing functions within a single file, see go-functions. For configuring linters that enforce import rules, see go-linting.

Package Organization

Avoid Util Packages

Package names should describe what the package provides. Avoid generic names like util, helper, common — they obscure meaning and cause import conflicts.

// Good: Meaningful package names
db := spannertest.NewDatabaseFromFile(...)
_, err := f.Seek(0, io.SeekStart)

// Bad: Vague names obscure meaning
db := test.NewDatabaseFromFile(...)
_, err := f.Seek(0, common.SeekStart)

Generic names can be used as part of a name (e.g., stringutil) but should not be the entire package name.

Package Size

QuestionAction
Can you describe its purpose in one sentence?No → split by responsibility
Do files never share unexported symbols?Those files could be separate packages
Distinct user groups use different parts?Split along user boundaries
Godoc page overwhelming?Split to improve discoverability

Do NOT split just because a file is long, to create single-type packages, or if it would create circular dependencies.

---

Imports

Imports are organized in groups separated by blank lines. Standard library packages always come first. Use goimports to manage this automatically.

import (
    "fmt"
    "os"

    "github.com/foo/bar"
    "rsc.io/goversion/version"
)

Quick rules:

RuleGuidance
Groupingstdlib first, then external. Extended: stdlib → other → protos → side-effects
RenamingAvoid unless collision. Rename the most local import. Proto packages get pb suffix
Blank imports (import _)Only in main packages or tests
Dot imports (import .)Never use, except for circular-dependency test files

---

Avoid init()

Avoid init() where possible. When unavoidable, it must be:

1. Completely deterministic 2. Independent of other init() ordering 3. Free of environment state (env vars, working dir, args) 4. Free of I/O (filesystem, network, system calls)

Acceptable uses: complex expressions that can't be single assignments, pluggable hooks (e.g., database/sql dialects), deterministic precomputation.

---

Exit in Main

Call os.Exit or log.Fatal* only in `main()`. All other functions should return errors.

Why: Non-obvious control flow, untestable, defer statements skipped.

Best practice: Use the run() pattern — extract logic into func run() error, call from main() with a single exit point:

func main() {
    if err := run(); err != nil {
        log.Fatal(err)
    }
}

---

Command-Line Flags

Advisory: Define flags only in package main.
  • Flag names use snake_case: --output_dir not --outputDir
  • Libraries should accept configuration as parameters, not read flags directly —

this keeps them testable and reusable

  • Prefer the standard flag package; use pflag only when POSIX conventions

(double-dash, single-char shortcuts) are required

// Good: Flag in main, passed as parameter to library
func main() {
    outputDir := flag.String("output_dir", ".", "directory for output files")
    flag.Parse()
    if err := mylib.Generate(*outputDir); err != nil {
        log.Fatal(err)
    }
}

---

Related Skills

  • Package naming: See go-naming when choosing package names, avoiding stuttering, or naming exported symbols
  • Error handling across packages: See go-error-handling when wrapping errors at package boundaries with %w vs %v
  • Import linting: See go-linting when configuring goimports local-prefixes or enforcing import grouping
  • Global state: See go-defensive when replacing init() with explicit initialization or avoiding mutable globals

Related skills

How it compares

Use this skill when team import conventions exceed default goimports output and agents must match documented grouping rules.

FAQ

What is Uber minimal Go import grouping?

go-packages describes Uber minimal grouping as two sections: all standard library imports first, then every other dependency, separated by a blank line. Agents apply this layout when generating readable Go files for services and CLIs.

How does Google extended import grouping differ?

go-packages adds Google extended grouping with four sections: standard library, other packages, protocol buffers, and side-effect imports, each separated by blank lines. The skill includes alias examples for proto packages in generated Go code.

Is Go Packages safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.