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-refactoringUse cases
- Refactor an oversized Go function with gopls and gofmt transforms
- Break an import cycle between two Go packages
- Move types across packages through small stacked PRs
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
Golang Code Style
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing...
by samber
Golang Testing
Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with gole...
by samber
Golang Error Handling
Idiomatic Golang error handling — creation, wrapping with %w, errors.Is/As, errors.Join, custom error types, sentinel errors, panic/recover, the si...
by samber
Golang Security
Security best practices and vulnerability prevention for Golang. Covers injection (SQL, command, XSS), cryptography, filesystem safety, network sec...
by samber
Similar Skills
Find Skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", o...
by vercel-labs
Grill Me
A relentless interview to sharpen a plan or design.
by mattpocock
Ai Video Generation
Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0,...
by inference-sh
Ai Image Generation
Generate AI images with GPT-Image-2, FLUX, Gemini, Grok, Seedream, Reve and 50+ models via inference.sh CLI. Models: GPT-Image-2, FLUX Dev LoRA, FL...
by inference-sh