について
このClaude Skillは、Goコードベースに対して安全で振る舞いを保持するリファクタリングワークフローを提供し、すべての変更がコンパイラでチェックされ、合格したテストによって裏付けられることを保証します。コードベース全体での名前変更、パッケージの抽出、循環依存の解消、ストラングラーパターンを用いた移行の管理などのタスクを扱います。機能を変更せずに構造的な整理を行うために使用できますが、アーキテクチャの決定、新しい言語機能の採用、パフォーマンスの書き換えには使用できません。
クイックインストール
Claude Code
推奨npx skills add eduardo-sl/go-agent-skills -a claude-code/plugin add https://github.com/eduardo-sl/go-agent-skillsgit clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-refactoringこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
Go Refactoring Workflow
A refactor changes structure, never behavior. The definition of done is mechanical: same tests pass before and after every step, and every step is small enough to revert alone.
1. The Loop
- Baseline:
go build ./... && go test ./...must be green before touching anything. If tests are missing around the target code, write characterization tests FIRST — they pin current behavior, even if that behavior looks wrong. - One transformation from the catalog below.
- Verify: build + tests +
go vet ./.... - Commit. Never mix a refactor commit with a behavior change —
reviewers can skim a
refactor:commit; they must scrutinize a mixed one. - Repeat.
If step 3 fails and the fix isn't obvious in a minute, revert the step rather than debugging a half-applied transformation.
2. Renames — Let Tools Do Them
# Preferred: gopls (understands types, interfaces, embedding)
gopls rename -w internal/service/user.go:#offset newName
# Module path or package import path changes:
# update go.mod, then rewrite imports mechanically
find . -name '*.go' -exec sed -i 's|github.com/acme/old|github.com/acme/new|g' {} +
go build ./... # the compiler is the reviewer
Never rename an exported identifier of a published library without a
deprecation cycle: add the new name, mark the old one
// Deprecated: use NewName., delete in the next major version.
3. Extract Package
Moving code out of a god package, in compiler-checked steps:
- Create the new package; move one type and its methods (
goplsor cut/paste), leaving everything else. - In the old package, add type aliases so nothing breaks:
type User = user.User(aliases,=, not definitions). - Build. Migrate importers to the new path in batches; build each batch.
- Delete the aliases when no importer remains.
This keeps every commit green with an arbitrarily large caller base.
4. Break a Circular Dependency
Packages a → b and b → a won't compile; near-cycles show up as
god packages. Three escapes, in order of preference:
- Extract the shared core: both
aandbactually depend on a type — move it to a third packagecthat imports nothing. - Invert with an interface: if
storecalls back intoservice, define the callback interface INstore(consumer side) and letserviceimplement it. The arrow flips at compile time. - Merge: if two packages can't be described without each other, they were one package all along.
5. Change a Function Signature Safely
For exported functions with many callers:
// Step 1 — add the new form alongside the old
func (s *Service) ProcessCtx(ctx context.Context, id string) error { ... }
// Step 2 — old form delegates; mark deprecated
// Deprecated: use ProcessCtx.
func (s *Service) Process(id string) error {
return s.ProcessCtx(context.Background(), id)
}
// Step 3 — migrate callers batch by batch, building each batch
// Step 4 — delete the old form (same module) or keep until next major (library)
Inside a single module, prefer atomic signature changes when the compiler can find every caller for you: change it, then chase the build errors — that's the compiler enumerating your TODO list.
6. Strangler Migration for Subsystems
Replacing a subsystem (old store, legacy client) too big for one PR:
- Define the consumer-side interface the callers actually need.
- Make the OLD implementation satisfy it; wire callers to the interface.
- Build the new implementation behind the same interface; test both implementations against one shared conformance test suite.
- Switch the wiring in the composition root (one line, one commit, trivially revertible). Feature-flag it if risk warrants.
- Delete the old implementation in its own commit.
7. What Is NOT a Refactor
- "While I'm here" bug fixes — separate commit before or after.
- Reordering struct fields used with positional literals, changing exported error strings callers match on, changing JSON tags — these are behavior changes wearing refactor clothes.
- Rewrites without tests. If you can't pin behavior first, you're not refactoring; you're gambling.
Verification Checklist
- Baseline build + tests green before the first change
- Characterization tests added where coverage was missing
- Each commit is one transformation;
refactor:commits contain no behavior change - Renames done via gopls/compiler, not find-and-replace on identifiers
- Package extractions used type aliases to stay green mid-flight
- No new dependency cycles (
go build ./...proves it) - Public API changes follow the deprecation cycle
go vet ./...and the full test suite pass at every commit, not just the last- git log reads as a sequence of safe, revertible steps
GitHub リポジトリ
よくある質問
go-refactoring Skillとは何ですか?
go-refactoring はeduardo-sl が作成した Claude Skillです。Skillは、Claudeが必要に応じて読み込む指示とリソースをまとめ、追加の指示なしで go-refactoring に関連するタスクを実行できるようにします。
go-refactoring をインストールするには?
このページのインストールコマンドを使用してください。go-refactoring をプラグインとして Claude Code に追加するか、リポジトリを skills ディレクトリにクローンし、Claudeを再起動してSkillを読み込みます。
go-refactoring はどのカテゴリに属しますか?
go-refactoring は テスト カテゴリに属します。
go-refactoring は無料で利用できますか?
はい。go-refactoring は AIMCP に掲載されており、無料でインストールできます。
関連スキル
このClaudeスキルは、lm-evaluation-harnessを実行し、MMLUやGSM8Kなど60以上の標準化学術タスクでLLMをベンチマークします。開発者がモデルの品質を比較し、トレーニングの進捗を追跡し、学術的な結果を報告するために設計されています。このツールはHuggingFaceやvLLMモデルを含む様々なバックエンドをサポートしています。
このスキルは、cron式を使用してWorkersをスケジュールするためのCloudflare Cron Triggersの実装に関する包括的な知識を提供します。定期的なタスクの設定、メンテナンスジョブ、自動化されたワークフローの構築を網羅し、無効なcron式やタイムゾーン問題といった一般的な課題への対処法も含みます。開発者はこれを使用して、スケジュールされたハンドラーの設定、cronトリガーのテスト、WorkflowsやGreen Computeとの連携を構成できます。
このClaude Skillは、Playwrightベースのツールキットを提供し、Pythonスクリプトを通じてローカルWebアプリケーションのテストを可能にします。フロントエンドの検証、UIデバッグ、スクリーンショット撮影、ログ表示を実現し、サーバーライフサイクルを管理します。ブラウザ自動化タスクにご利用いただけますが、コンテキストの汚染を避けるため、スクリプトのソースコードを読むのではなく直接実行してください。
このスキルは、開発者がテストの合格を確認し、構造化された統合オプションを提示することで、完成した作業を仕上げることを支援します。実装が完了した後のマージ、PR作成、ブランチの整理といったワークフローを案内します。コードが準備できてテスト済みの際に使用し、開発プロセスを体系的に完了させましょう。
