Skip to content
Skill

Go refactoring

Guides an agent through behavior-preserving Go refactors, renames and package moves

Go refactoring is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
90
Last commit
License
MIT
Listing updated

Similar skills

About Go refactoring

This skill gives a coding agent a disciplined procedure for restructuring Go code without changing what it does. Each change is treated as one small, compiler-checked step: the agent confirms the build and tests are green, applies a single transformation, re-runs build, tests and go vet, and then commits before moving on. It includes a risk table that sorts transformations from low to high risk and calls for developer sign-off before cross-package moves, exported API changes or deletions.

The workflow covers renames through gopls, extracting a type into a new package behind temporary aliases, breaking circular dependencies by moving shared types or inverting them through consumer-side interfaces, changing function signatures with a deprecation cycle, and replacing a subsystem with a strangler migration. It also lists what does not count as a refactor, such as bug fixes or changes to JSON tags, and includes a checklist to run before finishing.

The skill expects a Go project with the Go toolchain and git installed. gopls is optional and only needed for semantic renames. It uses shell commands and reads or edits files in the repository. A reference file on bulk rewrites with gofmt -r, go fix, eg and gopatch is loaded only when needed.

When your agent uses it

Safe refactoring workflow for Go: behavior-preserving steps, compiler-checked renames, extracting packages, breaking circular dependencies, and strangler migrations — always behind green tests. Use when: "refactor this", "rename across the codebase", "extract a package", "break this circular dependency", "split this god package", "migrate callers", "clean up without changing behavior". Not for: choosing the target architecture (go-architecture-review), adopting new language features (go-modernize), performance rewrites (go-performance-review).

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 2 files (10 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

Download the skill folder from https://github.com/eduardo-sl/go-agent-skills and copy it into your agent's skills folder.

What it does

Risk-graded transformation table
Sorts refactoring steps into low, medium and high risk, with the checks each level requires before starting.
Compiler-checked package extraction
Moves a type into a new package in small steps, using temporary aliases so every commit stays green.
Circular dependency escapes
Offers three ordered ways to break an import cycle: extract a shared core, invert with an interface, or merge.
Safe signature changes
Adds a new function form, deprecates the old one, and migrates callers batch by batch.
Strangler subsystem migration
Stages the replacement of a large component behind a shared interface and a conformance test suite.
Commit and verification discipline
Requires one transformation per commit, with build, tests and go vet run at every step.

Good for

  • Rename a widely used exported type across a Go codebase
  • Extract a package out of a large god package
  • Break a circular dependency between two Go packages
  • Migrate callers from an old function signature to a new one
  • Replace a legacy storage layer incrementally without a big-bang rewrite
  • Clean up a Go module without changing its behavior

Go refactoring FAQ

What does the skill need to run?

It requires the Go toolchain and git. gopls is optional and is used for semantic renames.

Does Go refactoring change code on its own?

It guides the agent through edits such as renames and package moves, and it asks for developer approval before high-risk steps like cross-package moves or exported API changes.

When should Go refactoring not be used?

It is not for choosing a target architecture, adopting new language features, or performance rewrites. The skill points to other skills for those tasks.

Does Go refactoring add tests?

When test coverage is missing around the target code, the workflow says to write characterization tests first, before any refactor.

Does Go refactoring run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Go refactoring?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Go refactoring?

The closest alternatives to Go refactoring are Refactor, Go semantic tools, Refactor seams, Code simplification edho ferdian and Go modernize.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from eduardo-sl/go-agent-skills

  1. Guides Go agents in designing HTTP REST APIs, handlers, middleware and shutdown

    • Open source
    • 90 GitHub stars
    • Developer tools
  2. Reviews Go project structure, dependency direction and module boundaries

    • Open source
    • 90 GitHub stars
    • Developer tools
  3. Guides an AI agent to build Go command-line tools with clean flags, streams and exit codes

    • Open source
    • 90 GitHub stars
    • Developer tools
  4. Guides Go code toward constructor injection, explicit wiring and no global state

    • Open source
    • 90 GitHub stars
    • Developer tools
  5. Guides Go code toward idiomatic design patterns like functional options and factories

    • Open source
    • 90 GitHub stars
    • Developer tools
  6. Guides building Go GraphQL servers with gqlgen, covering N+1 batching and query limits

    • Open source
    • 90 GitHub stars
    • Developer tools