SKILL11.5K installs3.7K

Golang Refactoring

Golang refactoring — the safe, at-scale process for restructuring existing Go code: a coverage-adaptive safety net, tool-driven behavior-preserving transforms (gopls Rename/Inline/Extract, `gofmt -r`, `eg`, `gopatch`, `go/analysis` fixers), the Fowler catalog mapped to Go, breaking import cycles, moving types across packages, and a human-in-the-loop workflow of small stacked PRs on a refactoring branch. Apply when code is hard to maintain, a function/type has grown too large, a code smell needs fixing, adding a feature is blocked by the current structure, or the user asks to clean up, refactor, or improve Go code — also for renaming at scale, extracting functions/interfaces, moving code between packages, splitting packages, or planning a multi-step refactor. Target styles owned elsewhere → See `samber/cc-skills-golang@golang-naming` (renames), `@golang-project-layout` (splits), `@golang-modernize` (idioms), `@golang-code-style` (control flow), `@golang-design-patterns` (patterns/DI).

Type
Skill
Author
samber
Category
Backend
GitHub stars
3.7K
Installs
11.5K
Last updated
November 1, 2026

Install

npx skills add https://github.com/samber/cc-skills-golang --skill golang-refactoring

Use cases


Frequently Asked Questions

Which tools does it use for transforms?

gopls Rename/Inline/Extract, gofmt -r, eg, gopatch, and go/analysis fixers.

How does it keep a refactor safe?

It builds a coverage-adaptive safety net, relies on behavior-preserving transforms, and works in small stacked PRs on a refactoring branch.

Which concerns are owned by other skills?

Renaming style, project layout, modernization idioms, code style, and design patterns are handled by sibling golang skills.


About this skill

A process for restructuring existing Go code safely at scale: a coverage-adaptive safety net, tool-driven behavior-preserving transforms (gopls Rename/Inline/Extract, gofmt -r, eg, gopatch, go/analysis fixers), the Fowler catalog mapped to Go, breaking import cycles, and moving types across packages. The workflow is human-in-the-loop with small stacked PRs on a refactoring branch. Apply it when code is hard to maintain, a function or type has grown too large, or a feature is blocked by current structure; naming, layout, modernization, and design-pattern concerns are owned by sibling skills.

Summary written with AI assistance from the project's public description.


Categories


More from samber


Similar Skills