modern-go
Skill0 starsChanged 35 days agoMITView on GitHub
Modernize Go code to version-appropriate idioms, Go 1.0→1.27+, reading go.mod for the target version. Triggers: 现代化, 现代Go语言, modernize, gofix, idiomatic, update Go code.
2 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- smallnest/goal-workflowtheir own version, first seen Jul 3, 2026
- jidechao/claude-codex-goal-workflowedited, first seen Jun 4, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- jidechao/claude-codex-goal-workflow★ 417% same
Wrote their own version · 1
- smallnest/goal-workflow★ 283same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- evals/AGENTS.mdAGENTS.md
- conflictSkill
- diagnoseSkill
- harness-engineeringSkill
- open-source-skillSkill
- refactorSkill
- test-firstSkill
- triageSkill
- understandSkill
- graphSkill
- loop-itSkill
- merge-itSkill
- prdSkill
- review-itSkill
- ship-itSkill
- to-designSkill
- to-issuesSkill
- find-skillsSkill
- frontend-designSkill
- humanizer-zhSkill
- pptxSkill
- resume-optimizerSkill
- skill-creatorSkill
- svg-diagramSkill
- teachSkill
- ui-ux-pro-maxSkill
- web-design-guidelinesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 8 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
No version bump, no new requirement, no functional change: Do not raise the go directive, add a module dependency, or fold a bug fix or …
- Distinctive: line 20
One rule per commit: Never mix a modernization with a functional change, and never bundle several rules into one commit.
- Distinctive: line 27
Do not use it when:
- Distinctive: line 35
Follow the phases in order.
- Very specific: line 39
Read go.mod to extract the Go version (go 1.xx line).
- Distinctive: line 53
Read the file content.
- Very specific: line 56
Run goimports -w (or gofmt -w) on the file after all edits.
- Very specific: line 60
run go build ./... and go vet ./..., plus the project's tests.
- Distinctive: line 61
if a rule turns any of them red, revert that rule — do not patch around a modernization.
- Distinctive: line 62
commit each rule on its own, and never mix a modernization with a functional change.
- Distinctive: line 93
Never apply transformations that change semantics in edge cases without the user's awareness.
- Very specific: line 94
Do not apply omitzero blindly—it changes JSON serialization behavior.
- Very specific: line 95
Treat semantic migrations as suggestions, not auto-applies: math/rand/v2 (changes the random stream), iter.Seq iterators (reshapes the …
- Very specific: line 96
When replacing a bufio.Scanner loop with strings.Lines/bytes.Lines, remember the yielded line keeps its trailing \n.
- Very specific: line 97
Do not apply strings.SplitSeq or bytes.SplitSeq when the loop body references the index or the full slice elsewhere.
- Very specific: line 98
Do not apply strings.Builder if the concatenation happens outside a loop (single += is fine).
- Distinctive: line 99
When a transformation requires a new import, ensure the import is added to the file.
- Very specific: line 100
After all edits, run goimports -w on each modified file to clean up imports.
- Very specific: line 101
If goimports is not available, fall back to gofmt -w.
- Very specific: line 102
If the project has no go.mod, ask the user for the target Go version before proceeding.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
modern-go
Modernize Go source code by applying version-appropriate idioms, APIs, and language features. Works like go fix plus additional transformations curated from the Go team's modernize analysis passes and community best practices.
This skill is guidance, not a script. The version-by-version rule catalog is lookup material, not body content: it lives in references/, one file per version band, and you load only the bands your go.mod version makes eligible (see References). Work through those bands one rule at a time — do not read, or apply, the catalog as a checklist.
Scope limit
This skill changes how Go code is written, never what it does. Concretely:
- Behaviour-preserving only. A rewrite keeps observable behaviour identical, including error values, ordering and allocation semantics.
- Never exceed the declared Go version. A rule gated at, say, Go 1.24 is not eligible for a
go 1.22module. Never apply a transformation that requires a version higher than the project declares. - No version bump, no new requirement, no functional change. Do not raise the
godirective, add a module dependency, or fold a bug fix or feature into a modernization. - One rule per commit. Never mix a modernization with a functional change, and never bundle several rules into one commit.
- Suggestions are not edits. Rules the catalog marks as semantic migrations (
math/rand/v2,iter.Seq,os.Root,omitzero) are pointed out and applied only if the user opts in.
When to use it
Invoke this skill when the user asks to modernize Go code. By default, modernize the entire project; the user may specify a file or directory instead.
Do not use it when:
- the user wants a behaviour change — that is an ordinary edit, and mixing it with a modernization is exactly what this skill forbids;
- nothing declares the target version and the user will not name one — without a
go.modgodirective you cannot decide which rules are eligible; - the change is a single rename or signature edit — apply it directly; the catalog adds nothing.
Workflow
Follow the phases in order.
Phase 1: Detect
Read go.mod to extract the Go version (go 1.xx line). If no go.mod is found, default to go 1.21.
Phase 2: Gather files
Find all .go files in the target scope (project root, or user-specified file/directory). Exclude vendor/, .git/, and testdata/ directories.
Phase 3: Determine eligible rules
Load the references/ band(s) whose version range is at or below the detected version (see References). Each transformation includes a Go version gate—only apply when the project's go.mod version ≥ that version. Never apply a transformation that requires a version higher than the project's Go version.
Phase 4: Apply transformations
For each .go file, apply all transformations for versions ≤ the detected Go version. Process files sequentially. For each file:
- Read the file content.
- Identify applicable transformations by scanning for the "Before" patterns.
- Apply each transformation using the Edit tool.
- Run
goimports -w(orgofmt -w) on the file after all edits.
Apply one rule at a time, oldest gate to newest, and keep the build and the go vet/test gates green after each one:
- run
go build ./...andgo vet ./..., plus the project's tests; - if a rule turns any of them red, revert that rule — do not patch around a modernization;
- commit each rule on its own, and never mix a modernization with a functional change.
Phase 5: Report
Print a summary table showing:
- File: path relative to project root
- Transformations applied: list of transformation names per file
- Total files modified and total transformations applied
- Skipped transformations (available but not applicable due to version constraints) and their required Go version
Example Summary Output
## Modernization Summary
| File | Transformations |
|---|---|
| main.go | any, strings.Cut, min/max (2 occurrences) |
| pkg/handler.go | range over int (3), slices.Contains, t.Context() |
| pkg/util.go | new(expr) (1), errors.AsType → errors.Is |
**3 files modified, 10 transformations applied**
Skipped (requires higher Go version):
- new(expr): requires go 1.26 (project is go 1.24)
- WaitGroup.Go: requires go 1.25 (project is go 1.24)Safety Rules
- Never apply transformations that change semantics in edge cases without the user's awareness.
- Do not apply
omitzeroblindly—it changes JSON serialization behavior; flag it as a suggestion instead. - Treat semantic migrations as suggestions, not auto-applies:
math/rand/v2(changes the random stream),iter.Seqiterators (reshapes the API),os.Root(behavior/error-path change). Point them out and let the user opt in. - When replacing a
bufio.Scannerloop withstrings.Lines/bytes.Lines, remember the yielded line keeps its trailing\n; add aTrimSuffixif the old code relied onScanner.Text()semantics. - Do not apply
strings.SplitSeqorbytes.SplitSeqwhen the loop body references the index or the full slice elsewhere. - Do not apply
strings.Builderif the concatenation happens outside a loop (single+=is fine). - When a transformation requires a new import, ensure the import is added to the file.
- After all edits, run
goimports -won each modified file to clean up imports. - If
goimportsis not available, fall back togofmt -w. - If the project has no
go.mod, ask the user for the target Go version before proceeding.
Automated tooling (Go 1.27+)
Many of these transformations are now shipped as official modernizers in gopls/go fix. On Go 1.27+ the whole set can be applied across a module with:
go fix ./...gopls v0.22.0 added four notable passes covered above:
| Modernizer | Min Go | Transformation |
unsafefuncs | 1.17 | uintptr pointer math → unsafe.Add / unsafe.Slice |
atomictypes | 1.19 | primitive atomic.* funcs → typed atomic.Int32/Pointer[T] wrappers |
slicesbackward | 1.23 | descending-index loops → slices.Backward iterator |
embedlit | 1.27 | redundant embedded-field literals → promoted-field init |
Other modernizers in the same suite that this catalog covers: minmax, efaceany, fmtappendf, stringscut, stringsseq, sortslice/slicescontains, mapsloop, stditerators, forvar, rangeint, testingcontext, bloop, waitgroup, newexpr, errorsastype, appendclipped (→ slices.Concat), and plusbuild (→ drop obsolete // +build).
To disable an over-eager pass (e.g. slicesbackward rewriting loops that mutate the slice), scope the run with -fixes or exclude that analyzer in your editor's gopls settings.
References
Load only the bands your go.mod version makes eligible: a band is eligible when the detected version is at or above its version range, and a rule inside it applies only when its own heading's version gate is met.
references/go-1.0-1.17.md—time.Since/time.Until, loopstrings.Builder,errors.Is,//go:buildcleanup,unsafe.Add/unsafe.Slice. Read for every module.references/go-1.18-1.20.md—any,strings.Cut/bytes.Cut,fmt.Appendf, typed atomics,strings.Clone/bytes.Clone,CutPrefix/CutSuffix,errors.Join,context.WithCancelCause. Read forgo 1.18+.references/go-1.21-slices-maps.md— theslicesandmapspackages:Contains,Index,SortFunc,Max/Min,Reverse,Compact,Clip,Clone,Delete/Insert,Equal, andmaps.Clone/Copy/DeleteFunc. Read forgo 1.21+.references/go-1.21-language.md—min/max,clear,sync.OnceFunc/OnceValue,context.AfterFunc,context.WithTimeoutCause. Read forgo 1.21+.references/go-1.22.md—slices.Concat, range over integer, loop-variable shadow removal,cmp.Or,reflect.TypeFor, enhancedhttp.ServeMux,math/rand/v2. Read forgo 1.22+.references/go-1.23.md— range over function (iter.Seq), iterator helpers,strings.SplitSeq/FieldsSeq,bytes.SplitSeq,slices.Backward. Read forgo 1.23+.references/go-1.24.md—t.Context(),strings.Lines/bytes.Lines,os.Root,omitzero,b.Loop(). Read forgo 1.24+.references/go-1.25-1.27.md—sync.WaitGroup.Go,newwith expressions,errors.AsType, embedded field literals. Read forgo 1.25+.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

