- name
SKILL.md
技能檔案保留在發布者的儲存庫中。
在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add samber/cc-skills-golang --skill golang-project-layout -a cursor -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add samber/cc-skills-golang --skill golang-project-layout -a claude-code -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add samber/cc-skills-golang --skill golang-project-layout -a codex -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add samber/cc-skills-golang --skill golang-project-layout -a grok -y在 Grok Bot 聊天中傳送複製的訊息。Bot 會從 GitHub 取得這個 SKILL.md,並加入你所有 Bot 共用的技能中。
Install this skill: https://github.com/samber/cc-skills-golang/tree/HEAD/skills/golang-project-layout來自發布者
Persona: You are a Go project architect. You right-size structure to the problem — a script stays flat, a service gets layers only when justified by actual complexity.
Questions: Ask the user through the environment's question tool — never as plain-text prose. Architecture preference and DI approach are asked one at a time, in that order, waiting for each answer before proceeding — getting either wrong early cascades into every file created afterward.
When starting a new project, ask the developer what software architecture they prefer (clean architecture, hexagonal, DDD, flat structure, etc.). Avoid over-structuring small projects — a 100-line CLI tool does not need layers of abstractions or dependency injection.
→ See samber/cc-skills-golang@golang-design-patterns skill for detailed architecture guides with file trees and code examples.
After settling on the architecture, ask the developer which dependency injection approach they want: manual constructor injection, or a DI library (samber/do, google/wire, uber-go/dig+fx), or none at all. The choice affects how services are wired, how lifecycle (health checks, graceful shutdown) is managed, and how the project is structured. See the samber/cc-skills-golang@golang-dependency-injection skill for a full comparison and decision table.
For applications (services, APIs, workers), follow 12-Factor App conventions: config via environment variables, logs to stdout, stateless processes, graceful shutdown, backing services as attached resources, and admin tasks as one-off commands (e.g., cmd/migrate/).
Your module path in go.mod should:
github.com/username/project-namegithub.com/you/my-app (not MyApp)user-auth not user_auth or userAuthExamples:
// ✅ Good
module github.com/jdoe/payment-processor
module github.com/company/cli-tool
// ❌ Bad
module myproject
module github.com/jdoe/MyProject
module utils
Packages MUST be lowercase, singular, and match their directory name. → See samber/cc-skills-golang@golang-naming skill for complete package naming conventions and examples.
All main packages must reside in cmd/ with minimal logic — parse flags, wire dependencies, call Run(). Business logic belongs in internal/ or pkg/. Use internal/ for non-exported packages, pkg/ only when code is useful to external consumers.
See directory layout examples for universal, small project, and library layouts, plus common mistakes.
Every Go project should include at the root:
samber/cc-skills-golang@golang-lint skill for the recommended configurationFor application configuration with Cobra + Viper, see config reference.
Co-locate _test.go files with the code they test. Use testdata/ for fixtures. See testing layout for file naming, placement, and organization details.
Use go.work when developing multiple related modules in a monorepo. See workspaces for setup, structure, and commands.
When starting a new Go project:
samber/cc-skills-golang@golang-dependency-injection skillgo version to detect the current go versiongo mod init github.com/user/project-namecmd/{name}/main.go for entry pointinternal/ for private codepkg/ only if you have public librariesgo work and add modulesgofmt -s -w . to ensure formatting.gitignore with /vendor/ and binary patternssamber/cc-skills-golang@golang-how-to into the project's agent-config file (CLAUDE.md, AGENTS.md, or equivalent) — no user confirmation needed, see that skill's Configure modesamber/cc-skills-golang@golang-cli skill for CLI tool structure and Cobra/Viper patterns.samber/cc-skills-golang@golang-dependency-injection skill for DI approach comparison and wiring.samber/cc-skills-golang@golang-lint skill for golangci-lint configuration.samber/cc-skills-golang@golang-continuous-integration skill for CI/CD pipeline setup.samber/cc-skills-golang@golang-design-patterns skill for architectural patterns.samber/cc-skills-golang@golang-refactoring skill for safely moving or splitting existing code into the layout above via type-alias gradual code repair and staged PRs, without a big-bang break.samber/cc-skills-golang@golang-how-to skill's Configure mode for the always-load directive and optional ## Required Go skills block written to the project's agent-config file (CLAUDE.md, AGENTS.md, or equivalent).Golang project layout and workspace setup — cmd/internal/pkg directory conventions, module and package naming, go.work workspaces, and essential configuration files. Use when starting a new Go project
---name: golang-project-layoutdescription: Golang project layout and workspace setup — cmd/internal/pkg directory conventions, module and package naming…---# skills/golang-project-layout/SKILL.md總覽
Golang project layout and workspace setup — cmd/internal/pkg directory conventions, module and package naming, go.work workspaces, and essential configuration files. Use when starting a new Go project, organizing an existing codebase, setting up a monorepo with multiple packages, creating CLI tools with multiple main packages, or discussing package restructuring, package splits, or module splits. Not for restructuring existing code without a layout change (→ See `samber/cc-skills-golang@golang-refactoring` skill).
常見問題
從發布者下載 skills/golang-project-layout/SKILL.md,或複製路徑後開啟儲存庫。PlugMCP 只收錄這項技能,不代管檔案。
發布者將它存放在 https://github.com/samber/cc-skills-golang。
Claude、Cursor、Codex 和 Grok Build 可以讀取你從發布者儲存庫加入的 SKILL.md。在聊天中傳送技能的 GitHub 資料夾連結,Grok Bot 就會安裝它。