Standard Go project layouts and architecture patterns. Use when initializing projects or understanding codebase structure.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
This skill defines standard Go project layouts following community conventions.
Use this skill when:
bin/ directoryproject/
├── cmd/ # Command entry points
│ └── myapp/
│ └── main.go
├── internal/ # Private application code
│ ├── handler/
│ ├── service/
│ └── repository/
├── pkg/ # Public libraries
│ └── util/
├── api/ # API specifications (OpenAPI, gRPC)
├── web/ # Web application assets
├── configs/ # Configuration files
├── scripts/ # Build and utility scripts
├── deployments/ # Deployment configs (Docker, K8s)
├── test/ # Integration and system tests
├── docs/ # Documentation
├── bin/ # Build output (REQUIRED, gitignored)
│ └── myapp
├── go.mod # Go module definition
├── go.sum # Dependency checksums
├── Makefile # Build automation (REQUIRED)
├── .gitignore # Must include bin/
├── Dockerfile
└── README.md
project/
├── cmd/
├── internal/
│ ├── domain/ # Business logic
│ ├── ports/ # Interfaces
│ ├── adapters/ # Implementations
│ └── app/ # Application layer
└── ...
project/
├── main.go
├── handler.go
├── service.go
├── bin/
├── go.mod
├── Makefile
└── README.md
Every project MUST have a Makefile:
.PHONY: build test clean lint fmt run
# Build binary to ./bin directory
build:
\t@mkdir -p bin
\tgo build -o bin/myapp cmd/myapp/main.go
# Run the application
run: build
\t./bin/myapp
# Run tests
test:
\tgo test -v ./...
# Run tests with race detector
test-race:
\tgo test -v -race ./...
# Run tests with coverage
coverage:
\tgo test -coverprofile=coverage.out ./...
\tgo tool cover -html=coverage.out
# Format code
fmt:
\tgo fmt ./...
# Run linters
lint:
\tgolangci-lint run
# Clean build artifacts
clean:
\trm -rf bin/
\trm -f coverage.out
# Install dependencies
deps:
\tgo mod download
\tgo mod tidy
./bin/ directorybin/ directory MUST be in .gitignoremake build, NEVER go build directly# Binaries
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary
*.test
# Output of the go coverage tool
*.out
# Dependency directories
vendor/
# Go workspace file
go.work
# Environment files
.env
.env.local
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
module github.com/username/project
go 1.21
require (
github.com/gin-gonic/gin v1.9.1
github.com/stretchr/testify v1.8.4
)
go mod tidy regularlygo mod vendor if needed for reproducible builds# Project Name
Brief description of what this project does.
## Prerequisites
- Go >= 1.21
- make
## Installation
\`\`\`bash
git clone https://github.com/username/project
cd project
make deps
\`\`\`
## Building
\`\`\`bash
make build
\`\`\`
Binary will be in `./bin/`
## Running
\`\`\`bash
make run
\`\`\`
## Testing
\`\`\`bash
make test
make test-race
make coverage
\`\`\`
## Development
\`\`\`bash
make fmt # Format code
make lint # Run linters
make vet # Run go vet
\`\`\`
## License
MIT
internal/ to prevent external importscmd/./bin/