go-packages
Skill7 starsChanged 10 days agoApache-2.0View on GitHub
Use when creating or splitting Go packages, organizing imports or dependencies, or structuring a new Go project. Individual identifier naming belongs to go-naming.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Rain-kl/OpenFlaretheir own version, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- Rain-kl/OpenFlare★ 298same 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 repository25 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- go-code-refactorSkill
- go-code-reviewSkill
- go-codeSkill
- go-concurrencySkill
- go-contextSkill
- go-databaseSkill
- go-data-structuresSkill
- go-defensiveSkill
- go-documentationSkill
- go-error-handlingSkill
- go-functionsSkill
- go-genericsSkill
- go-httpSkill
- go-interfacesSkill
- go-lintingSkill
- go-loggingSkill
- go-namingSkill
- go-performanceSkill
- go-resilienceSkill
- go-securitySkill
- go-style-coreSkill
- go-testingSkill
- go-troubleshootingSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Stop at the first rung that works:
- Very specific: line 117
Avoid init() where possible.
- Very specific: line 127
Call os.Exit or log.Fatal* only in main().
- Very specific: line 132
Best practice: Use the run() pattern — extract logic into a run that returns an error, called from main() with a single exit point:
- Very specific: line 154
Follow the project's flag naming convention.
- Very specific: line 158
Prefer the standard flag package, which already accepts -v and --v as the same flag.
≈ “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.
Files
Go Packages and Imports
Compatibility: Baseline Go 1.27 (see COMPATIBILITY.md). The
tooldirective requires Go 1.24+; stdlibuuidandencoding/json/v2Go 1.27+.
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, avoidinginit, structuringmain, or designing CLI flags/subcommands.references/DEPENDENCIES.md- Read when runninggo mod initor setting thegodirective, adding a module, usingreplaceorexclude, pinning a tool, tidying, or scanning before a release.
Dependency Ladder
Normative: Before adding a module to
go.mod, check the stdlib. Go 1.27 absorbed several of the most-added dependencies.
Stop at the first rung that works:
- Standard library — check
go doc <pkg>before assuming it is missing - A module already in
go.mod— reuse a suitable supported API - A new module, including
golang.org/x/...— when the above do not meet the contract or would require materially more implementation and maintenance
Judge suitability by required semantics, supported versions, and maintenance, not line count alone. Existing project conventions take precedence; this ladder does not require replacing a working dependency in neighboring code. A dependency is a convention; a standard-library idiom is not (Write Current Go).
Commonly added modules the standard library now covers:
| Was | Use instead | Since |
github.com/google/uuid | uuid — New/NewV4/NewV7, Parse/MustParse, Nil/Max, Compare, text marshaling | 1.27 |
| A third-party JSON library kept for speed | encoding/json, which runs on the v2 implementation (unmarshal faster, marshal slower than on 1.26); encoding/json/v2 + encoding/json/jsontext for v2 semantics or streaming | 1.27 |
github.com/sirupsen/logrus, go.uber.org/zap | log/slog (see go-logging) | 1.21 |
github.com/pkg/errors | fmt.Errorf with %w, errors.Is, errors.AsType | 1.13 / 1.26 |
golang.org/x/exp/slices, .../maps | slices, maps | 1.21 |
| A CSPRNG string helper | crypto/rand.Text | 1.24 |
encoding/json/v2 is not a drop-in replacement for encoding/json: it changes
omitempty, case-matching, and error semantics. Keep v1 for existing wire
formats; reach for v2 for new code or when you need jsontext streaming. Both
ship in the toolchain — no build tag or GOEXPERIMENT needed on Go 1.27.
For I/O forms and compatibility options, read
JSON v2 at API boundaries.
github.com/google/uuid stays justified for the algorithms stdlib uuid does
not have (v1, v3, v5, custom sources).
Adding and Auditing Dependencies
- Upgrade one module per change —
go get <module>@<version>, notgo get -u ./...— so a failure names its cause and the revert is one line; modules that release together count as one. A minor bump needs its release notes read, a major one its migration notes, and av0minor may break. Minimal version selection raises the indirect requirements the new version declares: the// indirectandgo.sumlines are part of the diff, andgo mod graph | grep <module>@names who pulled a surprise version. Tests run before and after;govulncheckcovers the new versions. - A checksum mismatch is a finding.
SECURITY ERRORfrom thegocommand means the bytes differ fromgo.sumor the checksum database: report the module, version, and both hashes. Never editgo.sumor setGOSUMDB,GONOSUMDB, orGOPRIVATEto get past it;go clean -modcachefixes only whatgo mod verifyreports asdir has been modified.
go mod init and the go directive, the pre-add check, replace and
exclude, tool pinning, tidy, and the release scan:
DEPENDENCIES.md.
Package Organization
Layout
cmd/<binary>holds eachmainpackage; everything it imports lives elsewhere.internal/holds packages that are not API. Use it for anything you do not want to support; do not wrap the whole module ininternal/pkg. A layer tree (internal/handlers,internal/services,internal/repositories,internal/models) fits one cohesive service; once several domains change independently, the same layer names move underinternal/<module>/.- Restructuring an existing module — a god package, a global layer tree several domains share, a monolith heading for modules — is go-code-refactor's ARCHITECTURE.md: the import-graph audit, the target shapes, the staged move, and the boundary test. This skill decides where a new package goes.
- A package named
util,helper, orcommonis a finding: go-naming owns the rule.
Package Size
Don't split just because a file is long, to create single-type packages, or if it would create circular dependencies.
Imports
| Rule | Guidance |
Blank imports (import _) | Only in main packages or tests |
import _ "embed" | Any package, in the file whose //go:embed fills a string or []byte — the compiler requires it |
Avoid init()
Avoid init() where possible. When unavoidable, it must be:
- Completely deterministic
- Independent of other
init()ordering - Free of environment state and I/O
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 a run that
returns an error, called from main() with a single exit point:
func main() {
if err := run(os.Args[1:], os.Stdout, os.Stderr); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}A CLI's run takes args []string, stdout, stderr io.Writer and builds its
flag set or command tree inside: a package-level FlagSet or cobra root keeps
flags and state from one test to the next.
Command-Line Flags
Advisory: Define flags only in
package main.
- Follow the project's flag naming convention; this pack defaults to
snake_case(--output_dir) when none exists. - Libraries should accept configuration as parameters, not read flags directly — this keeps them testable and reusable
- Prefer the standard
flagpackage, which already accepts-vand--vas the same flag; usepflagonly when POSIX/GNU conventions are required — grouped single-letter flags (-xvf) or short/long pairs (-v/--verbose)
Build Constraints and Embedded Files
- Platform-specific code lives in
_linux.go/_windows.gosuffix files or behind//go:build linux; a runtimeif runtime.GOOS == ...switch is the last resort. Every constrained file needs a fallback so the package still compiles undergo vet ./...on any GOOS. - Static assets (templates, SQL, schemas) ship via
//go:embedin the package that uses them — never by reading a relative path at runtime, which breaks as soon as the binary runs from another directory.
//go:embed schema/*.sql
var schemaFS embed.FSRelated Skills
- go-naming: package names, stuttering, exported symbols.
- go-error-handling:
%wversus%vat package boundaries. - go-linting: goimports local prefixes, import grouping.
- go-defensive: replacing
init(), mutable globals.
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
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.

