go-wire
Guides Google Wire dependency injection — composition root layout, Provide* providers, wireinject files, wire_gen workflow, and cleanup patterns.
Skill by tomyou666
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/tomyou666-go-wire
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: productivity
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/go-wire
What's inside
- Skill name
go-wire- Description
- Guides Google Wire dependency injection — composition root layout, Provide* providers, wireinject files, wire_gen workflow, and cleanup patterns. Use only when the user explicitly invokes this skill (e.g. /go-wire).
- License
- MIT
- Instructions
- 106 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Go Wire
Wire の定義は **composition root パッケージ1か所** に閉じる(例: `internal/app`)。他パッケージに `wireinject` を増やさない。
## ファイル役割(例)
プロジェクトごとに名前は異なる。典型的な分割:
| ファイル(例) | 役割 |
|----------------|------|
| ルート struct 定義 | 実行時に束ねる依存(例: `Application`) |
| `providers.go` | `Provide*`、Wire 用アダプタ型 |
| `wire.go` | `//go:build wireinject` + injector + `wire.Build` リストのみ |
| `wire_gen.go` | 生成物。**手編集禁止** |
- `wire.go` に Provider 実装を書かない。
- composition root に **ドメイン・ビジネスロジックを置かない** — 下位パッケージ(例: インフラ層・ドメイン層・ユースケース層など、プロジェクトのレイアウトに従う)へ委譲する。
## 固定ルール
1. **composition root は1パッケージ** — Wire グラフの組み立てはそこだけ。
2. **Provider 名は `ProvideXxx`** — 下位の `NewXxx` と区別する。
3. **グラフの型は基本具象** — `wire.Bind` は interface 差し替えが必要なときだけ。
4. **組み立ては `Provide*` が原則** — 複数フィールドをそのまま注入するだけの型は `wire.Struct(new(T), "*")`。
5. **リソースの teardown** — ライフサイクルがある Provider は `(T, func(), error)` を返してよい。呼び出し側は **injector の第2戻り値 `cleanup` だけ** を `defer` する(Provider ごとの `func()` は Wire が連結する)。
6. **`wire_gen.go` はコミット** — `providers.go` / `wire.go` 変更後は Wire を再生成し、生成差分もコミットする(プロジェクトの Makefile・`go generate` 等に従う)。
## 都度判断(固定しない)
- **ルート struct のフィールド** — エントリポイント(CLI・HTTP・GUI 等)が何を必要とするかで追加。中間依存を載せるかはケースごと。
- **`Provide*` 内のロジック量** — 薄い `New*` ラッパーから、`Init` / `Close` など composition まで root に書く場合もある。ビジネス処理は下位パッケージへ。
- **`wire.Struct` vs 新規 `Provide*`** — フィールド注入だけなら `wire.Struct`、それ以外は `Provide*` を優先しつつケースで決める。
## Injector
- エントリ injector は **基本1本**(例: `Initialize`)。別エントリが必要なら injector を分けるか、引数で分岐するかは都度判断。
- 引数は **必要に応じて injector に追加**(例: `context.Context`、設定 struct)。
- 戻り値の典型: `( *RootStruct, func(), error )` — 第2戻り値が cleanup。
`wire.go` の injector 本体は `return nil, nil, nil`(または型に合うゼロ値)のスタブ。`wire.Build(...)` に列挙する。
```go
//go:build wireinject
//go:generate go run github.com/google/wire/cmd/wire
func Initialize(ctx context.Context, cfg *Config) (*Application, func(), error) {
wire.Build(
wire.Struct(new(Application), "*"),
ProvideSomething,
wire.Struct(new(SomeAdapter), "*"),
)
return nil, nil, nil
}
```
## 依存追加チェックリスト
1. 実装を composition root **以外** の適切なパッケージに置く。
2. `providers.go` に `ProvideXxx` を追加(必要ならアダプタ型も同ファイル)。
3. ルート struct に載せるか判断(エントリポイントから直接使うか)。
4. `wire.go` の `wire.Build` に `ProvideXxx`(または `wire.Struct`)を追加。
5. Wire を再生成 — エラーなら Provider の引数・戻り値型を修正。
6. `wire_gen.go` をコミットに含める。
7. プロジェクトに docstring 規約があればそれに従う。
## パターン例
**薄い Provider**
```go
func ProvideService(repo *Repository) *Service {
return NewService(repo)
}
```
**ライフサイクル + cleanup**
```go
func ProvideClient(ctx context.Context, cfg *Config) (*Client, func(), error) {
c := NewClient(cfg)
if err := c.Connect(ctx); err != nil {
return nil, nil, err
}
return c, func() { _ = c.Close(ctx) }, nil
}
```
**アダプタ型 + `wire.Struct`**
composition 専用の接着型は `providers.go` に置き、`wire.Struct(new(Adapter), "*")` で注入。
**Provider 戻り値が interface** — `wire.Bind` なしでも可。複数実装の差し替えが必要なときだけ `wire.Bind` を検討。
## 禁止・注意
- `wire_gen.go` を手で直さない。
- composition root **以外** に `wireinject` を置かない。
- cleanup をルート struct のフィールドに持たせず、injector の `cleanup` に集約する。
- `wire.go` と `wire_gen.go` のビルドタグ(`wireinject` / `!wireinject`)を崩さない。
## コード生成
プロジェクトの手順に従う(例: `make wire`、`go generate ./...`、`cd <composition-root> && go run github.com/google/wire/cmd/wire`)。README や Makefile を確認する。From tomyou666/skills, MIT.
More from tomyou666/skills
- 0.565score
plan-ticket
tomyou666
Write one kanban ticket in Cursor Plan style: outcome, decisions, work sections, verification, and a checklist.
SkillAFreshness: AClaude Code +9 - 0.565score
pr-overview
tomyou666
Draft a Japanese pull/merge request title and body as a non-technical overview.
SkillAFreshness: AClaude Code +9 - 0.565score
update-changelog
tomyou666
Add an entry to CHANGELOG.md after implementing a feature, fix, or other notable change in this repo.
SkillAFreshness: AClaude Code +9 - 0.565score
code-comments
tomyou666
Add Japanese comments to implementations and Japanese summaries to tests.
SkillAFreshness: AClaude Code +9 - 0.565score
design-to-shadcn-css
tomyou666
Reads a specified DESIGN.md and syncs its color tokens into shadcn/ui CSS variables (:root and .dark) in globals.css or index.css, including semantic…
SkillAFreshness: AClaude Code +9 - 0.565score
git-commit-en
tomyou666
Generates Conventional Commits messages in English from session context and staged git diff.
SkillAFreshness: AClaude Code +9 - 0.565score
go-docstring-style
tomyou666
Enforces docstring writing in this Go project for functions, methods, and struct fields, with approved exceptions and multiline parameter supplements.
SkillAFreshness: AClaude Code +9 - 0.565score
impl-code-check
tomyou666
Review recent implementation for bug risk, dead code, missing tests, and error-handling gaps.
SkillAFreshness: AClaude Code +9 - 0.561score
plan-skill-annotate
tomyou666
Scans project Agent Skills directories and annotates a plan-mode markdown with applicable "Use the `skill-name` skill" notes on matching steps.
SkillAFreshness: AClaude Code +9 - 0.561score
qiita-article-planner
tomyou666
Qiita記事で書きたいテーマとペルソナ・原体験・ゴールを対話形式でヒアリングし、qiita-writing-principlesのコツを踏まえた日本語Markdownの見出し構成と各セクションの要約を生成するスキル。Qiita記事の企画・構成決めに使用する。
SkillAFreshness: AClaude Code +9 - 0.561score
qiita-sample-pattern-extractor
tomyou666
ユーザーが渡した複数のQiita記事サンプルから、いいねが付きやすそうな共通パターンを抽出し、再現テンプレートと執筆指針にまとめるスキル。Qiita記事のサンプル分析、勝ちパターン抽出、構成ルール化、記事スタイルの言語化をしたいときに使う。
SkillAFreshness: AClaude Code +9 - 0.561score
obsidian-vault
tomyou666
Obsidian Vault でノートを作成・移動・改名・編集するときに、フォルダ構成、命名、 作成フロー、Markdown と数式の書式を適用する。00-Inbox から 05-Archive への配置、 日記、ウィキリンク、LaTeX、タグ、フロントマターを扱うときに使う。 Vault 以外の README…
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Sep 27, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/tomyou666/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from tomyou666
- 0.565score
impl-code-check
tomyou666
Review recent implementation for bug risk, dead code, missing tests, and error-handling gaps.
SkillAFreshness: AClaude Code +9 - 0.565score
code-comments
tomyou666
Add Japanese comments to implementations and Japanese summaries to tests.
SkillAFreshness: AClaude Code +9 - 0.565score
design-to-shadcn-css
tomyou666
Reads a specified DESIGN.md and syncs its color tokens into shadcn/ui CSS variables (:root and .dark) in globals.css or index.css, including semantic…
SkillAFreshness: AClaude Code +9 - 0.565score
git-commit-en
tomyou666
Generates Conventional Commits messages in English from session context and staged git diff.
SkillAFreshness: AClaude Code +9 - 0.565score
go-docstring-style
tomyou666
Enforces docstring writing in this Go project for functions, methods, and struct fields, with approved exceptions and multiline parameter supplements.
SkillAFreshness: AClaude Code +9 - 0.565score
plan-ticket
tomyou666
Write one kanban ticket in Cursor Plan style: outcome, decisions, work sections, verification, and a checklist.
SkillAFreshness: AClaude Code +9
Cite this page
go-wire skill. Agent Mart. https://agentmart.dev/skills/tomyou666-go-wire (last updated 2026-10-24)