Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides safe, behavior-preserving Go refactoring using gopls, gofmt -r, eg, gopatch and go/analysis fixers, landed as small stacked PRs.
57% 83%+26 ptsof test cases passed
Passed 19 of 23 test cases with the skill, and 13 of 23 without it.
3 of 3 safety checks passed
8 agent runs
1 forkA fork is a copy of this skill that someone made so they could edit it for their own use. The original doesn't change.
Each entry below follows the same structure: Motivation (why the refactoring earns its keep), Smell trigger (the code shape that signals it's time), Go mechanics (what the transform actually looks like in Go), Tool (what performs it), and Risk (matching the Risk Stratification table in SKILL.md). Entries are grouped by family, following the shape of Fowler's Refactoring catalog.
gopls codeaction -exec -kind=refactor.extract.function file.go:#start,#end
gopls codeaction -exec -kind=refactor.extract.method file.go:#start,#end
Editor-integrated as "Extract function"/"Extract method" in the code actions menu.
var temporaries instead of being duplicated wherever the parameter is used, implicit conversions at the call boundary are made explicit, and a callee body containing defer is wrapped in an immediately-invoked function literal so the deferred call still fires at the right point. Inline cannot cross a dynamic dispatch (interface method call, function value) or inline a generic function.gopls codeaction -exec -kind=refactor.inline.call file.go:#offset
:= binding immediately above the first use; the -all variant rewrites every syntactic occurrence of the expression in scope to reference the new variable. Extract Constant does the same for a literal that deserves a name and compile-time immutability. Inline Variable is the reverse: substitute the variable's value at its use site(s) and remove the binding.Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.