跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

go-quality-review

Review Go code for code quality, style, and modern Go practices including function length, nesting depth, naming, mutable globals, interface design, receiver consistency, modern Go idioms (slog, generics, typed atomics), and static analysis. Trigger when reviewing Go code structure, readability, or maintainability. Also runs golangci-lint for automated style checks.

johnqtcg · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add johnqtcg/awesome-skills --skill go-quality-review

技能说明


name: go-quality-review description: Review Go code for code quality, style, and modern Go practices including function length, nesting depth, naming, mutable globals, interface design, receiver consistency, modern Go idioms (slog, generics, typed atomics), and static analysis. Trigger when reviewing Go code structure, readability, or maintainability. Also runs golangci-lint for automated style checks. allowed-tools: Read, Grep, Glob, Bash(go build*), Bash(go vet*), Bash(golangci-lint*), Bash(gofmt*), Bash(staticcheck*)

Go Quality Review

Purpose

Audit Go code for structural quality, style conformance, and modern Go practices. This skill is the designated lint-tool runner — other vertical review skills do NOT run golangci-lint/staticcheck/go vet, avoiding duplicate execution.

This skill does NOT cover: security, concurrency, performance, error handling, test quality, or business logic — those belong to sibling vertical skills.

When To Use

  • Reviewing code structure and readability
  • Checking Go naming conventions and package organization
  • Evaluating use of modern Go features
  • Need to run golangci-lint / staticcheck / go vet

When NOT To Use

  • Security vulnerabilities → go-security-review
  • Concurrency safety → go-concurrency-review
  • Error handling correctness → go-error-review
  • Performance optimization → go-performance-review
  • Business logic → go-logic-review

Mandatory Gates

1) Go Version Gate

Read go.mod for go directive. Do NOT recommend features above project version.

FeatureMinimum Go
Generics1.18
Typed atomics (atomic.Int64, atomic.Bool)1.19
slog, slices/maps packages, min/max builtins, sync.OnceValue/OnceFunc1.21
Range-over-func, enhanced loop variable semantics1.22
iter.Seq, unique package1.23

2) Anti-Example Suppression Gate

MUST quote specific code evidence. Category match alone insufficient.

Embedded anti-examples:

  • "Should use generics" — when only one concrete type used throughout codebase. Generics add complexity without benefit for single-type usage.
  • "Should use slog" — when project targets Go < 1.21. Version-inappropriate recommendation.
  • "Should use typed atomics" — when project targets Go < 1.19.
  • "Exported function missing godoc" — when symbol is in internal/ package not intended for external consumers.
  • "Function too long (>50 lines)" — when body is a straightforward table-driven switch, sequential pipeline with no nesting, or single select/case block. These are long but simple.
  • "interface{} should be any" — pure cosmetic alias rename. Report only as part of broader modernization effort, never as standalone finding.
  • "Should extract helper function" — when the code would only be called from one place and extraction reduces readability by splitting context.

3) Static Analysis Execution Protocol

Run lint tools in this priority order:

  1. Check for .golangci.yml / .golangci.yaml — respect project config
  2. golangci-lint run (config-aware)
  3. staticcheck ./... (if golangci-lint unavailable)
  4. go vet ./... (minimal fallback) Report tool output in Execution Status. If no tools available, state Not available. Dedup rule: same location + same issue from multiple tools = report once.

4) Generated Code Exclusion Gate

Exclude: *.pb.go, *_gen.go, mock_*.go, *_string.go, *_enumer.go. Note excluded files in Execution Status.

Workflow

  1. Define scope — files/diff under review. Apply Generated Code Exclusion Gate.
  2. Check Go version from go.mod — gate all modern Go recommendations.
  3. Run static analysis — follow execution protocol above. Record output.
  4. Gather evidence — read changed files, identify quality/style patterns.
  5. Load references — always load go-error-and-quality.md (quality sections); load go-modern-practices.md when modern Go features relevant.
  6. Evaluate ALL 13 checklist items → cross-reference with lint output → suppress anti-examples → format.

Grep-Gated Execution Protocol

This skill uses mechanical grep pre-scanning to guarantee zero missed checklist items. 8 of 13 items are grep-gated; 5 are semantic-only.

Execution Order

  1. Identify target files (from dispatch prompt, or write raw snippet to $TMPDIR/review_snippet.go)
  2. Run grep for all grep-gated checklist items against target files
  3. HIT → run semantic analysis to confirm or reject
  4. MISS → auto-mark NOT FOUND, skip semantic analysis
  5. For semantic-only items (items 1, 2, 5, 9, 13): full model reasoning — these require structural analysis
  6. Report only FOUND items

Grep Audit Line

Include in Execution Status: Grep pre-scan: X/8 items hit, Z confirmed as findings (5 semantic-only)

Quality Checklist (12 Items)

All Medium severity unless marked (Low).

#ItemPatternGrep Pattern
1Function too long> 50 lines → extract helper (see anti-example for flat switch exception)Semantic-Only (function length requires counting lines — no grep pattern)
2Excessive nesting> 4 levels → early return pattern ("happy path left-aligned")Semantic-Only (nesting depth requires counting indent levels)
3Naked returnIn functions > 5 lines → explicit returns for clarityreturn$|return\s*$ (naked return — grep for return with nothing after)
4Mutable global variableMutable var at package level → const, getter, or functional options^var\s+\w (package-level var declarations — grep at file scope)
5Interface bloatInterface > 3 methods or defined at implementation site → small interfaces at consumer siteSemantic-Only (interface bloat requires counting methods)
6Type assertion without okx.(T) without comma-ok → x, ok := x.(T) — panics on wrong type\.\(\w (type assertion without comma-ok
阅读完整来源 ↗