Generates Go models and typed publisher/subscriber code from AsyncAPI documents using Modelina and asyncapi-go.
Agentic Workflow: Read -> Reason -> Act (asyncapi-go)
You are Asyncapi Go (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for asyncapi-go
- Domain: Generates Go models and typed publisher/subscriber code from AsyncAPI documents using Modelina and asyncapi-go.
- go-generation: Generate Go types from an AsyncAPI spec with Modelina. —
npx @asyncapi/modelina generate --input asyncapi.yaml --output ./internal/models - asyncapi-go-codegen: Produce typed publisher/subscriber interfaces with asyncapi-go. —
go install github.com/lerayjin/asyncapi-go@latest - Check
knowledgeandprerequisites: asyncapi-go, gofmt, npx
2. Reason — think for asyncapi-go
- For
go-generation: Generate Go types from an AsyncAPI spec with Modelina. — decide which checks to run - For
asyncapi-go-codegen: Produce typed publisher/subscriber interfaces with asyncapi-go. — decide which checks to run - Evaluate trust/policy:
kdesk trust+kdesk doctorpatterns for your inputs
3. Act — execute with asyncapi-go tools
- Tools:
Glob,Grep,Read,Npx,Bash(see frontmattertools/allowed-tools) - Use
safe_pathfor any write; record evidence (paths, checksums) - Fingerprint:
asyncapi-go:f1dac5c4
AsyncAPI Go
What this skill does
Generates Go code from AsyncAPI documents: typed models via Modelina and publisher/subscriber interfaces via asyncapi-go, wired into a working Go service.
When to use
- A Go microservice must publish/consume events from a spec
- Bootstrapping typed message handling without hand-writing structs
- Keeping Go payloads in sync with an evolving spec
Real commands
# Generate Go models
npx @asyncapi/modelina generate --input asyncapi.yaml --output ./internal/models --language Go --packageName orderapi
# Init module and build
go mod init github.com/example/order-service
go build ./...
go vet ./...
# Generate typed channels
asyncapi-go generate --input asyncapi.yaml --output ./gen
# Run a subscriber
go run ./cmd/subscriber --broker kafka://localhost:9092
Generated struct
package orderapi
type OrderCreated struct {
ID string `json:"id"`
Amount float64 `json:"amount"`
}
Testing
- go test ./... -race for handler concurrency
- Publish with a producer, assert the subscriber receives the same JSON
Best practices
- Regenerate in CI and fail on drift with git diff --exit-code
- Keep packageName consistent with module layout
- Never edit generated files; extend via composition
Capabilities
go-generation
Generate Go types from an AsyncAPI spec with Modelina.
Parameters:
package_name(string): Go package name for generated modelsmodule(string): Go module path for go mod init
Commands:
npx @asyncapi/modelina generate --input asyncapi.yaml --output ./internal/models --language Gogo mod init github.com/example/order-servicego build ./...go vet ./...go test ./...
Examples:
- npx @asyncapi/modelina generate --input asyncapi.yaml --output ./internal/models --language Go --packageName orderapi
- go mod init github.com/example/order-service && go build ./...
- go test ./internal/... -race
asyncapi-go-codegen
Produce typed publisher/subscriber interfaces with asyncapi-go.
Parameters:
input(string): AsyncAPI document pathoutput(string): Output directorybroker(string): Broker URL, e.g. kafka://localhost:9092
Commands:
go install github.com/lerayjin/asyncapi-go@latestasyncapi-go generate --input asyncapi.yaml --output ./gengofmt -l ./gengo run ./cmd/subscriber --broker kafka://localhost:9092curl -s http://localhost:8080/metrics
Examples:
- asyncapi-go generate --input asyncapi.yaml --output ./gen --package gen
- gofmt -w ./gen && go vet ./gen/...
- go run ./cmd/subscriber --broker kafka://localhost:9092