skills/go-import/SKILL.md
Use when writing or reviewing Go imports, especially when a repository has existing formatting automation or import-grouping conventions that must be preserved.
npx skillsauth add hicker-kin/ai-context go-importInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Keep import grouping aligned with repository automation first, generic formatting rules second.
Makefile, Taskfile, justfile, scripts, or CI-documented commands.go.mod. In multi-module repos, repeat the fallback commands per module instead of running once from the repository root.gci is installed, run goimports -local $(go list -m) -w . from the module root and then apply the 3-group gci layout shown below.gci is not installed, install it with go install github.com/daixiang0/gci@latest only when the environment and user permissions allow installation, then apply the same 3-group layout.gci is not possible, accept the goimports -local $(go list -m) result as the fallback instead of inventing a repo-wide custom grouping by hand.gofmt -s afterward only if the repo or surrounding workflow expects it.Before changing imports, check for any of the following:
Makefile, Taskfile, or justfile formatting targetsscripts/, hack/, or similar repo utility directoriesgoimports, gci, golangci-lint, or custom formatting commandsIf those sources disagree, follow the most explicit executable automation over prose documentation.
Apply this layout only when the repo does not already define a different executable formatting command. The example assumes it runs from a Go module root; in multi-module repositories, run the same pattern separately inside each module.
MODULE := $(shell go list -m)
.PHONY: fmt
fmt:
goimports -local $(MODULE) -w .
gci write --skip-generated \
-s standard \
-s default \
-s "prefix($(MODULE))" \
.
This example produces 3 groups:
$(MODULE)If a repository already uses gci or another formatter with different sections, follow that configuration instead of normalizing back to the generic 3-group layout.
When manual judgment is needed and the repo does not define a different rule, keep imports in this order with one blank line between present groups:
go.mod module valueOmit missing groups. Single-import files need no grouping blank line.
Only split shared organization packages into their own middle group when the repository already does that through formatter config or established file patterns.
goimports or gci already produced a stable resultFor full usage examples, see examples.md.
development
Guides Go development to follow project architecture and code style rules. Use when implementing or reviewing Go code, adding features, refactoring, or when the user asks to follow project rules or standards. Ensures compliance with ai_go/v1/rules (project_architecture.md, code_style.md) and .cursor/rules.
development
Use when adding or configuring structured logging in Go projects, integrating zap-based log with request context, or when the user asks about logging. Places log package under pkg/logs for new projects.
development
Use when implementing JWT token signing or verification in Go projects. Covers ES256 (ECDSA, recommended), PS256/RS256 (RSA asymmetric), and HS256 (HMAC symmetric) signing methods, with keys loaded from file path or inline string. Places the jwt package under pkg/jwt for new projects.
development
Recommends and scaffolds frontend technology stack for new projects. Use when starting a new frontend project, selecting a framework, setting up a web app from scratch, or when the user asks about frontend tech stack, scaffolding, or architecture selection. Covers React/Next.js/Astro/Vue, TypeScript, Tailwind CSS, state management, data fetching, UI components, testing, and monorepo setup.