go-project-layout
Skill9 starsChanged 8 months agoMITView on GitHub
Use when starting a new Go project, organizing packages, or restructuring an existing Go codebase. Covers standard directory layout, package design, Makefile targets, Dockerfile patterns, and module setup.
- Deletes or force-pushes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- eduardo-sl/go-agent-skillstheir own version, first seen Aug 18, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- eduardo-sl/go-agent-skills★ 72same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- golangSkill
- go-code-reviewSkill
- go-concurrencySkill
- go-error-handlingSkill
- go-lintingSkill
- go-performanceSkill
- go-securitySkill
- go-testingSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 100
pkg/: Avoid. If code is meant to be imported, put it at the module root or in a named package. - Very specific: line 101
src/: Not a Go convention. Do not use. - Distinctive: line 171
Avoid circular imports: if A imports B and B needs A, extract the shared type into a third package
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Project Layout
Standard project structure and setup patterns for Go.
Directory Structure
Small projects (libraries, CLIs) should stay flat. Only add structure when the project warrants it. Do not create directories speculatively.
Application Layout
myapp/
├── cmd/
│ └── myapp/
│ └── main.go # entry point, minimal logic
├── internal/
│ ├── server/
│ │ └── server.go # HTTP server setup
│ ├── handler/
│ │ └── user.go # HTTP handlers
│ ├── service/
│ │ └── user.go # business logic
│ └── store/
│ └── postgres.go # data access
├── go.mod
├── go.sum
├── Makefile
├── Dockerfile
├── .golangci.yml
└── README.mdLibrary Layout
mylib/
├── mylib.go # primary package API
├── mylib_test.go
├── internal/
│ └── parse/ # unexported helpers
│ └── parse.go
├── go.mod
└── README.mdKey Directories
cmd/
Each subdirectory is an executable. Keep main.go minimal: parse flags, build dependencies, call run().
// cmd/myapp/main.go
package main
import (
"context"
"fmt"
"os"
"myapp/internal/server"
)
func main() {
if err := run(context.Background()); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run(ctx context.Context) error {
srv, err := server.New()
if err != nil {
return fmt.Errorf("create server: %w", err)
}
return srv.Start(ctx)
}internal/
Packages under internal/ cannot be imported by other modules. Use this for code that is not part of your public API. The Go toolchain enforces this.
When NOT to use certain directories
pkg/: Avoid. If code is meant to be imported, put it at the module root or in a named package.pkg/adds a directory with no meaning.src/: Not a Go convention. Do not use.models//types//utils/: These become dumping grounds. Name packages by what they do, not what they contain.
Module Setup
mkdir myapp && cd myapp
go mod init github.com/yourorg/myappgo.mod with Tool Dependencies (Go 1.24+)
module github.com/yourorg/myapp
go 1.25
tool (
github.com/golangci/golangci-lint/cmd/golangci-lint
golang.org/x/tools/cmd/stringer
)Makefile
.PHONY: build test lint run clean
build: ## Build the binary
go build -o bin/myapp ./cmd/myapp
test: ## Run tests
go test -race -count=1 ./...
lint: ## Run linters
go tool golangci-lint run ./...
run: build ## Build and run
./bin/myapp
clean: ## Remove build artifacts
rm -rf bin/Dockerfile
Multi-stage build for small, secure images:
FROM golang:1.25 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /bin/myapp ./cmd/myapp
FROM gcr.io/distroless/static-debian12
COPY --from=build /bin/myapp /bin/myapp
ENTRYPOINT ["/bin/myapp"]Key points:
CGO_ENABLED=0for static binary (no libc dependency)- Distroless base image: no shell, no package manager, smaller attack surface
- Copy
go.modandgo.sumfirst for Docker layer caching
Package Design Rules
- Name by purpose, not contents:
storenotmodels,authnotutils - One package, one idea: a package should do one thing well
- Avoid circular imports: if A imports B and B needs A, extract the shared type into a third package
- internal for private code: anything under
internal/is hidden from external importers - Keep cmd/ thin: main.go builds dependencies and calls into internal packages
- Accept interfaces, return structs: define interfaces where they are used, return concrete types
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

