npx skills add ...
npx skills add github/gh-aw --skill go-linters
Add and validate custom Go analysis linters in gh-aw.
npx skills add github/gh-aw --skill go-linters
Use this guide when adding a new custom Go analysis linter in this repository.
For PR-driven linter generation (derive a rule from a specific pull request pattern), use .github/skills/pr-to-go-linter/SKILL.md.
pkg/linters/<linter-name>/.Analyzer).analysistest with fixtures under testdata/src/....cmd/linters/main.go so it runs via the multichecker binary.go test ./pkg/linters/<linter-name>/...go build ./cmd/lintersmake golint-custommake golint-custom builds cmd/linters and runs it against ./cmd/... and ./pkg/....
For linters that flag micro-optimizations (allocation/perf rules), only apply them on lines that
tests actually exercise — "hot paths" — rather than on dead or rarely-executed code where the
optimization brings no measurable benefit. Use the shared pkg/linters/internal/coverage package:
In your analyzer file, register a -hot-threshold flag in init() (not as a var initializer,
to avoid an Analyzer/run/flag initialization cycle):
Immediately before reporting a diagnostic, gate it with coverage.ShouldApply:
coverage.ShouldApply is permissive by default: when no coverage profile is loaded via the
GH_AW_LINT_COVERAGE_PROFILE environment variable, or when hot-threshold is 0, it always
returns true, preserving pre-coverage-aware behavior. Only wire this into linters whose fix has
a genuine performance rationale (extra allocations, O(n²) behavior, etc.) — purely
readability/style linters should not be coverage-gated.
This profile is read once per linter-runner process. To lint only a specific subtree, scope
the go test and golint-custom commands to the same package path.