sandgardenhq/sgai/go-code-review
Claude Code and agent skill by sandgardenhq/sgai
Trust tier 2
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Go code review checklist based on official Go style guides. When reviewing Go code for style, idioms, and best practices
Install
npx vskill@latest install sandgardenhq/sgai/go-code-reviewSKILL.md
Go Code Review
Comprehensive code review checklist based on official Go style guides.
Reference URLs
For deeper information, fetch these URLs:
- https://go.dev/wiki/CodeReviewComments - Go Code Review Comments
- https://go.dev/wiki/TestComments - Go Test Comments
- https://google.github.io/styleguide/go/decisions - Google Go Style Guide
Formatting
Gofmt
- [ ] Code formatted with
gofmtorgoimports - [ ] Tabs for indentation (not spaces)
Run: gofmt -w . or goimports -w .
Line Length
- No rigid limit, but avoid uncomfortably long lines
- Break lines by semantics, not arbitrary length
- Long lines often indicate need for shorter names or refactoring
Naming
Package Names
- [ ] Short, concise, lowercase
- [ ] No underscores or mixedCaps
- [ ] Avoid:
util,common,misc,api,types,interfaces - [ ] Name doesn't stutter:
chubby.Filenotchubby.ChubbyFile
Variable Names
- [ ] Short for limited scope:
c,i,r - [ ] Longer for broader scope
- [ ] Basic rule: further from declaration = more descriptive
Receiver Names
- [ ] 1-2 letter abbreviation of type:
cfor Client - [ ] Consistent across all methods
- [ ] Never
me,this,self
Initialisms
- [ ] Consistent case:
URLorurl, neverUrl - [ ]
ServeHTTPnotServeHttp - [ ]
xmlHTTPRequestorXMLHTTPRequest - [ ]
appIDnotappId
Getters/Setters
- [ ]
Owner()notGetOwner() - [ ]
SetOwner()is fine
Interface Names
- [ ] Single-method interfaces:
-ersuffix (Reader,Writer) - [ ] Multi-method interfaces: descriptive noun
Comments
Comment Sentences
- [ ] Full sentences starting with name being described
- [ ] End with period
- [ ] Doc comments on all exported names
Package Comments
- [ ] Adjacent to
packageclause (no blank line) - [ ] Full sentences
Error Handling
Handle Errors
- [ ] All errors checked (no
_, err := Foo()then ignored) - [ ] Errors returned or handled, not swallowed
Error Strings
- [ ] Lowercase (unless proper noun/acronym)
- [ ] No ending punctuation
- [ ]
fmt.Errorf("something bad")not"Something bad."
Error Flow
- [ ] Normal path at minimal indentation
- [ ] Error handling indented
Don't Panic
- [ ] Use error returns for normal error handling
- [ ] Panic only for truly unrecoverable situations
- [ ] Library code almost never panics
Context
- [ ] First parameter when used:
func F(ctx context.Context, ...) - [ ] Not stored in structs
- [ ] Passed through call chain
- [ ] Use
context.Background()only with good reason
Concurrency
Goroutine Lifetimes
- [ ] Clear when/whether goroutines exit
- [ ] No goroutine leaks (blocked on unreachable channels)
- [ ] Documented exit conditions for non-obvious cases
Synchronous Functions
- [ ] Prefer sync over async
- [ ] Let callers add concurrency
Race Detection
- [ ] Tested with
go test -race
Interfaces
Interface Location
- [ ] Defined at point of use (consumer), not implementation
- [ ] No premature interfaces
Return Types
- [ ] Return concrete types, not interfaces
- [ ] Let consumers define interfaces as needed
Data Types
Empty Slices
- [ ] Prefer
var t []string(nil slice) - [ ] Use
t := []string{}only when needed (JSON encoding)
Copying
- [ ] Don't copy values with pointer methods
- [ ] Be careful copying structs with slices (aliasing)
Pass Values
- [ ] Don't pass pointers just to save bytes
- [ ]
*stringand*io.Readerusually wrong - [ ] Pointers for large structs or mutation
Crypto Rand
- [ ]
crypto/randfor keys, notmath/rand - [ ]
crypto/rand.Text()for random text
Imports
Import Organization
- [ ] Standard library first, blank line, then others
- [ ] Grouped with blank lines
Import Naming
- [ ] Avoid renaming imports unless collision
- [ ] Rename most local/project-specific import on collision
Import Blank
- [ ]
import _ "pkg"only in main package or tests
Import Dot
- [ ] Only for external test packages with circular deps
- [ ] Never in regular code
Testing
Test Failures
- [ ] Helpful error messages
- [ ] Show what was wrong, inputs, actual vs expected
- [ ] Order: actual != expected, message matches
Test Names
- [ ]
TestFunctionNameformat - [ ] Subtests with clear names
Table-Driven Tests
- [ ] Use for multiple test cases
- [ ] Clear field names in test struct
Named Results
- [ ] Avoid when repetitive in godoc
- [ ] Use when clarifying multiple same-type returns
- [ ] Naked returns only in very short functions
In-Band Errors
- [ ] Return additional value for validity (error or bool)
- [ ] Don't use -1, "", nil as error indicators
Switch Statements
Direct Evaluation
- [ ] Use switch with expressions for cleaner multi-way conditionals
- [ ] Prefer switch over long if-else chains
- [ ] Switch evaluates cases top-to-bottom, first match wins
- [ ] No need for break statements (they're automatic)
Type Switches
- [ ] Use type switches for interface type assertions
- [ ] Use comma-ok idiom for safe type assertion
Fallthrough
- [ ] Avoid fallthrough unless intentional
- [ ] Use comma-separated cases when multiple values need same handling
Modern Go Idioms (Go 1.21+)
Standard Library Preferences
- [ ] Uses
slices.Sortinstead ofsort.Slice - [ ] Uses
slices.Sortinstead ofsort.Ints/sort.Float64s/sort.Strings - [ ] Uses
slices.Containsinstead of manual search loops - [ ] Uses
slices.Equalinstead of manual slice comparison - [ ] Uses
slices.Deleteinstead of append pattern for slice deletion - [ ] Uses
maps.Cloneinstead of manual map copy loops - [ ] Uses
maps.Equalinstead of manual map comparison - [ ] Uses
maps.Keys/maps.Values(Go 1.23+) for iteration
Generics
- [ ] Generic functions used for type-safe utilities
- [ ] Not over-generalized (use specific types when appropriate)
- [ ]
cmp.Orderedconstraint used for comparable types - [ ]
anyconstraint only when truly type-agnostic
Time-Dependent Code
- [ ] Uses dependency injection for
time.Now()calls - [ ] Clock interface pattern for testable time handling
- [ ] No direct
time.Now()in business logic
Iterators (Go 1.23+)
- [ ] Custom iterators use
iter.Seqoriter.Seq2 - [ ] Range over functions for custom iteration patterns
- [ ] Iterators return early when yield returns false
WaitGroup.Go (Go 1.24+)
- [ ] Uses
sync.WaitGroup.Gofor fire-and-forget goroutines - [ ]
wg.Go(fn)is equivalent togo func() { wg.Wait(); fn() }()but simpler - [ ] Preferred over
go func() { defer wg.Done(); fn() }()for simpler error handling
Dead Code Detection
Bare Blocks
- [ ] No unnecessary bare blocks
{ ... }wrapping code without if/for/switch - [ ] Bare blocks often indicate leftover code from refactoring
- [ ] Check for extra indentation levels that could be removed
Unused Code
- [ ] No unused imports (run
goimports -w .) - [ ] No unused variables (compiler will error)
- [ ] No unreachable code after return/panic/continue
- [ ] No functions only called from tests (unless test-only with build tag)
Leftover References
- [ ] No references to removed files (e.g.,
response.txtafter file-based transport removal) - [ ] No calls to removed functions
- [ ] No references to deprecated fields
Unreachable Code
- [ ] No code after
return,panic,breakin loops (unless in defer) - [ ] No dead branches in if-else after condition simplification
- [ ] No commented-out code blocks (delete, don't leave)
Variable Scope
- [ ] No variables that could be moved to tighter scope
- [ ] No shadowing of outer variables unintentionally
- [ ] Loop variables don't leak outside loop (use for-range copy or explicit variable)
Quick Checklist
For fast reviews, check these critical items:
- gofmt - Code is formatted
- Errors handled - No ignored errors
- Doc comments - Exports documented
- slices.Delete - Use for slice deletion (not append pattern)
- Naming - Short, idiomatic names
- Tests - Exist and helpful failures
- No panics - Error returns used
- Context - First param when used
- Interfaces - At consumer, not producer
- Modern idioms - Uses slices/maps packages where applicable
- Switch statements - Use switch for multi-way conditionals
- Dead code - No bare blocks, unreachable code, or leftover references
Review Output Format
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcmd/sgai/skel/.sgai/skills/coding-practices/go-code-review/SKILL.md
Popularity
- Repository stars
- 113
- Repository forks
- 6
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 27 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sandgardenhq/sgai/go-code-review)