PlugWiki

golang-refactoring Skill for Claude Code: Safe Go Refactoring

Makes Claude refactor Go code in small, tool-checked steps, with a test safety net and a human sign-off before any edit.

Installs
12.2K
on skills.sh
Stars
3.7K
on GitHub
Files
5
besides SKILL.md
Updated
Nov 2026
last repo commit

golang-refactoring makes Claude plan a Go refactor before it touches code, then carry it out one small change at a time. It prefers gopls Rename and Inline, gofmt -r and similar tools over hand edits, adds tests first when coverage is thin, and never mixes structure changes with behavior changes in one commit or PR. It loads when you ask to refactor Go code, rename at scale, extract functions or interfaces, move code between packages or plan a multi-step refactor.

It needs go and gopls on your machine, plus git. In plan mode it asks for your sign-off through the question tool before any edit, and again before cross-package moves, exported-API changes or deletions. Larger refactors run as one sub-agent, worktree and PR per change, all targeting a refactor/<topic> branch.

Good for

  • Go developers with a function, type or package that has grown too large
  • Teams planning a rename, extraction or package split across many files
  • Reviewers who want refactor PRs kept small and separate from behavior changes

Install golang-refactoring

Claude Code

  1. 1

    Copy this prompt.

    Install the golang-refactoring skill in Claude Code. Run this command:
    
    /plugin marketplace add samber/cc
    /plugin install cc-skills-golang@samber
    
    Then check that it loaded and tell me how to use it.
  2. 2

    Paste it into Claude Code. It shows the change and asks before running it.

Requires gopls and git installed.

The plugin installs the whole Go set (the repo has 46 skill folders); its manifest lists no hooks or MCP servers. The README says the skills reference each other and recommends installing the general-purpose ones together. This skill's SKILL.md only points to the others with 'See', so the single-skill command also works. Install go and gopls yourself first.

From the project README. Source.

What's in the skill

When it loads

Golang refactoring — safe, at-scale restructuring of existing Go code: a coverage-adaptive safety net, behavior-preserving transforms (gopls Rename/Extract, `gofmt -r`, `gopatch`), the Fowler catalog mapped to Go, breaking import cycles, and small stacked PRs. Apply when a function or type has grown too large, a code smell blocks a feature, or the user asks to refactor Go code — also for renaming at scale, extracting functions or interfaces, moving code between packages, or planning a multi-step refactor. Target styles owned elsewhere → See `samber/cc-skills-golang@golang-naming` (renames), `samber/cc-skills-golang@golang-project-layout` (splits), `samber/cc-skills-golang@golang-modernize` (idioms), `samber/cc-skills-golang@golang-code-style` (control flow), `samber/cc-skills-golang@golang-design-patterns` (patterns/DI).

Sections in SKILL.md

  1. The Core Loop
  2. Hard Rules
  3. When Not to Refactor
  4. Risk Stratification
  5. Workflow: Plan → Stage → Land
  6. Detailed References
  7. Cross-References

Key facts

License
MIT
Installs on skills.sh
12,162 (Nov 2, 2026)

What it includes

  • Maps blast radius with gopls and gets your sign-off before any edit.

    Mandatory before editing. The agent builds a refactoring inventory, decides the order of changes and asks for approval through the question tool.

    Runs code · Plan mode

  • One sub-agent, worktree, branch and PR per change, landed on a refactor branch.

    Each atomic change gets its own worktree and branch off the refactor/<topic> branch, then a PR opened with gh pr create. You review and merge each one. The final merge into main is opened as a draft.

    Runs code · Execute mode

  • One mechanical transform applied across the whole tree.

    For a single behavior-preserving rewrite, such as one gofmt -r, eg or modernize fixer. It may use ultracode.

    Runs code · Simple-sweep mode

  • Reviews a refactor PR for structure/behavior separation and preserved behavior.

    Used when you ask Claude to check someone's refactoring PR before approving.

    Read · Review mode

  • Coverage thresholds and characterization-test recipes for untested code.

    Sets how aggressive the refactor can be, based on test coverage of the code being touched.

    references/safety-net.md

  • gopls code actions, gofmt -r, eg, gopatch and go/analysis fixers.

    The ladder of tools, from simple rewrites to generated fixers, used for changes that repeat across many sites.

    references/go-tooling.md

  • The Fowler refactoring catalog mapped to Go.

    Each entry lists the code smell, the mechanics, the tool and the risk.

    references/catalog.md

  • Breaking import cycles, package boundaries and type aliases for moved types.

    Covers consumer-side interfaces for cycles, type aliases for gradual moves and exported-API changes.

    references/structural.md

  • Planning gate, PR ordering, git model and REFACTOR(step N) markers.

    The full staging process for multi-step refactors.

    references/workflow.md

From the official docs

Permissions

Medium risk

It edits your Go code, creates branches and worktrees, and opens pull requests with gh. Keep the sign-off gates on and review each PR before merging.

What it can do

  • Read your data
  • Create and change things
  • Delete things
  • Read-only mode

Watch out for

  • It edits code and opens PRs

    Its allowed tools include Edit, Write and Bash for git and gh, and the workflow runs gh pr create. Check each PR before you merge it. github.com

  • It asks you to install gopls

    The skill's metadata lists go install for gopls and benchstat at latest. Install them yourself and read what they do first. github.com

  • It can fetch from the web

    WebFetch and WebSearch are in its allowed tools. The SKILL.md names no hosts. github.com

Technical details
Scopes
  • go

  • gopls

  • golangci-lint

  • git

  • gh

  • benchstat

Questions

What does golang-refactoring do?

It makes Claude refactor Go code in small steps. It plans first, adds tests where coverage is thin, uses gopls and other tools for the edits, and lands each change as its own small PR.

How do I install golang-refactoring?

Use the install box above. On Claude Code the README's route is the plugin, which adds the whole Go set. The skills CLI command installs only this skill. Install go and gopls yourself either way.

Does it work in the Claude app or Codex?

Its SKILL.md says it is designed for Claude Code, Codex or a similar harness, for Go projects with gopls and git. The README documents no Claude app upload, and the skill runs local commands, so use Claude Code or Codex.

Does it need an API key?

SKILL.md names no API key. It needs go, gopls and git, and can use golangci-lint, benchstat, deadcode, eg and gopatch if you have them.

Is it safe to run on my repo?

It edits code and opens PRs with gh, so run it on a clean, committed branch. SKILL.md has it ask for your sign-off before editing, before cross-package moves, API changes and deletions, and when the code has no tests. Review every PR it opens.

How is it different from golang-modernize or golang-naming?

This skill owns how to apply a change safely at scale. Its SKILL.md leaves what to rename to, and version-driven idiom updates, to the golang-naming and golang-modernize skills in the same repo.

Information

updated Nov 2, 2026

Folder
skills/golang-refactoring

samber/cc-skills-golangskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 7
  1. cc-skills-golang README · github.com
  2. samber/cc marketplace.json · github.com
  3. plugin.json · github.com
  4. golang-refactoring SKILL.md · github.com
  5. workflow.md · github.com
  6. golang-refactoring on skills.sh · skills.sh
  7. samber/cc-skills-golang · github.com

Updated Nov 2, 2026.