
Go Packages
Apply Uber- and Google-style Go import grouping, renaming, and blank-import rules so agent-written packages stay review-ready.
Overview
go-packages is an agent skill for the Ship phase that applies production Go import grouping, renaming, and blank-import rules to keep modules review-ready.
Install
npx skills add https://github.com/cxuu/golang-skills --skill go-packagesWhat is this skill?
- Defines minimal (stdlib vs external) and extended (proto + side-effect) import groupings with blank-line separators
- Renaming rules: mandatory for pb collisions, optional for urlpkg-style local variable clashes
- Documents blank imports for side-effect registration and protocol buffer naming conventions
- Aligns with large-org Go style guides for solo builders maintaining production modules
- Two grouping schemes documented: minimal (Uber) and extended (Google) with proto and side-effect groups
Adoption & trust: 647 installs on skills.sh; 110 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Agent-generated Go files mix stdlib and third-party imports in random order, risky renames, and missing side-effect imports that fail review.
Who is it for?
Solo builders maintaining Go services who want agents to mirror Uber/Google import hygiene without pasting style guides each session.
Skip if: Teams that rely solely on gofmt/golangci-lint with zero import-order policy, or non-Go codebases.
When should I use this skill?
Writing or reviewing Go files where import order, renames, or blank imports need to match team style.
What do I get? / Deliverables
Imports follow documented Uber/Google grouping with correct pb and urlpkg patterns, reducing style nits on the next PR.
- Reorganized import blocks per documented grouping and rename rules
- Consistent pb and urlpkg aliases where collisions occur
Recommended Skills
Journey fit
Import layout is enforced when polishing Go code before merge, alongside other style gates in the Ship phase. Review subphase covers mechanical consistency—stdlib-first groups, pb suffixes, and local rename precedence—that reviewers flag on every PR.
How it compares
Style playbook for import blocks—not a linter binary or module dependency resolver.
Common Questions / FAQ
Who is go-packages for?
Indie Go developers and small teams who want Claude Code, Cursor, or Codex to organize imports the way senior reviewers expect on backend and CLI repos.
When should I use go-packages?
Use it in Ship review when cleaning PRs, during Build backend work when scaffolding new packages, or beforeOperate iterate refactors that touch many import blocks.
Is go-packages safe to install?
It is documentation-only procedural knowledge with no shell or network calls; review the Security Audits panel on this Prism page before adding any skill to your agent.
SKILL.md
READMESKILL.md - Go Packages
# Import Organization Detailed rules and examples for organizing Go imports. ## Import Grouping Imports are organized in groups, with blank lines between them. The standard library packages are always in the first group. **Minimal grouping (Uber):** stdlib, then everything else. **Extended grouping (Google):** stdlib → other → protocol buffers → side-effects. ```go // Good: Standard library separate from external packages import ( "fmt" "os" "go.uber.org/atomic" "golang.org/x/sync/errgroup" ) ``` ```go // Good: Full grouping with protos and side-effects import ( "fmt" "os" "github.com/dsnet/compress/flate" "golang.org/x/text/encoding" foopb "myproj/foo/proto/proto" _ "myproj/rpc/protocols/dial" ) ``` ## Import Renaming Avoid renaming imports except to avoid a name collision; good package names should not require renaming. In the event of collision, **prefer to rename the most local or project-specific import**. **Must rename:** collision with other imports, generated protocol buffer packages (remove underscores, add `pb` suffix). **May rename:** uninformative names (e.g., `v1`), collision with local variable. ```go // Good: Proto packages renamed with pb suffix import ( foosvcpb "path/to/package/foo_service_go_proto" ) // Good: urlpkg when url variable is needed import ( urlpkg "net/url" ) func parseEndpoint(url string) (*urlpkg.URL, error) { return urlpkg.Parse(url) } ``` ## Blank Imports (`import _`) Packages that are imported only for their side effects (using `import _ "pkg"`) should only be imported in the main package of a program, or in tests that require them. ```go // Good: Blank import in main package package main import ( _ "time/tzdata" _ "image/jpeg" ) ``` ## Dot Imports (`import .`) **Do not** use dot imports. They make programs much harder to read because it is unclear whether a name like `Quux` is a top-level identifier in the current package or in an imported package. **Exception:** The `import .` form can be useful in tests that, due to circular dependencies, cannot be made part of the package being tested: ```go package foo_test import ( "bar/testutil" // also imports "foo" . "foo" ) ``` In this case, the test file cannot be in package `foo` because it uses `bar/testutil`, which imports `foo`. So the `import .` form lets the file pretend to be part of package `foo` even though it is not. **Except for this one case, do not use `import .` in your programs.** ```go // Bad: Dot import hides origin import . "foo" var myThing = Bar() // Where does Bar come from? // Good: Explicit qualification import "foo" var myThing = foo.Bar() ``` # Package Size, Program Structure, and CLIs Detailed guidance on package splitting, avoiding init(), the run() pattern, and CLI structure. ## When to Split a Package ``` Is the package getting too large? ├─ Can you describe its purpose in one sentence? │ ├─ No → Split by responsibility │ └─ Yes → Keep it, but check below ├─ Do files in the package never import each other's unexported symbols? │ └─ Yes → Those files could be separate packages ├─ Does the package have distinct user groups using different parts? │ └─ Yes → Split along user boundaries └─ Is the godoc page overwhelming? └─ Yes → Split to improve discoverability ``` ### When NOT to Split - Don't split just because a file is long — large files in a focused package are fine - Don't create packages with only one type or function - Don't split if it would create circular dependencies - Avoid splitting internal helpers into a `util` or `internal/helpers` package ### When to Combine Packages - If client code likely needs two types to interact, keep them together - If types have tightly coupled implementations - If users would need to import both packages to use either meaningfully ### File Organization No "one type, one file" convention in Go. Files should be focused enough to know which file contains something a