Getting Started
I want to skip the tutorial
If you’re eager to see the outcome of this tutorial, jump straight to our templates’ repo.
Starting from scratch
-
Start a new go project
Terminal window mkdir examplecd examplego mod init example -
Install kibu’s base tool chain
Terminal window go install github.com/google/wire/cmd/wire@latestgo install github.com/kibu-sh/kibu/internal/toolchain/kibugenv2/cmd/kibugenv2@maingo install github.com/kibu-sh/kibu/internal/toolchain/kibuwire/cmd/kibuwire@maingo install github.com/kibu-sh/kibu/internal/toolchain/kibugen_ts/cmd/kibugen_ts@mainSee the Toolchain Reference for details on each tool.
-
Jump start the project structure
Terminal window # this will be our code generation entrypointtouch generate.go# we need a place to put our first servicemkdir -p src/backend/systems/health/servicestouch src/backend/systems/health/health.go
Let’s write a simple service interface in Kibu
src/backend/systems/health/health.go
package health
import ( "context")
type CheckRequest struct {}
type CheckResponse struct { Message string `json:"message"`}
// Activities stub until bug is fixed//kibu:activitytype Activities interface{}
// Service checks the health of the entire system////kibu:servicetype Service interface { // Check returns a message letting us know the service is alive // //kibu:service:method method=GET Check(ctx context.Context, req CheckRequest) (res CheckResponse, err error)}Now, generate some plumbing
generate.go
package generate
// analyze each module and generate system plumbing code//go:generate kibugenv2 ./...
// execute a second pass to generate wire superset//go:generate kibuwire ./...go generate generate.goTwo new files have manifested
System plumbing for the interfaces we defined.
src/backend/systems/health/health.gen.go
A managed wire superset of all the //kibu:provider directives in the system.
At scale, kibu makes managing wire sets a breeze across hundreds of services.
kibuwire/kibuwire.gen.go
Optional: Generate TypeScript Clients
If you’re building a TypeScript frontend, you can also generate type-safe clients:
kibugen_ts -output ./frontend/src/api ./...This creates TypeScript types and service clients from your Go service definitions. See the kibugen_ts Reference for more details.
Understanding Decorators
Kibu uses comment-based decorators to drive code generation:
| Decorator | Purpose |
|---|---|
//kibu:service | Define an HTTP service interface |
//kibu:service:method | Configure an HTTP endpoint |
//kibu:workflow | Define a Temporal workflow |
//kibu:activity | Define Temporal activities |
//kibu:provider | Register a Wire provider |
See the full Decorators Reference for all options.