一键导入
golang
Go coding standards and conventions for this project. Apply when writing, reviewing, or refactoring any Go source file.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Go coding standards and conventions for this project. Apply when writing, reviewing, or refactoring any Go source file.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Apply whenever writing content a human will read — emails, documents, reports, documentation, messages, UI copy, commit messages, explanations, or any other prose. Applies Strunk's timeless rules for clearer, stronger, more professional writing.
Migrate a Subversion (SVN) repository to a standalone Git repository by running the migration directly using inline PowerShell (on Windows) or bash (on macOS/Linux). The agent executes all commands itself — detection, each migration phase, and verification — using the powershell tool with inline code (never pointing to a .ps1 file, which is blocked by Group Policy). Use this skill whenever the user mentions SVN migration, converting SVN to Git, "we're moving away from SVN", "git svn is missing", "git-svn not found on Windows", or wants to import SVN history into a Git repo. Also use when someone asks how to preserve SVN history in Git, convert branches/tags from SVN, or set up a Git mirror of an SVN repo.
Autonomously optimize any Claude Code skill by running it repeatedly, scoring outputs against binary evals, mutating the prompt, and keeping improvements. Based on Karpathy's autoresearch methodology. Use when: optimize this skill, improve this skill, run autoresearch on, make this skill better, self-improve skill, benchmark skill, eval my skill, run evals on. Outputs: an improved SKILL.md, a results log, and a changelog of every mutation tried.
Workflow for generating conventional commit messages following the Conventional Commits specification. MUST be invoked every time a commit is created. Guides construction of standardized commit messages with correct type, scope, description, body, and footer.
Markdown formatting rules for this project. Apply when writing or editing any .md or .mdx file, including documentation and website content.
PowerShell cmdlet conventions for this project. Apply when writing or reviewing any .ps1 or module file.
| name | golang |
| description | Go coding standards and conventions for this project. Apply when writing, reviewing, or refactoring any Go source file. |
| triggers | ["on_commit"] |
Follow idiomatic Go practices and community standards when writing Go code. These instructions are based on Effective Go, Go Code Review Comments, and Google's Go Style Guide.
else statements - use early returns, continue, or break instead_ characters, hyphens, or mixedCapsutil, common, or base_ charactershttp.HTTPServer, prefer http.Server)Reader, Writer, Formatter)Read → Reader)const blocksgofmt to format codegoimports to manage imports automatically//) for most comments/* */) sparingly, mainly for package documentation_ unless you have a good reason (document why)fmt.Errorf with %w verberrlog package for logginglog.Error(err)log package handle itdefer log.Trace(time.Now(), args)
where args are the function arguments at the start of the function.else statements - they create unnecessary nesting and reduce readabilitycontinue in loops to skip to the next iteration instead of nestingbreak to exit loops early instead of complex conditional logic❌ BAD - Don't do this:
func processEntry(entry *Entry) string {
if entry.Expired() {
return "expired"
} else {
if entry.TTL < 0 {
return "never expires"
} else {
return fmt.Sprintf("expires at %s", time.Unix(entry.Timestamp, 0))
}
}
}
✅ GOOD - Do this instead:
func processEntry(entry *Entry) string {
if entry.Expired() {
return "expired"
}
if entry.TTL < 0 {
return "never expires"
}
return fmt.Sprintf("expires at %s", time.Unix(entry.Timestamp, 0))
}
❌ BAD - Nested loop logic:
for _, item := range items {
if item.IsValid() {
if item.ShouldProcess() {
// complex processing logic
}
}
}
✅ GOOD - Early continue:
for _, item := range items {
if !item.IsValid() {
continue
}
if !item.ShouldProcess() {
continue
}
// complex processing logic (happy path)
}
go.mod and go.sum)go mod tidy to clean up unused dependenciessync.WaitGroup or channels to wait for goroutinesselect for non-blocking operationssync.Mutex for protecting shared statesync.RWMutex when you have many readerssync.Once for one-time initializationerrors.New for simple static errorsfmt.Errorf for errors with runtime valueserrors.Is and errors.As for error checkingsync.Pool)pprof)testing.B for benchmarks_test package suffix for black-box testing_test.go suffixTestFunctionNameScenariot.Run for better organizationtestify/assert and testify/require for assertionslibtime for the time package.t.Helper()testing.TB interface for functions used in tests and benchmarkst.Cleanup()When a test mutates package-level variables (resolvers, loggers, clocks, time.Local, etc.),
save the original value into a local variable and restore it via t.Cleanup. Never restore to a
hardcoded value; you would overwrite whatever state preceded your test.
// ✅ CORRECT: save original, restore original
origResolver := myPackageResolver
t.Cleanup(func() { myPackageResolver = origResolver })
myPackageResolver = fakeResolver
origLocal := time.Local
t.Cleanup(func() { time.Local = origLocal })
time.Local = time.UTC
// ❌ WRONG: restores to a hardcoded value instead of the pre-test value
defer func() { time.Local = time.FixedZone("UTC", 0) }()
go fmt: Format codego vet: Find suspicious constructsgolint or golangci-lint: Additional lintinggo test: Run testsgo mod: Manage dependenciesgo generate: Code generationREQUIRED BEFORE EVERY COMMIT. Run the following commands in sequence after any Go code change. Commit after all pass with zero errors. Never skip this step; these linters catch real bugs and style violations that will be flagged in CI or code review.
Code Modernization: Apply modern Go best practices; this rewrites files in place
modernize --fix "./..."
modernizemodifies source files (e.g. replacingstrings.Splitwithstrings.SplitSeqfor Go 1.24+ range loops). Always stage its changes and include them in the same commit as your feature code.
Field Alignment: Optimize struct field ordering for memory efficiency; this rewrites files in place
fieldalignment --fix "./..."
Warning:
fieldalignmentrewrites struct field order. Any inline struct literals that use positional (unnamed) field initialization (common in table-driven test files) will break after the reorder. Always use named fields in struct literals (e.g.{Case: "foo", Now: t}) so that the order of fields in the struct definition does not matter.
Dependency Management: Clean up and organize module dependencies
go mod tidy
Formatting and Linting: Ensure code follows standards (must report zero errors)
gofmt -w .
golangci-lint run
After steps 1 through 3, always run git diff to review auto-applied changes before staging them.
All four steps must complete with zero errors before the commit is created.
_unix.go, _windows.go, _darwin.go)If you add or modify a file with a platform-specific suffix, also cross-compile to catch issues the local OS linter skips. On Windows, run:
$env:GOOS = "linux"; go build ./...; $env:GOOS = ""
On Linux/macOS, run:
GOOS=windows go build ./...
This catches import mismatches, missing symbols, and linter rules (like modernize
strings.SplitSeq) that apply on the non-host platform.
These rules frequently fire on new code and are quick to resolve before linting:
| Linter | Trigger | Fix |
|---|---|---|
goconst | Same string literal occurs 3+ times | Extract to a named const |
gofmt | Incorrect indentation or comment spacing | Run gofmt -w .; it fixes automatically |
dupl | Two functions/test cases with near-identical structure | Add //nolint:dupl with a brief reason comment |
modernize | strings.Split used in a for range (Go 1.24+) | Run modernize --fix "./..." (auto-fixes) |
interface{} or any)