Kessoku is a next-generation dependency injection framework for Go that enables parallel initialization of dependencies. It benefits developers by simplifying complex dependency management in large-scale applications. It integrates with Go projects to streamline initialization workflows and improve performance.
git clone https://github.com/mazrean/kessoku.gitKessoku is a compile-time dependency injection library for Go designed to speed up application startup by executing independent providers in parallel instead of sequentially. Unlike traditional frameworks like google/wire that initialize services one after another, Kessoku automatically detects independent dependencies and runs them concurrently, dramatically reducing startup time for applications with multiple slow services like databases, caches, and authentication systems. It generates optimized code at compile time with zero runtime overhead, making it ideal for development workflows with frequent restarts and serverless/Lambda cold start scenarios. The library provides an Async() wrapper to mark parallelizable providers and integrates with Go's code generation via //go:generate directives.
1. **Install Kessoku**: Add `github.com/yourorg/kessoku` to your Go module dependencies using `go get github.com/yourorg/kessoku@latest`. 2. **Analyze Dependencies**: Run `kessoku analyze --project-root ./` to scan your project and identify all dependencies in your `main.go` and package files. 3. **Generate Initialization Plan**: Use the prompt template to generate a parallel initialization plan. Replace [PROJECT_ROOT] with your actual project path and specify your key components like [COMPONENT_1], [COMPONENT_2], etc. 4. **Implement Container**: Copy the generated `main.go` file into your project. The Kessoku container will automatically handle dependency resolution and parallel initialization. 5. **Optimize Performance**: Use `kessoku profile --output timing.json` to measure initialization times and identify bottlenecks. Adjust your dependency groups to maximize parallel execution. **Pro Tips:** - Group independent dependencies together in the same `Register` call for maximum parallelism - Use `kessoku debug` to visualize dependency chains before implementation - For complex projects, break initialization into multiple containers for better modularity
Reduce Lambda/serverless cold start times during initialization
Speed up development by eliminating startup delays during frequent app restarts
Parallelize initialization of multiple slow services (PostgreSQL, Redis, S3, Auth0)
Migrate from google/wire while maintaining compile-time DI benefits with faster startup
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/mazrean/kessokuCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Initialize dependencies for a Go project using the Kessoku framework. Analyze the [PROJECT_ROOT] directory structure to identify all required dependencies (e.g., database clients, HTTP servers, configuration managers). Generate a parallel initialization plan using Kessoku's dependency injection container, ensuring thread-safe initialization of [COMPONENT_1], [COMPONENT_2], and [COMPONENT_3]. Output a main.go file with the Kessoku container setup and a dependency graph visualization in Mermaid format.
```go
// main.go - Auto-generated by Kessoku Dependency Initializer
package main
import (
"context"
"log"
"net/http"
"time"
"github.com/yourorg/yourproject/config"
"github.com/yourorg/yourproject/database"
"github.com/yourorg/yourproject/handlers"
"github.com/yourorg/yourproject/services"
"github.com/yourorg/yourproject/kessoku"
)
func main() {
ctx := context.Background()
// Initialize Kessoku container with parallel dependency loading
container := kessoku.NewContainer()
// Register dependencies with explicit initialization order
container.Register("config", func(c *kessoku.Container) (interface{}, error) {
return config.Load("config.yaml")
})
container.Register("db", func(c *kessoku.Container) (interface{}, error) {
cfg := c.MustGet("config").(*config.Config)
return database.NewPostgresClient(cfg.DatabaseURL, cfg.DatabaseTimeout)
})
container.Register("httpServer", func(c *kessoku.Container) (interface{}, error) {
cfg := c.MustGet("config").(*config.Config)
db := c.MustGet("db").(*database.Client)
handler := handlers.NewAPIHandler(db, cfg)
return &http.Server{
Addr: cfg.ServerAddress,
Handler: handler,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}, nil
})
container.Register("paymentService", func(c *kessoku.Container) (interface{}, error) {
cfg := c.MustGet("config").(*config.Config)
db := c.MustGet("db").(*database.Client)
return services.NewPaymentService(db, cfg.PaymentGatewayURL), nil
})
// Parallel initialization with dependency resolution
if err := container.Initialize(ctx); err != nil {
log.Fatalf("Dependency initialization failed: %v", err)
}
// Start HTTP server in goroutine
httpServer := container.MustGet("httpServer").(*http.Server)
go func() {
log.Printf("Starting HTTP server on %s", httpServer.Addr)
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatalf("HTTP server failed: %v", err)
}
}()
// Wait for shutdown signal
<-ctx.Done()
// Graceful shutdown
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
if err := httpServer.Shutdown(ctx); err != nil {
log.Printf("HTTP server shutdown error: %v", err)
}
}
```
```mermaid
graph TD
config[Config] -->|depends on| db[Database Client]
config -->|depends on| httpServer[HTTP Server]
config -->|depends on| paymentService[Payment Service]
db -->|used by| httpServer
db -->|used by| paymentService
httpServer -->|handles requests for| paymentService
style config fill:#f9f,stroke:#333
style db fill:#bbf,stroke:#333
style httpServer fill:#f96,stroke:#333
style paymentService fill:#6f9,stroke:#333
```
**Initialization Performance Metrics:**
- Total dependencies: 4
- Parallel initialization groups: 2
- Database client init: 120ms
- Config loading: 8ms
- HTTP server init: 45ms
- Payment service init: 200ms
- **Total time: 208ms** (vs 373ms sequential)
- **Speedup: 1.8x**
The Kessoku container automatically resolved dependency order and executed independent initializations in parallel, reducing startup time by 44%. The dependency graph clearly shows the initialization hierarchy and runtime relationships between components.Enterprise encrypted messaging with MLS encryption
Get more done every day with Microsoft Teams – powered by AI
Automate security compliance and monitor real-time security posture seamlessly.
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan