golang-project-layout

Organize Go repositories into idiomatic cmd/internal/pkg layouts with go.mod and go.work.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

It prevents messy or non-idiomatic Go repository structures by giving clear, practical conventions for where code should live (cmd/, internal/, pkg/) and how to structure modules and workspaces.

Core Features & Use Cases

  • Project scoping and structure: Helps you choose a minimal layout that matches whether you’re building a CLI tool, library, service, or a multi-module monorepo.
  • Correct Go conventions: Enforces Go naming rules for modules and packages, and keeps executable entry points in cmd/ with minimal logic.
  • Maintainable growth paths: Guides when to use go.work for multi-module development and how to decide between internal/ and pkg/ based on export needs.

Quick Start

Tell your AI assistant: “Recommend a clean, idiomatic Go directory layout for a new service repository with multiple binaries, and explain where to put configuration, wiring code, and business logic.”

Frequently Asked Questions about golang-project-layout

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

FAQPage Schema
How do I structure a Go project layout with cmd, internal, and pkg directories?

An idiomatic Go project layout keeps executable entry points minimal in cmd/, private code in internal/, and reusable libraries in pkg/. This structure prevents messy repositories by enforcing clear conventions for where code should live based on export needs.

When should I use go.work for a multi-module Go monorepo?

Use go.work for multi-module development scenarios in a Go monorepo when you need to manage multiple modules simultaneously. It provides a maintainable growth path for multi-module repositories, whereas single-module projects should rely solely on go.mod.

What is the best way to organize a new Go repository for multiple binaries?

The best way to organize multiple binaries in a Go repository is placing each executable entry point in its own subdirectory under cmd/ with minimal logic. This enforces correct Go module and package naming conventions while keeping business logic separated.

How do I decide between using internal or pkg for my Go modules?

Choose internal/ for private code you want to restrict from external imports, and pkg/ for reusable libraries intended for external consumption. This decision enforces correct Go conventions and ensures your repository structure matches your code export needs.

Can I use a minimal Go project layout for a simple CLI tool?

Yes, a minimal Go project layout works for a simple CLI tool by right-sizing the structure to match your specific build target. You can start with a basic cmd/ directory and go.mod file, expanding to internal/ or pkg/ only as your codebase grows.