golang-project-layout

Identify and apply optimal Go project layouts for single-module and monorepo structures.

2.9k|191|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-project-layout
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-project-layout
Source: https://github.com/samber/cc-skills-golang/tree/main/skills/golang-project-layout
Command: npx skills add https://github.com/samber/cc-skills-golang --skill golang-project-layout

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides a structured approach to organizing Go projects, guiding developers on proper directory layouts, module naming, and workspace strategies to support scalable, maintainable codebases across single-module and multi-module scenarios.

Core Features & Use Cases

  • Guidance on choosing between CLI, library, and service layouts, including where to place entry points, interfaces, and business logic.
  • Prescribed directory patterns for cmd/, internal/, and pkg/ to promote clean architecture and easy testing.
  • Guidance for monorepos and multi-module setups, including module naming conventions and workspace decisions like go.work when appropriate.

Quick Start

Plan your project structure for a new Go project by selecting a project type (CLI, library, service) and applying the recommended directory layout and module naming conventions.

Frequently Asked Questions about golang-project-layout

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to structure a scalable Go project layout?

A scalable Go project layout separates entry points, business logic, and shared code using prescribed cmd/, internal/, and pkg/ directories. This structure enforces clean architecture and proper module boundaries for maintainable codebases.

How do I organize a Go monorepo with multiple modules?

Organize a Go monorepo using go.work workspaces to manage multiple modules. This approach prescribes module naming conventions and workspace decisions to coordinate shared dependencies and internal packages across the repository.

When should I use internal packages versus pkg in Go modules?

Use internal packages to restrict imports to your own module, and use pkg for code safe for external consumption. Proper package placement ensures correct visibility boundaries and prevents unintended external dependencies.

How do I set up cmd structure for Go CLI, library, and service layouts?

Set up cmd structure by placing main.go entry points in cmd/<app-name>/ directories. Guidance covers distinguishing between CLI, library, and service layouts to correctly position interfaces and business logic within internal/.

Does this Go project structure guidance cover dependency injection decisions?

Yes, this Go project structure guidance covers dependency injection decisions alongside module naming and workspace strategies. It helps determine where to place interfaces and business logic to support scalable, maintainable codebases.