This skill enforces idiomatic Go development with TDD, mocks, and structured tests to accelerate reliable feature work.
npx playbooks add skill jumppad-labs/jumppad --skill go-dev-guidelines
This skill provides comprehensive guidelines for idiomatic Go development with a Test-Driven Development (TDD) approach. Follow these patterns when writing Go code, creating tests, organizing projects, or refactoring existing code.
When implementing a new feature in an existing Go project:
*_test.go file with testify/require testsmocks/ subfolderWhen creating a new Go service or package from scratch:
/cmd, /internal, /pkg)go mod init with appropriate module pathFollow these seven core principles for all Go development:
Write tests before implementation. Tests should be easy to read and favor verbosity over abstraction.
All unit tests must use github.com/stretchr/testify/require for assertions.
Generate mocks using mockery. Mocks must be localized in a mocks/ subfolder next to the interface being mocked.
Avoid table-driven tests. Write explicit test functions for each scenario.
Keep positive (success) and negative (error) test cases in separate test functions.
Never ignore errors. Always handle them explicitly or return them to the caller.
Design interfaces with few methods. Use composition over large interfaces.
any Instead of interface{}For generic types, prefer any over interface{} (Go 1.18+).
project-root/
├── cmd/ # Main applications
│ └── myapp/
│ └── main.go
├── internal/ # Private application code
│ ├── handler/ # HTTP handlers
│ │ ├── handler.go
│ │ ├── handler_test.go
│ │ └── mocks/ # Mocks for handler interfaces
│ ├── service/ # Business logic
│ │ ├── service.go
│ │ ├── service_test.go
│ │ └── mocks/
│ └── repository/ # Data access
│ ├── repository.go
│ ├── repository_test.go
│ └── mocks/
├── pkg/ # Public library code
│ └── client/
│ ├── client.go
│ ├── client_test.go
│ └── mocks/
├── api/ # API definitions (OpenAPI, protobuf)
├── configs/ # Configuration files
├── go.mod
├── go.sum
└── README.md
// Unit test with mock
func TestServiceCreate(t *testing.T) {
mockRepo := mocks.NewRepository(t)
mockRepo.On("Save", mock.Anything).Return(nil)
svc := NewService(mockRepo)
err := svc.Create(context.Background(), data)
require.NoError(t, err)
mockRepo.AssertExpectations(t)
}
// Separate negative test
func TestServiceCreate_RepoError(t *testing.T) {
mockRepo := mocks.NewRepository(t)
mockRepo.On("Save", mock.Anything).Return(errors.New("db error"))
svc := NewService(mockRepo)
err := svc.Create(context.Background(), data)
require.Error(t, err)
require.Contains(t, err.Error(), "db error")
}
handler, service)user_service.go, user_service_test.go)UserService, HTTPHandler)-er suffix (Reader, Writer, UserRepository)Use this table to find detailed guidance for specific tasks:
| If You Need To... | See This Resource |
|-------------------|-------------------|
| Set up a new Go project structure | [Project Structure](references/project-structure.md) |
| Understand Go naming conventions | [Naming Conventions](references/naming-conventions.md) |
| Write tests with TDD, testify/require, and mockery | [Testing Guide](references/testing-guide.md) |
| Organize packages, interfaces, and dependencies | [Code Organization](references/code-organization.md) |
| Handle errors idiomatically | [Error Handling](references/error-handling.md) |
| Work with goroutines, channels, and context | [Concurrency Patterns](references/concurrency-patterns.md) |
| Manage dependencies and go.mod | [Dependencies](references/dependencies.md) |
| See complete working examples | [Complete Examples](references/complete-examples.md) |
This skill includes detailed reference documentation in the references/ directory. Claude will load these resources as needed when working on specific tasks.
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.