Skip to main content

pr-to-go-linter

Generate a new pkg/linters analyzer from a merged or open PR pattern.

来源信息

仓库
github/gh-aw
最近来源活动
2026年5月18日 14:03
检测到的 SKILL.md 语言
英语
星标
5,381
分支
584

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
pr-to-go-linter
description
Generate a new pkg/linters analyzer from a merged or open PR pattern.
# PR to Go Linter Use this skill when a user asks to create a new custom Go linter based on a code pattern fixed in a pull request. ## Goal Convert one concrete PR pattern into a new `go/analysis` linter under `pkg/linters/<name>/` with tests and runner registration. ## Inputs - Repository owner/name - Pull request number - Target linter name (kebab-case) ## Workflow 1. Read PR metadata and changed files. 2. Read the PR diff and extract the repeated pattern that was fixed. 3. Define one precise diagnostic rule from that pattern. 4. Confirm no existing linter in `pkg/linters/` already covers it. 5. Implement: - `pkg/linters/<name>/<name>.go` with exported `Analyzer` - `pkg/linters/<name>/<name>_test.go` using `analysistest` - `pkg/linters/<name>/testdata/src/<name>/<name>.go` fixtures with `// want` - `cmd/linters/main.go` registration in `multichecker.Main(...)` 6. Validate: - `go test ./pkg/linters/<name>/...` - `go build ./cmd/linters` - `make golint-custom` ## Rule quality checks - High signal, low false positives on this repository. - Diagnostic is specific and fixable. - Rule scope matches code in the PR (do not generalize beyond evidence). - Do not change unrelated linter packages. ## Example pattern source For PR `#33038` (`Refactor pkg mutex sites to use deferred unlocks consistently`), derive a linter idea that reports lock/unlock sections that manually unlock instead of deferring unlock immediately after lock when the function body matches the same cache/logger-style critical section pattern. ## Output expectations - Minimal implementation-only diff in `pkg/linters/<name>/` and `cmd/linters/main.go`. - Tests prove both flagged and non-flagged cases. - PR summary explains: source PR, extracted pattern, and why the rule is safe.
在 GitHub 查看