WASM & TinyGo Build Review Skill
Target triple, binary size, and syscall/js misuse checks for agents - a cookbook-style Agent Skill for Go 1.26 and TinyGo WASM builds.
Search across all documentation pages
Target triple, binary size, and syscall/js misuse checks for agents - a cookbook-style Agent Skill for Go 1.26 and TinyGo WASM builds.
Produces a WASM build review checklist: correct GOOS/GOARCH, syscall/js vs syscall/wasmimport, TinyGo target tags, size budgets, host runtime compatibility (wazero, wasmtime), and forbidden imports - before merge.
GOOS=wasip1 GOARCH=wasm build targetssyscall/js| Input | Why |
|---|---|
| Build targets | wasip1/wasm, js/wasm, TinyGo board |
| Host runtime | wazero, wasmtime, browser |
| Size budget | KB limit for embedded |
go.mod / TinyGo version | Feature availability |
| Main package imports | Flag cgo, net, os/exec |
wasm-objdump, twiggy, tinygo size)syscall/js in WASI modules - browser-only API.os/exec or raw sockets in WASM without host capability doc.Quick-reference recipe card - copy-paste ready.
# WASI module (Go 1.26)
GOOS=wasip1 GOARCH=wasm go build -o app.wasm ./cmd/wasi/
# Inspect exports and size
wasm-objdump -x app.wasm | head -40
ls -la app.wasm
# TinyGo constrained build (example - verify board)
tinygo build -target=wasi -o tiny.wasm ./cmd/edge/
# wazero smoke (host)
go test ./internal/wasmhost/... -run TestLoadModule -count=1When to reach for this skill:
fmt.Println and net/http in browser WASM draft| Target | Runtime | Go API surface |
|---|---|---|
wasip1/wasm | wazero, wasmtime, Spin | WASI snapshot |
js/wasm | Browser | syscall/js |
| TinyGo board | MCU / WASM | Subset stdlib |
See Go on WebAssembly: Browser, WASI, and Embedded Paths
# Forbidden patterns in WASI
grep -rn 'syscall/js\|js\.Value' --include='*.go' ./cmd/wasi/
grep -rn 'cgo\|os/exec\|"net/http"' --include='*.go' ./cmd/wasi/| Finding | Action |
|---|---|
syscall/js in wasip1 build | Blocker - split packages |
net/http server in WASM | Blocker - use host RPC |
unsafe.Pointer cgo | Blocker unless TinyGo doc exception |
ls -la app.wasm
# Optional: twiggy top for Rust-linked hosts; wasm-objdump for Go wasmfunc TestLoadWASIModule(t *testing.T) {
ctx := context.Background()
r := wazero.NewRuntime(ctx)
defer r.Close(ctx)
mod, err := r.InstantiateWithConfig(ctx, wasmBytes,
wazero.NewModuleConfig().WithStartFunctions("_initialize"))
if err != nil {
t.Fatal(err)
}
defer mod.Close(ctx)
}_initialize, and exported run/main per module contracttinygo flash -target=pico -size=short ./cmd/firmware/ # example - verify board//go:build tinygo tags for divergent code pathsGo 1.26 WASM runtime improvements may change alloc behavior - re-benchmark size after toolchain bump.
See Go 1.26 WASM Runtime and Memory Improvements
syscall/js requires DOM callbacks and js.FuncOf cleanup - leak review in browser targets.
WASI preview vs wasip1: build tags and host capability matrix must match deployment environment.
| Approach | When |
|---|---|
| Rust WASM for size-critical | Team policy |
| Manual platform review | One module |
| CI size gate only | No import semantics |
| This skill | Agent-assisted WASM PR review |
Never. Split internal/browser and internal/wasi packages with build tags.
Skill outputs build commands; browser test in headless Chrome is separate pipeline - link team doc.
Collect size and stdlib needs in inputs. TinyGo for KB budgets; full Go for richer stdlib on WASI hosts.
Stack versions: This page was written for Go 1.26.x (Green Tea GC default, go fix modernizers - verify patch at build), chi (latest - verify at build), gin (latest - verify at build), echo (latest - verify at build), google.golang.org/grpc (latest - verify at build), sigs.k8s.io/controller-runtime (latest - verify at build), kubebuilder (latest - verify at build), tinygo (latest - verify board targets at build), wazero (latest - verify at build), and golangci-lint (latest - verify linter set at build).
Reviewed by Chris St. John·Last updated Jul 16, 2026